babylon.module.d.ts 4.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640
  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. export const Epsilon = 0.001;
  272. /**
  273. * Class used to hold a RBG color
  274. */
  275. export class Color3 {
  276. /**
  277. * Defines the red component (between 0 and 1, default is 0)
  278. */
  279. r: number;
  280. /**
  281. * Defines the green component (between 0 and 1, default is 0)
  282. */
  283. g: number;
  284. /**
  285. * Defines the blue component (between 0 and 1, default is 0)
  286. */
  287. b: number;
  288. /**
  289. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  290. * @param r defines the red component (between 0 and 1, default is 0)
  291. * @param g defines the green component (between 0 and 1, default is 0)
  292. * @param b defines the blue component (between 0 and 1, default is 0)
  293. */
  294. constructor(
  295. /**
  296. * Defines the red component (between 0 and 1, default is 0)
  297. */
  298. r?: number,
  299. /**
  300. * Defines the green component (between 0 and 1, default is 0)
  301. */
  302. g?: number,
  303. /**
  304. * Defines the blue component (between 0 and 1, default is 0)
  305. */
  306. b?: number);
  307. /**
  308. * Creates a string with the Color3 current values
  309. * @returns the string representation of the Color3 object
  310. */
  311. toString(): string;
  312. /**
  313. * Returns the string "Color3"
  314. * @returns "Color3"
  315. */
  316. getClassName(): string;
  317. /**
  318. * Compute the Color3 hash code
  319. * @returns an unique number that can be used to hash Color3 objects
  320. */
  321. getHashCode(): number;
  322. /**
  323. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  324. * @param array defines the array where to store the r,g,b components
  325. * @param index defines an optional index in the target array to define where to start storing values
  326. * @returns the current Color3 object
  327. */
  328. toArray(array: FloatArray, index?: number): Color3;
  329. /**
  330. * Returns a new Color4 object from the current Color3 and the given alpha
  331. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  332. * @returns a new Color4 object
  333. */
  334. toColor4(alpha?: number): Color4;
  335. /**
  336. * Returns a new array populated with 3 numeric elements : red, green and blue values
  337. * @returns the new array
  338. */
  339. asArray(): number[];
  340. /**
  341. * Returns the luminance value
  342. * @returns a float value
  343. */
  344. toLuminance(): number;
  345. /**
  346. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  347. * @param otherColor defines the second operand
  348. * @returns the new Color3 object
  349. */
  350. multiply(otherColor: DeepImmutable<Color3>): Color3;
  351. /**
  352. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  353. * @param otherColor defines the second operand
  354. * @param result defines the Color3 object where to store the result
  355. * @returns the current Color3
  356. */
  357. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  358. /**
  359. * Determines equality between Color3 objects
  360. * @param otherColor defines the second operand
  361. * @returns true if the rgb values are equal to the given ones
  362. */
  363. equals(otherColor: DeepImmutable<Color3>): boolean;
  364. /**
  365. * Determines equality between the current Color3 object and a set of r,b,g values
  366. * @param r defines the red component to check
  367. * @param g defines the green component to check
  368. * @param b defines the blue component to check
  369. * @returns true if the rgb values are equal to the given ones
  370. */
  371. equalsFloats(r: number, g: number, b: number): boolean;
  372. /**
  373. * Multiplies in place each rgb value by scale
  374. * @param scale defines the scaling factor
  375. * @returns the updated Color3
  376. */
  377. scale(scale: number): Color3;
  378. /**
  379. * Multiplies the rgb values by scale and stores the result into "result"
  380. * @param scale defines the scaling factor
  381. * @param result defines the Color3 object where to store the result
  382. * @returns the unmodified current Color3
  383. */
  384. scaleToRef(scale: number, result: Color3): Color3;
  385. /**
  386. * Scale the current Color3 values by a factor and add the result to a given Color3
  387. * @param scale defines the scale factor
  388. * @param result defines color to store the result into
  389. * @returns the unmodified current Color3
  390. */
  391. scaleAndAddToRef(scale: number, result: Color3): Color3;
  392. /**
  393. * Clamps the rgb values by the min and max values and stores the result into "result"
  394. * @param min defines minimum clamping value (default is 0)
  395. * @param max defines maximum clamping value (default is 1)
  396. * @param result defines color to store the result into
  397. * @returns the original Color3
  398. */
  399. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  400. /**
  401. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  402. * @param otherColor defines the second operand
  403. * @returns the new Color3
  404. */
  405. add(otherColor: DeepImmutable<Color3>): Color3;
  406. /**
  407. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  408. * @param otherColor defines the second operand
  409. * @param result defines Color3 object to store the result into
  410. * @returns the unmodified current Color3
  411. */
  412. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  413. /**
  414. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  415. * @param otherColor defines the second operand
  416. * @returns the new Color3
  417. */
  418. subtract(otherColor: DeepImmutable<Color3>): Color3;
  419. /**
  420. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  421. * @param otherColor defines the second operand
  422. * @param result defines Color3 object to store the result into
  423. * @returns the unmodified current Color3
  424. */
  425. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  426. /**
  427. * Copy the current object
  428. * @returns a new Color3 copied the current one
  429. */
  430. clone(): Color3;
  431. /**
  432. * Copies the rgb values from the source in the current Color3
  433. * @param source defines the source Color3 object
  434. * @returns the updated Color3 object
  435. */
  436. copyFrom(source: DeepImmutable<Color3>): Color3;
  437. /**
  438. * Updates the Color3 rgb values from the given floats
  439. * @param r defines the red component to read from
  440. * @param g defines the green component to read from
  441. * @param b defines the blue component to read from
  442. * @returns the current Color3 object
  443. */
  444. copyFromFloats(r: number, g: number, b: number): Color3;
  445. /**
  446. * Updates the Color3 rgb values from the given floats
  447. * @param r defines the red component to read from
  448. * @param g defines the green component to read from
  449. * @param b defines the blue component to read from
  450. * @returns the current Color3 object
  451. */
  452. set(r: number, g: number, b: number): Color3;
  453. /**
  454. * Compute the Color3 hexadecimal code as a string
  455. * @returns a string containing the hexadecimal representation of the Color3 object
  456. */
  457. toHexString(): string;
  458. /**
  459. * Computes a new Color3 converted from the current one to linear space
  460. * @returns a new Color3 object
  461. */
  462. toLinearSpace(): Color3;
  463. /**
  464. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  465. * @param convertedColor defines the Color3 object where to store the linear space version
  466. * @returns the unmodified Color3
  467. */
  468. toLinearSpaceToRef(convertedColor: Color3): Color3;
  469. /**
  470. * Computes a new Color3 converted from the current one to gamma space
  471. * @returns a new Color3 object
  472. */
  473. toGammaSpace(): Color3;
  474. /**
  475. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the gamma space version
  477. * @returns the unmodified Color3
  478. */
  479. toGammaSpaceToRef(convertedColor: Color3): Color3;
  480. private static _BlackReadOnly;
  481. /**
  482. * Creates a new Color3 from the string containing valid hexadecimal values
  483. * @param hex defines a string containing valid hexadecimal values
  484. * @returns a new Color3 object
  485. */
  486. static FromHexString(hex: string): Color3;
  487. /**
  488. * Creates a new Vector3 from the starting index of the given array
  489. * @param array defines the source array
  490. * @param offset defines an offset in the source array
  491. * @returns a new Color3 object
  492. */
  493. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  494. /**
  495. * Creates a new Color3 from integer values (< 256)
  496. * @param r defines the red component to read from (value between 0 and 255)
  497. * @param g defines the green component to read from (value between 0 and 255)
  498. * @param b defines the blue component to read from (value between 0 and 255)
  499. * @returns a new Color3 object
  500. */
  501. static FromInts(r: number, g: number, b: number): Color3;
  502. /**
  503. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  504. * @param start defines the start Color3 value
  505. * @param end defines the end Color3 value
  506. * @param amount defines the gradient value between start and end
  507. * @returns a new Color3 object
  508. */
  509. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  510. /**
  511. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  512. * @param left defines the start value
  513. * @param right defines the end value
  514. * @param amount defines the gradient factor
  515. * @param result defines the Color3 object where to store the result
  516. */
  517. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  518. /**
  519. * Returns a Color3 value containing a red color
  520. * @returns a new Color3 object
  521. */
  522. static Red(): Color3;
  523. /**
  524. * Returns a Color3 value containing a green color
  525. * @returns a new Color3 object
  526. */
  527. static Green(): Color3;
  528. /**
  529. * Returns a Color3 value containing a blue color
  530. * @returns a new Color3 object
  531. */
  532. static Blue(): Color3;
  533. /**
  534. * Returns a Color3 value containing a black color
  535. * @returns a new Color3 object
  536. */
  537. static Black(): Color3;
  538. /**
  539. * Gets a Color3 value containing a black color that must not be updated
  540. */
  541. static readonly BlackReadOnly: DeepImmutable<Color3>;
  542. /**
  543. * Returns a Color3 value containing a white color
  544. * @returns a new Color3 object
  545. */
  546. static White(): Color3;
  547. /**
  548. * Returns a Color3 value containing a purple color
  549. * @returns a new Color3 object
  550. */
  551. static Purple(): Color3;
  552. /**
  553. * Returns a Color3 value containing a magenta color
  554. * @returns a new Color3 object
  555. */
  556. static Magenta(): Color3;
  557. /**
  558. * Returns a Color3 value containing a yellow color
  559. * @returns a new Color3 object
  560. */
  561. static Yellow(): Color3;
  562. /**
  563. * Returns a Color3 value containing a gray color
  564. * @returns a new Color3 object
  565. */
  566. static Gray(): Color3;
  567. /**
  568. * Returns a Color3 value containing a teal color
  569. * @returns a new Color3 object
  570. */
  571. static Teal(): Color3;
  572. /**
  573. * Returns a Color3 value containing a random color
  574. * @returns a new Color3 object
  575. */
  576. static Random(): Color3;
  577. }
  578. /**
  579. * Class used to hold a RBGA color
  580. */
  581. export class Color4 {
  582. /**
  583. * Defines the red component (between 0 and 1, default is 0)
  584. */
  585. r: number;
  586. /**
  587. * Defines the green component (between 0 and 1, default is 0)
  588. */
  589. g: number;
  590. /**
  591. * Defines the blue component (between 0 and 1, default is 0)
  592. */
  593. b: number;
  594. /**
  595. * Defines the alpha component (between 0 and 1, default is 1)
  596. */
  597. a: number;
  598. /**
  599. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  600. * @param r defines the red component (between 0 and 1, default is 0)
  601. * @param g defines the green component (between 0 and 1, default is 0)
  602. * @param b defines the blue component (between 0 and 1, default is 0)
  603. * @param a defines the alpha component (between 0 and 1, default is 1)
  604. */
  605. constructor(
  606. /**
  607. * Defines the red component (between 0 and 1, default is 0)
  608. */
  609. r?: number,
  610. /**
  611. * Defines the green component (between 0 and 1, default is 0)
  612. */
  613. g?: number,
  614. /**
  615. * Defines the blue component (between 0 and 1, default is 0)
  616. */
  617. b?: number,
  618. /**
  619. * Defines the alpha component (between 0 and 1, default is 1)
  620. */
  621. a?: number);
  622. /**
  623. * Adds in place the given Color4 values to the current Color4 object
  624. * @param right defines the second operand
  625. * @returns the current updated Color4 object
  626. */
  627. addInPlace(right: DeepImmutable<Color4>): Color4;
  628. /**
  629. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  630. * @returns the new array
  631. */
  632. asArray(): number[];
  633. /**
  634. * Stores from the starting index in the given array the Color4 successive values
  635. * @param array defines the array where to store the r,g,b components
  636. * @param index defines an optional index in the target array to define where to start storing values
  637. * @returns the current Color4 object
  638. */
  639. toArray(array: number[], index?: number): Color4;
  640. /**
  641. * Determines equality between Color4 objects
  642. * @param otherColor defines the second operand
  643. * @returns true if the rgba values are equal to the given ones
  644. */
  645. equals(otherColor: DeepImmutable<Color4>): boolean;
  646. /**
  647. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  648. * @param right defines the second operand
  649. * @returns a new Color4 object
  650. */
  651. add(right: DeepImmutable<Color4>): Color4;
  652. /**
  653. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  654. * @param right defines the second operand
  655. * @returns a new Color4 object
  656. */
  657. subtract(right: DeepImmutable<Color4>): Color4;
  658. /**
  659. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  660. * @param right defines the second operand
  661. * @param result defines the Color4 object where to store the result
  662. * @returns the current Color4 object
  663. */
  664. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  665. /**
  666. * Creates a new Color4 with the current Color4 values multiplied by scale
  667. * @param scale defines the scaling factor to apply
  668. * @returns a new Color4 object
  669. */
  670. scale(scale: number): Color4;
  671. /**
  672. * Multiplies the current Color4 values by scale and stores the result in "result"
  673. * @param scale defines the scaling factor to apply
  674. * @param result defines the Color4 object where to store the result
  675. * @returns the current unmodified Color4
  676. */
  677. scaleToRef(scale: number, result: Color4): Color4;
  678. /**
  679. * Scale the current Color4 values by a factor and add the result to a given Color4
  680. * @param scale defines the scale factor
  681. * @param result defines the Color4 object where to store the result
  682. * @returns the unmodified current Color4
  683. */
  684. scaleAndAddToRef(scale: number, result: Color4): Color4;
  685. /**
  686. * Clamps the rgb values by the min and max values and stores the result into "result"
  687. * @param min defines minimum clamping value (default is 0)
  688. * @param max defines maximum clamping value (default is 1)
  689. * @param result defines color to store the result into.
  690. * @returns the cuurent Color4
  691. */
  692. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  693. /**
  694. * Multipy an Color4 value by another and return a new Color4 object
  695. * @param color defines the Color4 value to multiply by
  696. * @returns a new Color4 object
  697. */
  698. multiply(color: Color4): Color4;
  699. /**
  700. * Multipy a Color4 value by another and push the result in a reference value
  701. * @param color defines the Color4 value to multiply by
  702. * @param result defines the Color4 to fill the result in
  703. * @returns the result Color4
  704. */
  705. multiplyToRef(color: Color4, result: Color4): Color4;
  706. /**
  707. * Creates a string with the Color4 current values
  708. * @returns the string representation of the Color4 object
  709. */
  710. toString(): string;
  711. /**
  712. * Returns the string "Color4"
  713. * @returns "Color4"
  714. */
  715. getClassName(): string;
  716. /**
  717. * Compute the Color4 hash code
  718. * @returns an unique number that can be used to hash Color4 objects
  719. */
  720. getHashCode(): number;
  721. /**
  722. * Creates a new Color4 copied from the current one
  723. * @returns a new Color4 object
  724. */
  725. clone(): Color4;
  726. /**
  727. * Copies the given Color4 values into the current one
  728. * @param source defines the source Color4 object
  729. * @returns the current updated Color4 object
  730. */
  731. copyFrom(source: Color4): Color4;
  732. /**
  733. * Copies the given float values into the current one
  734. * @param r defines the red component to read from
  735. * @param g defines the green component to read from
  736. * @param b defines the blue component to read from
  737. * @param a defines the alpha component to read from
  738. * @returns the current updated Color4 object
  739. */
  740. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  741. /**
  742. * Copies the given float values into the current one
  743. * @param r defines the red component to read from
  744. * @param g defines the green component to read from
  745. * @param b defines the blue component to read from
  746. * @param a defines the alpha component to read from
  747. * @returns the current updated Color4 object
  748. */
  749. set(r: number, g: number, b: number, a: number): Color4;
  750. /**
  751. * Compute the Color4 hexadecimal code as a string
  752. * @returns a string containing the hexadecimal representation of the Color4 object
  753. */
  754. toHexString(): string;
  755. /**
  756. * Computes a new Color4 converted from the current one to linear space
  757. * @returns a new Color4 object
  758. */
  759. toLinearSpace(): Color4;
  760. /**
  761. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  762. * @param convertedColor defines the Color4 object where to store the linear space version
  763. * @returns the unmodified Color4
  764. */
  765. toLinearSpaceToRef(convertedColor: Color4): Color4;
  766. /**
  767. * Computes a new Color4 converted from the current one to gamma space
  768. * @returns a new Color4 object
  769. */
  770. toGammaSpace(): Color4;
  771. /**
  772. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  773. * @param convertedColor defines the Color4 object where to store the gamma space version
  774. * @returns the unmodified Color4
  775. */
  776. toGammaSpaceToRef(convertedColor: Color4): Color4;
  777. /**
  778. * Creates a new Color4 from the string containing valid hexadecimal values
  779. * @param hex defines a string containing valid hexadecimal values
  780. * @returns a new Color4 object
  781. */
  782. static FromHexString(hex: string): Color4;
  783. /**
  784. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  785. * @param left defines the start value
  786. * @param right defines the end value
  787. * @param amount defines the gradient factor
  788. * @returns a new Color4 object
  789. */
  790. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  791. /**
  792. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  793. * @param left defines the start value
  794. * @param right defines the end value
  795. * @param amount defines the gradient factor
  796. * @param result defines the Color4 object where to store data
  797. */
  798. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  799. /**
  800. * Creates a new Color4 from a Color3 and an alpha value
  801. * @param color3 defines the source Color3 to read from
  802. * @param alpha defines the alpha component (1.0 by default)
  803. * @returns a new Color4 object
  804. */
  805. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  806. /**
  807. * Creates a new Color4 from the starting index element of the given array
  808. * @param array defines the source array to read from
  809. * @param offset defines the offset in the source array
  810. * @returns a new Color4 object
  811. */
  812. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  813. /**
  814. * Creates a new Color3 from integer values (< 256)
  815. * @param r defines the red component to read from (value between 0 and 255)
  816. * @param g defines the green component to read from (value between 0 and 255)
  817. * @param b defines the blue component to read from (value between 0 and 255)
  818. * @param a defines the alpha component to read from (value between 0 and 255)
  819. * @returns a new Color3 object
  820. */
  821. static FromInts(r: number, g: number, b: number, a: number): Color4;
  822. /**
  823. * Check the content of a given array and convert it to an array containing RGBA data
  824. * If the original array was already containing count * 4 values then it is returned directly
  825. * @param colors defines the array to check
  826. * @param count defines the number of RGBA data to expect
  827. * @returns an array containing count * 4 values (RGBA)
  828. */
  829. static CheckColors4(colors: number[], count: number): number[];
  830. }
  831. /**
  832. * Class representing a vector containing 2 coordinates
  833. */
  834. export class Vector2 {
  835. /** defines the first coordinate */
  836. x: number;
  837. /** defines the second coordinate */
  838. y: number;
  839. /**
  840. * Creates a new Vector2 from the given x and y coordinates
  841. * @param x defines the first coordinate
  842. * @param y defines the second coordinate
  843. */
  844. constructor(
  845. /** defines the first coordinate */
  846. x?: number,
  847. /** defines the second coordinate */
  848. y?: number);
  849. /**
  850. * Gets a string with the Vector2 coordinates
  851. * @returns a string with the Vector2 coordinates
  852. */
  853. toString(): string;
  854. /**
  855. * Gets class name
  856. * @returns the string "Vector2"
  857. */
  858. getClassName(): string;
  859. /**
  860. * Gets current vector hash code
  861. * @returns the Vector2 hash code as a number
  862. */
  863. getHashCode(): number;
  864. /**
  865. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  866. * @param array defines the source array
  867. * @param index defines the offset in source array
  868. * @returns the current Vector2
  869. */
  870. toArray(array: FloatArray, index?: number): Vector2;
  871. /**
  872. * Copy the current vector to an array
  873. * @returns a new array with 2 elements: the Vector2 coordinates.
  874. */
  875. asArray(): number[];
  876. /**
  877. * Sets the Vector2 coordinates with the given Vector2 coordinates
  878. * @param source defines the source Vector2
  879. * @returns the current updated Vector2
  880. */
  881. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  882. /**
  883. * Sets the Vector2 coordinates with the given floats
  884. * @param x defines the first coordinate
  885. * @param y defines the second coordinate
  886. * @returns the current updated Vector2
  887. */
  888. copyFromFloats(x: number, y: number): Vector2;
  889. /**
  890. * Sets the Vector2 coordinates with the given floats
  891. * @param x defines the first coordinate
  892. * @param y defines the second coordinate
  893. * @returns the current updated Vector2
  894. */
  895. set(x: number, y: number): Vector2;
  896. /**
  897. * Add another vector with the current one
  898. * @param otherVector defines the other vector
  899. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  900. */
  901. add(otherVector: DeepImmutable<Vector2>): Vector2;
  902. /**
  903. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  904. * @param otherVector defines the other vector
  905. * @param result defines the target vector
  906. * @returns the unmodified current Vector2
  907. */
  908. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  909. /**
  910. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  911. * @param otherVector defines the other vector
  912. * @returns the current updated Vector2
  913. */
  914. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  915. /**
  916. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2
  919. */
  920. addVector3(otherVector: Vector3): Vector2;
  921. /**
  922. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  923. * @param otherVector defines the other vector
  924. * @returns a new Vector2
  925. */
  926. subtract(otherVector: Vector2): Vector2;
  927. /**
  928. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  929. * @param otherVector defines the other vector
  930. * @param result defines the target vector
  931. * @returns the unmodified current Vector2
  932. */
  933. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  934. /**
  935. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  936. * @param otherVector defines the other vector
  937. * @returns the current updated Vector2
  938. */
  939. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  940. /**
  941. * Multiplies in place the current Vector2 coordinates by the given ones
  942. * @param otherVector defines the other vector
  943. * @returns the current updated Vector2
  944. */
  945. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  946. /**
  947. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns a new Vector2
  950. */
  951. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  954. * @param otherVector defines the other vector
  955. * @param result defines the target vector
  956. * @returns the unmodified current Vector2
  957. */
  958. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  959. /**
  960. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  961. * @param x defines the first coordinate
  962. * @param y defines the second coordinate
  963. * @returns a new Vector2
  964. */
  965. multiplyByFloats(x: number, y: number): Vector2;
  966. /**
  967. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  968. * @param otherVector defines the other vector
  969. * @returns a new Vector2
  970. */
  971. divide(otherVector: Vector2): Vector2;
  972. /**
  973. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  974. * @param otherVector defines the other vector
  975. * @param result defines the target vector
  976. * @returns the unmodified current Vector2
  977. */
  978. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  979. /**
  980. * Divides the current Vector2 coordinates by the given ones
  981. * @param otherVector defines the other vector
  982. * @returns the current updated Vector2
  983. */
  984. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  985. /**
  986. * Gets a new Vector2 with current Vector2 negated coordinates
  987. * @returns a new Vector2
  988. */
  989. negate(): Vector2;
  990. /**
  991. * Multiply the Vector2 coordinates by scale
  992. * @param scale defines the scaling factor
  993. * @returns the current updated Vector2
  994. */
  995. scaleInPlace(scale: number): Vector2;
  996. /**
  997. * Returns a new Vector2 scaled by "scale" from the current Vector2
  998. * @param scale defines the scaling factor
  999. * @returns a new Vector2
  1000. */
  1001. scale(scale: number): Vector2;
  1002. /**
  1003. * Scale the current Vector2 values by a factor to a given Vector2
  1004. * @param scale defines the scale factor
  1005. * @param result defines the Vector2 object where to store the result
  1006. * @returns the unmodified current Vector2
  1007. */
  1008. scaleToRef(scale: number, result: Vector2): Vector2;
  1009. /**
  1010. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1011. * @param scale defines the scale factor
  1012. * @param result defines the Vector2 object where to store the result
  1013. * @returns the unmodified current Vector2
  1014. */
  1015. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1016. /**
  1017. * Gets a boolean if two vectors are equals
  1018. * @param otherVector defines the other vector
  1019. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1020. */
  1021. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1022. /**
  1023. * Gets a boolean if two vectors are equals (using an epsilon value)
  1024. * @param otherVector defines the other vector
  1025. * @param epsilon defines the minimal distance to consider equality
  1026. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1027. */
  1028. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1029. /**
  1030. * Gets a new Vector2 from current Vector2 floored values
  1031. * @returns a new Vector2
  1032. */
  1033. floor(): Vector2;
  1034. /**
  1035. * Gets a new Vector2 from current Vector2 floored values
  1036. * @returns a new Vector2
  1037. */
  1038. fract(): Vector2;
  1039. /**
  1040. * Gets the length of the vector
  1041. * @returns the vector length (float)
  1042. */
  1043. length(): number;
  1044. /**
  1045. * Gets the vector squared length
  1046. * @returns the vector squared length (float)
  1047. */
  1048. lengthSquared(): number;
  1049. /**
  1050. * Normalize the vector
  1051. * @returns the current updated Vector2
  1052. */
  1053. normalize(): Vector2;
  1054. /**
  1055. * Gets a new Vector2 copied from the Vector2
  1056. * @returns a new Vector2
  1057. */
  1058. clone(): Vector2;
  1059. /**
  1060. * Gets a new Vector2(0, 0)
  1061. * @returns a new Vector2
  1062. */
  1063. static Zero(): Vector2;
  1064. /**
  1065. * Gets a new Vector2(1, 1)
  1066. * @returns a new Vector2
  1067. */
  1068. static One(): Vector2;
  1069. /**
  1070. * Gets a new Vector2 set from the given index element of the given array
  1071. * @param array defines the data source
  1072. * @param offset defines the offset in the data source
  1073. * @returns a new Vector2
  1074. */
  1075. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1076. /**
  1077. * Sets "result" from the given index element of the given array
  1078. * @param array defines the data source
  1079. * @param offset defines the offset in the data source
  1080. * @param result defines the target vector
  1081. */
  1082. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1083. /**
  1084. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1085. * @param value1 defines 1st point of control
  1086. * @param value2 defines 2nd point of control
  1087. * @param value3 defines 3rd point of control
  1088. * @param value4 defines 4th point of control
  1089. * @param amount defines the interpolation factor
  1090. * @returns a new Vector2
  1091. */
  1092. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1093. /**
  1094. * 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".
  1095. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1096. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1097. * @param value defines the value to clamp
  1098. * @param min defines the lower limit
  1099. * @param max defines the upper limit
  1100. * @returns a new Vector2
  1101. */
  1102. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1103. /**
  1104. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1105. * @param value1 defines the 1st control point
  1106. * @param tangent1 defines the outgoing tangent
  1107. * @param value2 defines the 2nd control point
  1108. * @param tangent2 defines the incoming tangent
  1109. * @param amount defines the interpolation factor
  1110. * @returns a new Vector2
  1111. */
  1112. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1113. /**
  1114. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1115. * @param start defines the start vector
  1116. * @param end defines the end vector
  1117. * @param amount defines the interpolation factor
  1118. * @returns a new Vector2
  1119. */
  1120. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1121. /**
  1122. * Gets the dot product of the vector "left" and the vector "right"
  1123. * @param left defines first vector
  1124. * @param right defines second vector
  1125. * @returns the dot product (float)
  1126. */
  1127. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1128. /**
  1129. * Returns a new Vector2 equal to the normalized given vector
  1130. * @param vector defines the vector to normalize
  1131. * @returns a new Vector2
  1132. */
  1133. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1134. /**
  1135. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1136. * @param left defines 1st vector
  1137. * @param right defines 2nd vector
  1138. * @returns a new Vector2
  1139. */
  1140. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1141. /**
  1142. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1143. * @param left defines 1st vector
  1144. * @param right defines 2nd vector
  1145. * @returns a new Vector2
  1146. */
  1147. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1148. /**
  1149. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1150. * @param vector defines the vector to transform
  1151. * @param transformation defines the matrix to apply
  1152. * @returns a new Vector2
  1153. */
  1154. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1155. /**
  1156. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1157. * @param vector defines the vector to transform
  1158. * @param transformation defines the matrix to apply
  1159. * @param result defines the target vector
  1160. */
  1161. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1162. /**
  1163. * Determines if a given vector is included in a triangle
  1164. * @param p defines the vector to test
  1165. * @param p0 defines 1st triangle point
  1166. * @param p1 defines 2nd triangle point
  1167. * @param p2 defines 3rd triangle point
  1168. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1169. */
  1170. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1171. /**
  1172. * Gets the distance between the vectors "value1" and "value2"
  1173. * @param value1 defines first vector
  1174. * @param value2 defines second vector
  1175. * @returns the distance between vectors
  1176. */
  1177. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1178. /**
  1179. * Returns the squared distance between the vectors "value1" and "value2"
  1180. * @param value1 defines first vector
  1181. * @param value2 defines second vector
  1182. * @returns the squared distance between vectors
  1183. */
  1184. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1185. /**
  1186. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1187. * @param value1 defines first vector
  1188. * @param value2 defines second vector
  1189. * @returns a new Vector2
  1190. */
  1191. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1192. /**
  1193. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1194. * @param p defines the middle point
  1195. * @param segA defines one point of the segment
  1196. * @param segB defines the other point of the segment
  1197. * @returns the shortest distance
  1198. */
  1199. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1200. }
  1201. /**
  1202. * Classed used to store (x,y,z) vector representation
  1203. * A Vector3 is the main object used in 3D geometry
  1204. * It can represent etiher the coordinates of a point the space, either a direction
  1205. * Reminder: js uses a left handed forward facing system
  1206. */
  1207. export class Vector3 {
  1208. /**
  1209. * Defines the first coordinates (on X axis)
  1210. */
  1211. x: number;
  1212. /**
  1213. * Defines the second coordinates (on Y axis)
  1214. */
  1215. y: number;
  1216. /**
  1217. * Defines the third coordinates (on Z axis)
  1218. */
  1219. z: number;
  1220. private static _UpReadOnly;
  1221. /**
  1222. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1223. * @param x defines the first coordinates (on X axis)
  1224. * @param y defines the second coordinates (on Y axis)
  1225. * @param z defines the third coordinates (on Z axis)
  1226. */
  1227. constructor(
  1228. /**
  1229. * Defines the first coordinates (on X axis)
  1230. */
  1231. x?: number,
  1232. /**
  1233. * Defines the second coordinates (on Y axis)
  1234. */
  1235. y?: number,
  1236. /**
  1237. * Defines the third coordinates (on Z axis)
  1238. */
  1239. z?: number);
  1240. /**
  1241. * Creates a string representation of the Vector3
  1242. * @returns a string with the Vector3 coordinates.
  1243. */
  1244. toString(): string;
  1245. /**
  1246. * Gets the class name
  1247. * @returns the string "Vector3"
  1248. */
  1249. getClassName(): string;
  1250. /**
  1251. * Creates the Vector3 hash code
  1252. * @returns a number which tends to be unique between Vector3 instances
  1253. */
  1254. getHashCode(): number;
  1255. /**
  1256. * Creates an array containing three elements : the coordinates of the Vector3
  1257. * @returns a new array of numbers
  1258. */
  1259. asArray(): number[];
  1260. /**
  1261. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1262. * @param array defines the destination array
  1263. * @param index defines the offset in the destination array
  1264. * @returns the current Vector3
  1265. */
  1266. toArray(array: FloatArray, index?: number): Vector3;
  1267. /**
  1268. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1269. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1270. */
  1271. toQuaternion(): Quaternion;
  1272. /**
  1273. * Adds the given vector to the current Vector3
  1274. * @param otherVector defines the second operand
  1275. * @returns the current updated Vector3
  1276. */
  1277. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1278. /**
  1279. * Adds the given coordinates to the current Vector3
  1280. * @param x defines the x coordinate of the operand
  1281. * @param y defines the y coordinate of the operand
  1282. * @param z defines the z coordinate of the operand
  1283. * @returns the current updated Vector3
  1284. */
  1285. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1286. /**
  1287. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1288. * @param otherVector defines the second operand
  1289. * @returns the resulting Vector3
  1290. */
  1291. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1292. /**
  1293. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1294. * @param otherVector defines the second operand
  1295. * @param result defines the Vector3 object where to store the result
  1296. * @returns the current Vector3
  1297. */
  1298. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1299. /**
  1300. * Subtract the given vector from the current Vector3
  1301. * @param otherVector defines the second operand
  1302. * @returns the current updated Vector3
  1303. */
  1304. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the resulting Vector3
  1309. */
  1310. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1313. * @param otherVector defines the second operand
  1314. * @param result defines the Vector3 object where to store the result
  1315. * @returns the current Vector3
  1316. */
  1317. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1318. /**
  1319. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1320. * @param x defines the x coordinate of the operand
  1321. * @param y defines the y coordinate of the operand
  1322. * @param z defines the z coordinate of the operand
  1323. * @returns the resulting Vector3
  1324. */
  1325. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1326. /**
  1327. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1328. * @param x defines the x coordinate of the operand
  1329. * @param y defines the y coordinate of the operand
  1330. * @param z defines the z coordinate of the operand
  1331. * @param result defines the Vector3 object where to store the result
  1332. * @returns the current Vector3
  1333. */
  1334. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1335. /**
  1336. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1337. * @returns a new Vector3
  1338. */
  1339. negate(): Vector3;
  1340. /**
  1341. * Multiplies the Vector3 coordinates by the float "scale"
  1342. * @param scale defines the multiplier factor
  1343. * @returns the current updated Vector3
  1344. */
  1345. scaleInPlace(scale: number): Vector3;
  1346. /**
  1347. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1348. * @param scale defines the multiplier factor
  1349. * @returns a new Vector3
  1350. */
  1351. scale(scale: number): Vector3;
  1352. /**
  1353. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1354. * @param scale defines the multiplier factor
  1355. * @param result defines the Vector3 object where to store the result
  1356. * @returns the current Vector3
  1357. */
  1358. scaleToRef(scale: number, result: Vector3): Vector3;
  1359. /**
  1360. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1361. * @param scale defines the scale factor
  1362. * @param result defines the Vector3 object where to store the result
  1363. * @returns the unmodified current Vector3
  1364. */
  1365. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1366. /**
  1367. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1368. * @param otherVector defines the second operand
  1369. * @returns true if both vectors are equals
  1370. */
  1371. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1372. /**
  1373. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1374. * @param otherVector defines the second operand
  1375. * @param epsilon defines the minimal distance to define values as equals
  1376. * @returns true if both vectors are distant less than epsilon
  1377. */
  1378. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1379. /**
  1380. * Returns true if the current Vector3 coordinates equals the given floats
  1381. * @param x defines the x coordinate of the operand
  1382. * @param y defines the y coordinate of the operand
  1383. * @param z defines the z coordinate of the operand
  1384. * @returns true if both vectors are equals
  1385. */
  1386. equalsToFloats(x: number, y: number, z: number): boolean;
  1387. /**
  1388. * Multiplies the current Vector3 coordinates by the given ones
  1389. * @param otherVector defines the second operand
  1390. * @returns the current updated Vector3
  1391. */
  1392. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1393. /**
  1394. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1395. * @param otherVector defines the second operand
  1396. * @returns the new Vector3
  1397. */
  1398. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1399. /**
  1400. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1401. * @param otherVector defines the second operand
  1402. * @param result defines the Vector3 object where to store the result
  1403. * @returns the current Vector3
  1404. */
  1405. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1406. /**
  1407. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1408. * @param x defines the x coordinate of the operand
  1409. * @param y defines the y coordinate of the operand
  1410. * @param z defines the z coordinate of the operand
  1411. * @returns the new Vector3
  1412. */
  1413. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1414. /**
  1415. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1416. * @param otherVector defines the second operand
  1417. * @returns the new Vector3
  1418. */
  1419. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1420. /**
  1421. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1422. * @param otherVector defines the second operand
  1423. * @param result defines the Vector3 object where to store the result
  1424. * @returns the current Vector3
  1425. */
  1426. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1427. /**
  1428. * Divides the current Vector3 coordinates by the given ones.
  1429. * @param otherVector defines the second operand
  1430. * @returns the current updated Vector3
  1431. */
  1432. divideInPlace(otherVector: Vector3): Vector3;
  1433. /**
  1434. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1435. * @param other defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1441. * @param other defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1447. * @param x defines the x coordinate of the operand
  1448. * @param y defines the y coordinate of the operand
  1449. * @param z defines the z coordinate of the operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1455. * @param x defines the x coordinate of the operand
  1456. * @param y defines the y coordinate of the operand
  1457. * @param z defines the z coordinate of the operand
  1458. * @returns the current updated Vector3
  1459. */
  1460. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1461. /**
  1462. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1463. * Check if is non uniform within a certain amount of decimal places to account for this
  1464. * @param epsilon the amount the values can differ
  1465. * @returns if the the vector is non uniform to a certain number of decimal places
  1466. */
  1467. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1468. /**
  1469. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1470. */
  1471. readonly isNonUniform: boolean;
  1472. /**
  1473. * Gets a new Vector3 from current Vector3 floored values
  1474. * @returns a new Vector3
  1475. */
  1476. floor(): Vector3;
  1477. /**
  1478. * Gets a new Vector3 from current Vector3 floored values
  1479. * @returns a new Vector3
  1480. */
  1481. fract(): Vector3;
  1482. /**
  1483. * Gets the length of the Vector3
  1484. * @returns the length of the Vecto3
  1485. */
  1486. length(): number;
  1487. /**
  1488. * Gets the squared length of the Vector3
  1489. * @returns squared length of the Vector3
  1490. */
  1491. lengthSquared(): number;
  1492. /**
  1493. * Normalize the current Vector3.
  1494. * Please note that this is an in place operation.
  1495. * @returns the current updated Vector3
  1496. */
  1497. normalize(): Vector3;
  1498. /**
  1499. * Reorders the x y z properties of the vector in place
  1500. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1501. * @returns the current updated vector
  1502. */
  1503. reorderInPlace(order: string): this;
  1504. /**
  1505. * Rotates the vector around 0,0,0 by a quaternion
  1506. * @param quaternion the rotation quaternion
  1507. * @param result vector to store the result
  1508. * @returns the resulting vector
  1509. */
  1510. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1511. /**
  1512. * Rotates a vector around a given point
  1513. * @param quaternion the rotation quaternion
  1514. * @param point the point to rotate around
  1515. * @param result vector to store the result
  1516. * @returns the resulting vector
  1517. */
  1518. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1519. /**
  1520. * Normalize the current Vector3 with the given input length.
  1521. * Please note that this is an in place operation.
  1522. * @param len the length of the vector
  1523. * @returns the current updated Vector3
  1524. */
  1525. normalizeFromLength(len: number): Vector3;
  1526. /**
  1527. * Normalize the current Vector3 to a new vector
  1528. * @returns the new Vector3
  1529. */
  1530. normalizeToNew(): Vector3;
  1531. /**
  1532. * Normalize the current Vector3 to the reference
  1533. * @param reference define the Vector3 to update
  1534. * @returns the updated Vector3
  1535. */
  1536. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1537. /**
  1538. * Creates a new Vector3 copied from the current Vector3
  1539. * @returns the new Vector3
  1540. */
  1541. clone(): Vector3;
  1542. /**
  1543. * Copies the given vector coordinates to the current Vector3 ones
  1544. * @param source defines the source Vector3
  1545. * @returns the current updated Vector3
  1546. */
  1547. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1548. /**
  1549. * Copies the given floats to the current Vector3 coordinates
  1550. * @param x defines the x coordinate of the operand
  1551. * @param y defines the y coordinate of the operand
  1552. * @param z defines the z coordinate of the operand
  1553. * @returns the current updated Vector3
  1554. */
  1555. copyFromFloats(x: number, y: number, z: number): Vector3;
  1556. /**
  1557. * Copies the given floats to the current Vector3 coordinates
  1558. * @param x defines the x coordinate of the operand
  1559. * @param y defines the y coordinate of the operand
  1560. * @param z defines the z coordinate of the operand
  1561. * @returns the current updated Vector3
  1562. */
  1563. set(x: number, y: number, z: number): Vector3;
  1564. /**
  1565. * Copies the given float to the current Vector3 coordinates
  1566. * @param v defines the x, y and z coordinates of the operand
  1567. * @returns the current updated Vector3
  1568. */
  1569. setAll(v: number): Vector3;
  1570. /**
  1571. * Get the clip factor between two vectors
  1572. * @param vector0 defines the first operand
  1573. * @param vector1 defines the second operand
  1574. * @param axis defines the axis to use
  1575. * @param size defines the size along the axis
  1576. * @returns the clip factor
  1577. */
  1578. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1579. /**
  1580. * Get angle between two vectors
  1581. * @param vector0 angle between vector0 and vector1
  1582. * @param vector1 angle between vector0 and vector1
  1583. * @param normal direction of the normal
  1584. * @return the angle between vector0 and vector1
  1585. */
  1586. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1587. /**
  1588. * Returns a new Vector3 set from the index "offset" of the given array
  1589. * @param array defines the source array
  1590. * @param offset defines the offset in the source array
  1591. * @returns the new Vector3
  1592. */
  1593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1594. /**
  1595. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1596. * This function is deprecated. Use FromArray instead
  1597. * @param array defines the source array
  1598. * @param offset defines the offset in the source array
  1599. * @returns the new Vector3
  1600. */
  1601. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1602. /**
  1603. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1604. * @param array defines the source array
  1605. * @param offset defines the offset in the source array
  1606. * @param result defines the Vector3 where to store the result
  1607. */
  1608. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1609. /**
  1610. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1611. * This function is deprecated. Use FromArrayToRef instead.
  1612. * @param array defines the source array
  1613. * @param offset defines the offset in the source array
  1614. * @param result defines the Vector3 where to store the result
  1615. */
  1616. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1617. /**
  1618. * Sets the given vector "result" with the given floats.
  1619. * @param x defines the x coordinate of the source
  1620. * @param y defines the y coordinate of the source
  1621. * @param z defines the z coordinate of the source
  1622. * @param result defines the Vector3 where to store the result
  1623. */
  1624. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1625. /**
  1626. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1627. * @returns a new empty Vector3
  1628. */
  1629. static Zero(): Vector3;
  1630. /**
  1631. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1632. * @returns a new unit Vector3
  1633. */
  1634. static One(): Vector3;
  1635. /**
  1636. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1637. * @returns a new up Vector3
  1638. */
  1639. static Up(): Vector3;
  1640. /**
  1641. * Gets a up Vector3 that must not be updated
  1642. */
  1643. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1644. /**
  1645. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1646. * @returns a new down Vector3
  1647. */
  1648. static Down(): Vector3;
  1649. /**
  1650. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1651. * @returns a new forward Vector3
  1652. */
  1653. static Forward(): Vector3;
  1654. /**
  1655. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1656. * @returns a new forward Vector3
  1657. */
  1658. static Backward(): Vector3;
  1659. /**
  1660. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1661. * @returns a new right Vector3
  1662. */
  1663. static Right(): Vector3;
  1664. /**
  1665. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1666. * @returns a new left Vector3
  1667. */
  1668. static Left(): Vector3;
  1669. /**
  1670. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1671. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1672. * @param vector defines the Vector3 to transform
  1673. * @param transformation defines the transformation matrix
  1674. * @returns the transformed Vector3
  1675. */
  1676. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1677. /**
  1678. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1679. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1680. * @param vector defines the Vector3 to transform
  1681. * @param transformation defines the transformation matrix
  1682. * @param result defines the Vector3 where to store the result
  1683. */
  1684. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1685. /**
  1686. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1687. * This method computes tranformed coordinates only, not transformed direction vectors
  1688. * @param x define the x coordinate of the source vector
  1689. * @param y define the y coordinate of the source vector
  1690. * @param z define the z coordinate of the source vector
  1691. * @param transformation defines the transformation matrix
  1692. * @param result defines the Vector3 where to store the result
  1693. */
  1694. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1695. /**
  1696. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1697. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1698. * @param vector defines the Vector3 to transform
  1699. * @param transformation defines the transformation matrix
  1700. * @returns the new Vector3
  1701. */
  1702. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1703. /**
  1704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1705. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1706. * @param vector defines the Vector3 to transform
  1707. * @param transformation defines the transformation matrix
  1708. * @param result defines the Vector3 where to store the result
  1709. */
  1710. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1711. /**
  1712. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1713. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1714. * @param x define the x coordinate of the source vector
  1715. * @param y define the y coordinate of the source vector
  1716. * @param z define the z coordinate of the source vector
  1717. * @param transformation defines the transformation matrix
  1718. * @param result defines the Vector3 where to store the result
  1719. */
  1720. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1721. /**
  1722. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1723. * @param value1 defines the first control point
  1724. * @param value2 defines the second control point
  1725. * @param value3 defines the third control point
  1726. * @param value4 defines the fourth control point
  1727. * @param amount defines the amount on the spline to use
  1728. * @returns the new Vector3
  1729. */
  1730. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1731. /**
  1732. * 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"
  1733. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1734. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1735. * @param value defines the current value
  1736. * @param min defines the lower range value
  1737. * @param max defines the upper range value
  1738. * @returns the new Vector3
  1739. */
  1740. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1741. /**
  1742. * 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"
  1743. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1744. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1745. * @param value defines the current value
  1746. * @param min defines the lower range value
  1747. * @param max defines the upper range value
  1748. * @param result defines the Vector3 where to store the result
  1749. */
  1750. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1751. /**
  1752. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1753. * @param value1 defines the first control point
  1754. * @param tangent1 defines the first tangent vector
  1755. * @param value2 defines the second control point
  1756. * @param tangent2 defines the second tangent vector
  1757. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1758. * @returns the new Vector3
  1759. */
  1760. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1761. /**
  1762. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1763. * @param start defines the start value
  1764. * @param end defines the end value
  1765. * @param amount max defines amount between both (between 0 and 1)
  1766. * @returns the new Vector3
  1767. */
  1768. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1769. /**
  1770. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1771. * @param start defines the start value
  1772. * @param end defines the end value
  1773. * @param amount max defines amount between both (between 0 and 1)
  1774. * @param result defines the Vector3 where to store the result
  1775. */
  1776. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1777. /**
  1778. * Returns the dot product (float) between the vectors "left" and "right"
  1779. * @param left defines the left operand
  1780. * @param right defines the right operand
  1781. * @returns the dot product
  1782. */
  1783. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1784. /**
  1785. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1786. * The cross product is then orthogonal to both "left" and "right"
  1787. * @param left defines the left operand
  1788. * @param right defines the right operand
  1789. * @returns the cross product
  1790. */
  1791. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1792. /**
  1793. * Sets the given vector "result" with the cross product of "left" and "right"
  1794. * The cross product is then orthogonal to both "left" and "right"
  1795. * @param left defines the left operand
  1796. * @param right defines the right operand
  1797. * @param result defines the Vector3 where to store the result
  1798. */
  1799. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1800. /**
  1801. * Returns a new Vector3 as the normalization of the given vector
  1802. * @param vector defines the Vector3 to normalize
  1803. * @returns the new Vector3
  1804. */
  1805. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1806. /**
  1807. * Sets the given vector "result" with the normalization of the given first vector
  1808. * @param vector defines the Vector3 to normalize
  1809. * @param result defines the Vector3 where to store the result
  1810. */
  1811. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1812. /**
  1813. * Project a Vector3 onto screen space
  1814. * @param vector defines the Vector3 to project
  1815. * @param world defines the world matrix to use
  1816. * @param transform defines the transform (view x projection) matrix to use
  1817. * @param viewport defines the screen viewport to use
  1818. * @returns the new Vector3
  1819. */
  1820. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1821. /** @hidden */
  1822. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1823. /**
  1824. * Unproject from screen space to object space
  1825. * @param source defines the screen space Vector3 to use
  1826. * @param viewportWidth defines the current width of the viewport
  1827. * @param viewportHeight defines the current height of the viewport
  1828. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1829. * @param transform defines the transform (view x projection) matrix to use
  1830. * @returns the new Vector3
  1831. */
  1832. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1833. /**
  1834. * Unproject from screen space to object space
  1835. * @param source defines the screen space Vector3 to use
  1836. * @param viewportWidth defines the current width of the viewport
  1837. * @param viewportHeight defines the current height of the viewport
  1838. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1839. * @param view defines the view matrix to use
  1840. * @param projection defines the projection matrix to use
  1841. * @returns the new Vector3
  1842. */
  1843. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param view defines the view matrix to use
  1851. * @param projection defines the projection matrix to use
  1852. * @param result defines the Vector3 where to store the result
  1853. */
  1854. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param sourceX defines the screen space x coordinate to use
  1858. * @param sourceY defines the screen space y coordinate to use
  1859. * @param sourceZ defines the screen space z coordinate to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @param result defines the Vector3 where to store the result
  1866. */
  1867. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1868. /**
  1869. * Gets the minimal coordinate values between two Vector3
  1870. * @param left defines the first operand
  1871. * @param right defines the second operand
  1872. * @returns the new Vector3
  1873. */
  1874. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1875. /**
  1876. * Gets the maximal coordinate values between two Vector3
  1877. * @param left defines the first operand
  1878. * @param right defines the second operand
  1879. * @returns the new Vector3
  1880. */
  1881. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1882. /**
  1883. * Returns the distance between the vectors "value1" and "value2"
  1884. * @param value1 defines the first operand
  1885. * @param value2 defines the second operand
  1886. * @returns the distance
  1887. */
  1888. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1889. /**
  1890. * Returns the squared distance between the vectors "value1" and "value2"
  1891. * @param value1 defines the first operand
  1892. * @param value2 defines the second operand
  1893. * @returns the squared distance
  1894. */
  1895. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1896. /**
  1897. * Returns a new Vector3 located at the center between "value1" and "value2"
  1898. * @param value1 defines the first operand
  1899. * @param value2 defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1905. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1906. * to something in order to rotate it from its local system to the given target system
  1907. * Note: axis1, axis2 and axis3 are normalized during this operation
  1908. * @param axis1 defines the first axis
  1909. * @param axis2 defines the second axis
  1910. * @param axis3 defines the third axis
  1911. * @returns a new Vector3
  1912. */
  1913. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1914. /**
  1915. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1916. * @param axis1 defines the first axis
  1917. * @param axis2 defines the second axis
  1918. * @param axis3 defines the third axis
  1919. * @param ref defines the Vector3 where to store the result
  1920. */
  1921. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1922. }
  1923. /**
  1924. * Vector4 class created for EulerAngle class conversion to Quaternion
  1925. */
  1926. export class Vector4 {
  1927. /** x value of the vector */
  1928. x: number;
  1929. /** y value of the vector */
  1930. y: number;
  1931. /** z value of the vector */
  1932. z: number;
  1933. /** w value of the vector */
  1934. w: number;
  1935. /**
  1936. * Creates a Vector4 object from the given floats.
  1937. * @param x x value of the vector
  1938. * @param y y value of the vector
  1939. * @param z z value of the vector
  1940. * @param w w value of the vector
  1941. */
  1942. constructor(
  1943. /** x value of the vector */
  1944. x: number,
  1945. /** y value of the vector */
  1946. y: number,
  1947. /** z value of the vector */
  1948. z: number,
  1949. /** w value of the vector */
  1950. w: number);
  1951. /**
  1952. * Returns the string with the Vector4 coordinates.
  1953. * @returns a string containing all the vector values
  1954. */
  1955. toString(): string;
  1956. /**
  1957. * Returns the string "Vector4".
  1958. * @returns "Vector4"
  1959. */
  1960. getClassName(): string;
  1961. /**
  1962. * Returns the Vector4 hash code.
  1963. * @returns a unique hash code
  1964. */
  1965. getHashCode(): number;
  1966. /**
  1967. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1968. * @returns the resulting array
  1969. */
  1970. asArray(): number[];
  1971. /**
  1972. * Populates the given array from the given index with the Vector4 coordinates.
  1973. * @param array array to populate
  1974. * @param index index of the array to start at (default: 0)
  1975. * @returns the Vector4.
  1976. */
  1977. toArray(array: FloatArray, index?: number): Vector4;
  1978. /**
  1979. * Adds the given vector to the current Vector4.
  1980. * @param otherVector the vector to add
  1981. * @returns the updated Vector4.
  1982. */
  1983. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1984. /**
  1985. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1986. * @param otherVector the vector to add
  1987. * @returns the resulting vector
  1988. */
  1989. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1990. /**
  1991. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1992. * @param otherVector the vector to add
  1993. * @param result the vector to store the result
  1994. * @returns the current Vector4.
  1995. */
  1996. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1997. /**
  1998. * Subtract in place the given vector from the current Vector4.
  1999. * @param otherVector the vector to subtract
  2000. * @returns the updated Vector4.
  2001. */
  2002. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2003. /**
  2004. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2005. * @param otherVector the vector to add
  2006. * @returns the new vector with the result
  2007. */
  2008. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2009. /**
  2010. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2011. * @param otherVector the vector to subtract
  2012. * @param result the vector to store the result
  2013. * @returns the current Vector4.
  2014. */
  2015. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2016. /**
  2017. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2018. */
  2019. /**
  2020. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2021. * @param x value to subtract
  2022. * @param y value to subtract
  2023. * @param z value to subtract
  2024. * @param w value to subtract
  2025. * @returns new vector containing the result
  2026. */
  2027. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2028. /**
  2029. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2030. * @param x value to subtract
  2031. * @param y value to subtract
  2032. * @param z value to subtract
  2033. * @param w value to subtract
  2034. * @param result the vector to store the result in
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2040. * @returns a new vector with the negated values
  2041. */
  2042. negate(): Vector4;
  2043. /**
  2044. * Multiplies the current Vector4 coordinates by scale (float).
  2045. * @param scale the number to scale with
  2046. * @returns the updated Vector4.
  2047. */
  2048. scaleInPlace(scale: number): Vector4;
  2049. /**
  2050. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2051. * @param scale the number to scale with
  2052. * @returns a new vector with the result
  2053. */
  2054. scale(scale: number): Vector4;
  2055. /**
  2056. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2057. * @param scale the number to scale with
  2058. * @param result a vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. scaleToRef(scale: number, result: Vector4): Vector4;
  2062. /**
  2063. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2064. * @param scale defines the scale factor
  2065. * @param result defines the Vector4 object where to store the result
  2066. * @returns the unmodified current Vector4
  2067. */
  2068. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2069. /**
  2070. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2071. * @param otherVector the vector to compare against
  2072. * @returns true if they are equal
  2073. */
  2074. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2075. /**
  2076. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2077. * @param otherVector vector to compare against
  2078. * @param epsilon (Default: very small number)
  2079. * @returns true if they are equal
  2080. */
  2081. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2082. /**
  2083. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2084. * @param x x value to compare against
  2085. * @param y y value to compare against
  2086. * @param z z value to compare against
  2087. * @param w w value to compare against
  2088. * @returns true if equal
  2089. */
  2090. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2091. /**
  2092. * Multiplies in place the current Vector4 by the given one.
  2093. * @param otherVector vector to multiple with
  2094. * @returns the updated Vector4.
  2095. */
  2096. multiplyInPlace(otherVector: Vector4): Vector4;
  2097. /**
  2098. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2099. * @param otherVector vector to multiple with
  2100. * @returns resulting new vector
  2101. */
  2102. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2103. /**
  2104. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2105. * @param otherVector vector to multiple with
  2106. * @param result vector to store the result
  2107. * @returns the current Vector4.
  2108. */
  2109. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2110. /**
  2111. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2112. * @param x x value multiply with
  2113. * @param y y value multiply with
  2114. * @param z z value multiply with
  2115. * @param w w value multiply with
  2116. * @returns resulting new vector
  2117. */
  2118. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2121. * @param otherVector vector to devide with
  2122. * @returns resulting new vector
  2123. */
  2124. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2127. * @param otherVector vector to devide with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Divides the current Vector3 coordinates by the given ones.
  2134. * @param otherVector vector to devide with
  2135. * @returns the updated Vector3.
  2136. */
  2137. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2138. /**
  2139. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2140. * @param other defines the second operand
  2141. * @returns the current updated Vector4
  2142. */
  2143. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2144. /**
  2145. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2146. * @param other defines the second operand
  2147. * @returns the current updated Vector4
  2148. */
  2149. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2150. /**
  2151. * Gets a new Vector4 from current Vector4 floored values
  2152. * @returns a new Vector4
  2153. */
  2154. floor(): Vector4;
  2155. /**
  2156. * Gets a new Vector4 from current Vector3 floored values
  2157. * @returns a new Vector4
  2158. */
  2159. fract(): Vector4;
  2160. /**
  2161. * Returns the Vector4 length (float).
  2162. * @returns the length
  2163. */
  2164. length(): number;
  2165. /**
  2166. * Returns the Vector4 squared length (float).
  2167. * @returns the length squared
  2168. */
  2169. lengthSquared(): number;
  2170. /**
  2171. * Normalizes in place the Vector4.
  2172. * @returns the updated Vector4.
  2173. */
  2174. normalize(): Vector4;
  2175. /**
  2176. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2177. * @returns this converted to a new vector3
  2178. */
  2179. toVector3(): Vector3;
  2180. /**
  2181. * Returns a new Vector4 copied from the current one.
  2182. * @returns the new cloned vector
  2183. */
  2184. clone(): Vector4;
  2185. /**
  2186. * Updates the current Vector4 with the given one coordinates.
  2187. * @param source the source vector to copy from
  2188. * @returns the updated Vector4.
  2189. */
  2190. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2191. /**
  2192. * Updates the current Vector4 coordinates with the given floats.
  2193. * @param x float to copy from
  2194. * @param y float to copy from
  2195. * @param z float to copy from
  2196. * @param w float to copy from
  2197. * @returns the updated Vector4.
  2198. */
  2199. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2200. /**
  2201. * Updates the current Vector4 coordinates with the given floats.
  2202. * @param x float to set from
  2203. * @param y float to set from
  2204. * @param z float to set from
  2205. * @param w float to set from
  2206. * @returns the updated Vector4.
  2207. */
  2208. set(x: number, y: number, z: number, w: number): Vector4;
  2209. /**
  2210. * Copies the given float to the current Vector3 coordinates
  2211. * @param v defines the x, y, z and w coordinates of the operand
  2212. * @returns the current updated Vector3
  2213. */
  2214. setAll(v: number): Vector4;
  2215. /**
  2216. * Returns a new Vector4 set from the starting index of the given array.
  2217. * @param array the array to pull values from
  2218. * @param offset the offset into the array to start at
  2219. * @returns the new vector
  2220. */
  2221. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2222. /**
  2223. * Updates the given vector "result" from the starting index of the given array.
  2224. * @param array the array to pull values from
  2225. * @param offset the offset into the array to start at
  2226. * @param result the vector to store the result in
  2227. */
  2228. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2229. /**
  2230. * Updates the given vector "result" from the starting index of the given Float32Array.
  2231. * @param array the array to pull values from
  2232. * @param offset the offset into the array to start at
  2233. * @param result the vector to store the result in
  2234. */
  2235. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2236. /**
  2237. * Updates the given vector "result" coordinates from the given floats.
  2238. * @param x float to set from
  2239. * @param y float to set from
  2240. * @param z float to set from
  2241. * @param w float to set from
  2242. * @param result the vector to the floats in
  2243. */
  2244. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2245. /**
  2246. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2247. * @returns the new vector
  2248. */
  2249. static Zero(): Vector4;
  2250. /**
  2251. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2252. * @returns the new vector
  2253. */
  2254. static One(): Vector4;
  2255. /**
  2256. * Returns a new normalized Vector4 from the given one.
  2257. * @param vector the vector to normalize
  2258. * @returns the vector
  2259. */
  2260. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2261. /**
  2262. * Updates the given vector "result" from the normalization of the given one.
  2263. * @param vector the vector to normalize
  2264. * @param result the vector to store the result in
  2265. */
  2266. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2267. /**
  2268. * Returns a vector with the minimum values from the left and right vectors
  2269. * @param left left vector to minimize
  2270. * @param right right vector to minimize
  2271. * @returns a new vector with the minimum of the left and right vector values
  2272. */
  2273. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2274. /**
  2275. * Returns a vector with the maximum values from the left and right vectors
  2276. * @param left left vector to maximize
  2277. * @param right right vector to maximize
  2278. * @returns a new vector with the maximum of the left and right vector values
  2279. */
  2280. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2281. /**
  2282. * Returns the distance (float) between the vectors "value1" and "value2".
  2283. * @param value1 value to calulate the distance between
  2284. * @param value2 value to calulate the distance between
  2285. * @return the distance between the two vectors
  2286. */
  2287. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2288. /**
  2289. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2290. * @param value1 value to calulate the distance between
  2291. * @param value2 value to calulate the distance between
  2292. * @return the distance between the two vectors squared
  2293. */
  2294. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2295. /**
  2296. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2297. * @param value1 value to calulate the center between
  2298. * @param value2 value to calulate the center between
  2299. * @return the center between the two vectors
  2300. */
  2301. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2304. * This methods computes transformed normalized direction vectors only.
  2305. * @param vector the vector to transform
  2306. * @param transformation the transformation matrix to apply
  2307. * @returns the new vector
  2308. */
  2309. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2310. /**
  2311. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2312. * This methods computes transformed normalized direction vectors only.
  2313. * @param vector the vector to transform
  2314. * @param transformation the transformation matrix to apply
  2315. * @param result the vector to store the result in
  2316. */
  2317. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2318. /**
  2319. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2320. * This methods computes transformed normalized direction vectors only.
  2321. * @param x value to transform
  2322. * @param y value to transform
  2323. * @param z value to transform
  2324. * @param w value to transform
  2325. * @param transformation the transformation matrix to apply
  2326. * @param result the vector to store the results in
  2327. */
  2328. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2329. /**
  2330. * Creates a new Vector4 from a Vector3
  2331. * @param source defines the source data
  2332. * @param w defines the 4th component (default is 0)
  2333. * @returns a new Vector4
  2334. */
  2335. static FromVector3(source: Vector3, w?: number): Vector4;
  2336. }
  2337. /**
  2338. * Interface for the size containing width and height
  2339. */
  2340. export interface ISize {
  2341. /**
  2342. * Width
  2343. */
  2344. width: number;
  2345. /**
  2346. * Heighht
  2347. */
  2348. height: number;
  2349. }
  2350. /**
  2351. * Size containing widht and height
  2352. */
  2353. export class Size implements ISize {
  2354. /**
  2355. * Width
  2356. */
  2357. width: number;
  2358. /**
  2359. * Height
  2360. */
  2361. height: number;
  2362. /**
  2363. * Creates a Size object from the given width and height (floats).
  2364. * @param width width of the new size
  2365. * @param height height of the new size
  2366. */
  2367. constructor(width: number, height: number);
  2368. /**
  2369. * Returns a string with the Size width and height
  2370. * @returns a string with the Size width and height
  2371. */
  2372. toString(): string;
  2373. /**
  2374. * "Size"
  2375. * @returns the string "Size"
  2376. */
  2377. getClassName(): string;
  2378. /**
  2379. * Returns the Size hash code.
  2380. * @returns a hash code for a unique width and height
  2381. */
  2382. getHashCode(): number;
  2383. /**
  2384. * Updates the current size from the given one.
  2385. * @param src the given size
  2386. */
  2387. copyFrom(src: Size): void;
  2388. /**
  2389. * Updates in place the current Size from the given floats.
  2390. * @param width width of the new size
  2391. * @param height height of the new size
  2392. * @returns the updated Size.
  2393. */
  2394. copyFromFloats(width: number, height: number): Size;
  2395. /**
  2396. * Updates in place the current Size from the given floats.
  2397. * @param width width to set
  2398. * @param height height to set
  2399. * @returns the updated Size.
  2400. */
  2401. set(width: number, height: number): Size;
  2402. /**
  2403. * Multiplies the width and height by numbers
  2404. * @param w factor to multiple the width by
  2405. * @param h factor to multiple the height by
  2406. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2407. */
  2408. multiplyByFloats(w: number, h: number): Size;
  2409. /**
  2410. * Clones the size
  2411. * @returns a new Size copied from the given one.
  2412. */
  2413. clone(): Size;
  2414. /**
  2415. * True if the current Size and the given one width and height are strictly equal.
  2416. * @param other the other size to compare against
  2417. * @returns True if the current Size and the given one width and height are strictly equal.
  2418. */
  2419. equals(other: Size): boolean;
  2420. /**
  2421. * The surface of the Size : width * height (float).
  2422. */
  2423. readonly surface: number;
  2424. /**
  2425. * Create a new size of zero
  2426. * @returns a new Size set to (0.0, 0.0)
  2427. */
  2428. static Zero(): Size;
  2429. /**
  2430. * Sums the width and height of two sizes
  2431. * @param otherSize size to add to this size
  2432. * @returns a new Size set as the addition result of the current Size and the given one.
  2433. */
  2434. add(otherSize: Size): Size;
  2435. /**
  2436. * Subtracts the width and height of two
  2437. * @param otherSize size to subtract to this size
  2438. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2439. */
  2440. subtract(otherSize: Size): Size;
  2441. /**
  2442. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2443. * @param start starting size to lerp between
  2444. * @param end end size to lerp between
  2445. * @param amount amount to lerp between the start and end values
  2446. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2447. */
  2448. static Lerp(start: Size, end: Size, amount: number): Size;
  2449. }
  2450. /**
  2451. * Class used to store quaternion data
  2452. * @see https://en.wikipedia.org/wiki/Quaternion
  2453. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2454. */
  2455. export class Quaternion {
  2456. /** defines the first component (0 by default) */
  2457. x: number;
  2458. /** defines the second component (0 by default) */
  2459. y: number;
  2460. /** defines the third component (0 by default) */
  2461. z: number;
  2462. /** defines the fourth component (1.0 by default) */
  2463. w: number;
  2464. /**
  2465. * Creates a new Quaternion from the given floats
  2466. * @param x defines the first component (0 by default)
  2467. * @param y defines the second component (0 by default)
  2468. * @param z defines the third component (0 by default)
  2469. * @param w defines the fourth component (1.0 by default)
  2470. */
  2471. constructor(
  2472. /** defines the first component (0 by default) */
  2473. x?: number,
  2474. /** defines the second component (0 by default) */
  2475. y?: number,
  2476. /** defines the third component (0 by default) */
  2477. z?: number,
  2478. /** defines the fourth component (1.0 by default) */
  2479. w?: number);
  2480. /**
  2481. * Gets a string representation for the current quaternion
  2482. * @returns a string with the Quaternion coordinates
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name of the quaternion
  2487. * @returns the string "Quaternion"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Gets a hash code for this quaternion
  2492. * @returns the quaternion hash code
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Copy the quaternion to an array
  2497. * @returns a new array populated with 4 elements from the quaternion coordinates
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Check if two quaternions are equals
  2502. * @param otherQuaternion defines the second operand
  2503. * @return true if the current quaternion and the given one coordinates are strictly equals
  2504. */
  2505. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2506. /**
  2507. * Clone the current quaternion
  2508. * @returns a new quaternion copied from the current one
  2509. */
  2510. clone(): Quaternion;
  2511. /**
  2512. * Copy a quaternion to the current one
  2513. * @param other defines the other quaternion
  2514. * @returns the updated current quaternion
  2515. */
  2516. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2517. /**
  2518. * Updates the current quaternion with the given float coordinates
  2519. * @param x defines the x coordinate
  2520. * @param y defines the y coordinate
  2521. * @param z defines the z coordinate
  2522. * @param w defines the w coordinate
  2523. * @returns the updated current quaternion
  2524. */
  2525. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2526. /**
  2527. * Updates the current quaternion from the given float coordinates
  2528. * @param x defines the x coordinate
  2529. * @param y defines the y coordinate
  2530. * @param z defines the z coordinate
  2531. * @param w defines the w coordinate
  2532. * @returns the updated current quaternion
  2533. */
  2534. set(x: number, y: number, z: number, w: number): Quaternion;
  2535. /**
  2536. * Adds two quaternions
  2537. * @param other defines the second operand
  2538. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2539. */
  2540. add(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Add a quaternion to the current one
  2543. * @param other defines the quaternion to add
  2544. * @returns the current quaternion
  2545. */
  2546. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2547. /**
  2548. * Subtract two quaternions
  2549. * @param other defines the second operand
  2550. * @returns a new quaternion as the subtraction result of the given one from the current one
  2551. */
  2552. subtract(other: Quaternion): Quaternion;
  2553. /**
  2554. * Multiplies the current quaternion by a scale factor
  2555. * @param value defines the scale factor
  2556. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2557. */
  2558. scale(value: number): Quaternion;
  2559. /**
  2560. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2561. * @param scale defines the scale factor
  2562. * @param result defines the Quaternion object where to store the result
  2563. * @returns the unmodified current quaternion
  2564. */
  2565. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2566. /**
  2567. * Multiplies in place the current quaternion by a scale factor
  2568. * @param value defines the scale factor
  2569. * @returns the current modified quaternion
  2570. */
  2571. scaleInPlace(value: number): Quaternion;
  2572. /**
  2573. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2574. * @param scale defines the scale factor
  2575. * @param result defines the Quaternion object where to store the result
  2576. * @returns the unmodified current quaternion
  2577. */
  2578. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2579. /**
  2580. * Multiplies two quaternions
  2581. * @param q1 defines the second operand
  2582. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2583. */
  2584. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2585. /**
  2586. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2587. * @param q1 defines the second operand
  2588. * @param result defines the target quaternion
  2589. * @returns the current quaternion
  2590. */
  2591. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2592. /**
  2593. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2594. * @param q1 defines the second operand
  2595. * @returns the currentupdated quaternion
  2596. */
  2597. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2598. /**
  2599. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2600. * @param ref defines the target quaternion
  2601. * @returns the current quaternion
  2602. */
  2603. conjugateToRef(ref: Quaternion): Quaternion;
  2604. /**
  2605. * Conjugates in place (1-q) the current quaternion
  2606. * @returns the current updated quaternion
  2607. */
  2608. conjugateInPlace(): Quaternion;
  2609. /**
  2610. * Conjugates in place (1-q) the current quaternion
  2611. * @returns a new quaternion
  2612. */
  2613. conjugate(): Quaternion;
  2614. /**
  2615. * Gets length of current quaternion
  2616. * @returns the quaternion length (float)
  2617. */
  2618. length(): number;
  2619. /**
  2620. * Normalize in place the current quaternion
  2621. * @returns the current updated quaternion
  2622. */
  2623. normalize(): Quaternion;
  2624. /**
  2625. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2626. * @param order is a reserved parameter and is ignore for now
  2627. * @returns a new Vector3 containing the Euler angles
  2628. */
  2629. toEulerAngles(order?: string): Vector3;
  2630. /**
  2631. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2632. * @param result defines the vector which will be filled with the Euler angles
  2633. * @param order is a reserved parameter and is ignore for now
  2634. * @returns the current unchanged quaternion
  2635. */
  2636. toEulerAnglesToRef(result: Vector3): Quaternion;
  2637. /**
  2638. * Updates the given rotation matrix with the current quaternion values
  2639. * @param result defines the target matrix
  2640. * @returns the current unchanged quaternion
  2641. */
  2642. toRotationMatrix(result: Matrix): Quaternion;
  2643. /**
  2644. * Updates the current quaternion from the given rotation matrix values
  2645. * @param matrix defines the source matrix
  2646. * @returns the current updated quaternion
  2647. */
  2648. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2649. /**
  2650. * Creates a new quaternion from a rotation matrix
  2651. * @param matrix defines the source matrix
  2652. * @returns a new quaternion created from the given rotation matrix values
  2653. */
  2654. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2655. /**
  2656. * Updates the given quaternion with the given rotation matrix values
  2657. * @param matrix defines the source matrix
  2658. * @param result defines the target quaternion
  2659. */
  2660. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2661. /**
  2662. * Returns the dot product (float) between the quaternions "left" and "right"
  2663. * @param left defines the left operand
  2664. * @param right defines the right operand
  2665. * @returns the dot product
  2666. */
  2667. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2668. /**
  2669. * Checks if the two quaternions are close to each other
  2670. * @param quat0 defines the first quaternion to check
  2671. * @param quat1 defines the second quaternion to check
  2672. * @returns true if the two quaternions are close to each other
  2673. */
  2674. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2675. /**
  2676. * Creates an empty quaternion
  2677. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2678. */
  2679. static Zero(): Quaternion;
  2680. /**
  2681. * Inverse a given quaternion
  2682. * @param q defines the source quaternion
  2683. * @returns a new quaternion as the inverted current quaternion
  2684. */
  2685. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2686. /**
  2687. * Inverse a given quaternion
  2688. * @param q defines the source quaternion
  2689. * @param result the quaternion the result will be stored in
  2690. * @returns the result quaternion
  2691. */
  2692. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2693. /**
  2694. * Creates an identity quaternion
  2695. * @returns the identity quaternion
  2696. */
  2697. static Identity(): Quaternion;
  2698. /**
  2699. * Gets a boolean indicating if the given quaternion is identity
  2700. * @param quaternion defines the quaternion to check
  2701. * @returns true if the quaternion is identity
  2702. */
  2703. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2704. /**
  2705. * Creates a quaternion from a rotation around an axis
  2706. * @param axis defines the axis to use
  2707. * @param angle defines the angle to use
  2708. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2709. */
  2710. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2711. /**
  2712. * Creates a rotation around an axis and stores it into the given quaternion
  2713. * @param axis defines the axis to use
  2714. * @param angle defines the angle to use
  2715. * @param result defines the target quaternion
  2716. * @returns the target quaternion
  2717. */
  2718. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2719. /**
  2720. * Creates a new quaternion from data stored into an array
  2721. * @param array defines the data source
  2722. * @param offset defines the offset in the source array where the data starts
  2723. * @returns a new quaternion
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2726. /**
  2727. * Create a quaternion from Euler rotation angles
  2728. * @param x Pitch
  2729. * @param y Yaw
  2730. * @param z Roll
  2731. * @returns the new Quaternion
  2732. */
  2733. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2734. /**
  2735. * Updates a quaternion from Euler rotation angles
  2736. * @param x Pitch
  2737. * @param y Yaw
  2738. * @param z Roll
  2739. * @param result the quaternion to store the result
  2740. * @returns the updated quaternion
  2741. */
  2742. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Create a quaternion from Euler rotation vector
  2745. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2746. * @returns the new Quaternion
  2747. */
  2748. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2749. /**
  2750. * Updates a quaternion from Euler rotation vector
  2751. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2752. * @param result the quaternion to store the result
  2753. * @returns the updated quaternion
  2754. */
  2755. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2756. /**
  2757. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2758. * @param yaw defines the rotation around Y axis
  2759. * @param pitch defines the rotation around X axis
  2760. * @param roll defines the rotation around Z axis
  2761. * @returns the new quaternion
  2762. */
  2763. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2764. /**
  2765. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2766. * @param yaw defines the rotation around Y axis
  2767. * @param pitch defines the rotation around X axis
  2768. * @param roll defines the rotation around Z axis
  2769. * @param result defines the target quaternion
  2770. */
  2771. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2772. /**
  2773. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2774. * @param alpha defines the rotation around first axis
  2775. * @param beta defines the rotation around second axis
  2776. * @param gamma defines the rotation around third axis
  2777. * @returns the new quaternion
  2778. */
  2779. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2782. * @param alpha defines the rotation around first axis
  2783. * @param beta defines the rotation around second axis
  2784. * @param gamma defines the rotation around third axis
  2785. * @param result defines the target quaternion
  2786. */
  2787. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2788. /**
  2789. * 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)
  2790. * @param axis1 defines the first axis
  2791. * @param axis2 defines the second axis
  2792. * @param axis3 defines the third axis
  2793. * @returns the new quaternion
  2794. */
  2795. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2796. /**
  2797. * 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
  2798. * @param axis1 defines the first axis
  2799. * @param axis2 defines the second axis
  2800. * @param axis3 defines the third axis
  2801. * @param ref defines the target quaternion
  2802. */
  2803. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2804. /**
  2805. * Interpolates between two quaternions
  2806. * @param left defines first quaternion
  2807. * @param right defines second quaternion
  2808. * @param amount defines the gradient to use
  2809. * @returns the new interpolated quaternion
  2810. */
  2811. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2812. /**
  2813. * Interpolates between two quaternions and stores it into a target quaternion
  2814. * @param left defines first quaternion
  2815. * @param right defines second quaternion
  2816. * @param amount defines the gradient to use
  2817. * @param result defines the target quaternion
  2818. */
  2819. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2820. /**
  2821. * Interpolate between two quaternions using Hermite interpolation
  2822. * @param value1 defines first quaternion
  2823. * @param tangent1 defines the incoming tangent
  2824. * @param value2 defines second quaternion
  2825. * @param tangent2 defines the outgoing tangent
  2826. * @param amount defines the target quaternion
  2827. * @returns the new interpolated quaternion
  2828. */
  2829. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2830. }
  2831. /**
  2832. * Class used to store matrix data (4x4)
  2833. */
  2834. export class Matrix {
  2835. private static _updateFlagSeed;
  2836. private static _identityReadOnly;
  2837. private _isIdentity;
  2838. private _isIdentityDirty;
  2839. private _isIdentity3x2;
  2840. private _isIdentity3x2Dirty;
  2841. /**
  2842. * Gets the update flag of the matrix which is an unique number for the matrix.
  2843. * It will be incremented every time the matrix data change.
  2844. * You can use it to speed the comparison between two versions of the same matrix.
  2845. */
  2846. updateFlag: number;
  2847. private readonly _m;
  2848. /**
  2849. * Gets the internal data of the matrix
  2850. */
  2851. readonly m: DeepImmutable<Float32Array>;
  2852. /** @hidden */
  2853. _markAsUpdated(): void;
  2854. /** @hidden */
  2855. private _updateIdentityStatus;
  2856. /**
  2857. * Creates an empty matrix (filled with zeros)
  2858. */
  2859. constructor();
  2860. /**
  2861. * Check if the current matrix is identity
  2862. * @returns true is the matrix is the identity matrix
  2863. */
  2864. isIdentity(): boolean;
  2865. /**
  2866. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2867. * @returns true is the matrix is the identity matrix
  2868. */
  2869. isIdentityAs3x2(): boolean;
  2870. /**
  2871. * Gets the determinant of the matrix
  2872. * @returns the matrix determinant
  2873. */
  2874. determinant(): number;
  2875. /**
  2876. * Returns the matrix as a Float32Array
  2877. * @returns the matrix underlying array
  2878. */
  2879. toArray(): DeepImmutable<Float32Array>;
  2880. /**
  2881. * Returns the matrix as a Float32Array
  2882. * @returns the matrix underlying array.
  2883. */
  2884. asArray(): DeepImmutable<Float32Array>;
  2885. /**
  2886. * Inverts the current matrix in place
  2887. * @returns the current inverted matrix
  2888. */
  2889. invert(): Matrix;
  2890. /**
  2891. * Sets all the matrix elements to zero
  2892. * @returns the current matrix
  2893. */
  2894. reset(): Matrix;
  2895. /**
  2896. * Adds the current matrix with a second one
  2897. * @param other defines the matrix to add
  2898. * @returns a new matrix as the addition of the current matrix and the given one
  2899. */
  2900. add(other: DeepImmutable<Matrix>): Matrix;
  2901. /**
  2902. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2903. * @param other defines the matrix to add
  2904. * @param result defines the target matrix
  2905. * @returns the current matrix
  2906. */
  2907. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2908. /**
  2909. * Adds in place the given matrix to the current matrix
  2910. * @param other defines the second operand
  2911. * @returns the current updated matrix
  2912. */
  2913. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2914. /**
  2915. * Sets the given matrix to the current inverted Matrix
  2916. * @param other defines the target matrix
  2917. * @returns the unmodified current matrix
  2918. */
  2919. invertToRef(other: Matrix): Matrix;
  2920. /**
  2921. * add a value at the specified position in the current Matrix
  2922. * @param index the index of the value within the matrix. between 0 and 15.
  2923. * @param value the value to be added
  2924. * @returns the current updated matrix
  2925. */
  2926. addAtIndex(index: number, value: number): Matrix;
  2927. /**
  2928. * mutiply the specified position in the current Matrix by a value
  2929. * @param index the index of the value within the matrix. between 0 and 15.
  2930. * @param value the value to be added
  2931. * @returns the current updated matrix
  2932. */
  2933. multiplyAtIndex(index: number, value: number): Matrix;
  2934. /**
  2935. * Inserts the translation vector (using 3 floats) in the current matrix
  2936. * @param x defines the 1st component of the translation
  2937. * @param y defines the 2nd component of the translation
  2938. * @param z defines the 3rd component of the translation
  2939. * @returns the current updated matrix
  2940. */
  2941. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2942. /**
  2943. * Inserts the translation vector in the current matrix
  2944. * @param vector3 defines the translation to insert
  2945. * @returns the current updated matrix
  2946. */
  2947. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2948. /**
  2949. * Gets the translation value of the current matrix
  2950. * @returns a new Vector3 as the extracted translation from the matrix
  2951. */
  2952. getTranslation(): Vector3;
  2953. /**
  2954. * Fill a Vector3 with the extracted translation from the matrix
  2955. * @param result defines the Vector3 where to store the translation
  2956. * @returns the current matrix
  2957. */
  2958. getTranslationToRef(result: Vector3): Matrix;
  2959. /**
  2960. * Remove rotation and scaling part from the matrix
  2961. * @returns the updated matrix
  2962. */
  2963. removeRotationAndScaling(): Matrix;
  2964. /**
  2965. * Multiply two matrices
  2966. * @param other defines the second operand
  2967. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2968. */
  2969. multiply(other: DeepImmutable<Matrix>): Matrix;
  2970. /**
  2971. * Copy the current matrix from the given one
  2972. * @param other defines the source matrix
  2973. * @returns the current updated matrix
  2974. */
  2975. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2976. /**
  2977. * Populates the given array from the starting index with the current matrix values
  2978. * @param array defines the target array
  2979. * @param offset defines the offset in the target array where to start storing values
  2980. * @returns the current matrix
  2981. */
  2982. copyToArray(array: Float32Array, offset?: number): Matrix;
  2983. /**
  2984. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2985. * @param other defines the second operand
  2986. * @param result defines the matrix where to store the multiplication
  2987. * @returns the current matrix
  2988. */
  2989. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2990. /**
  2991. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the array where to store the multiplication
  2994. * @param offset defines the offset in the target array where to start storing values
  2995. * @returns the current matrix
  2996. */
  2997. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2998. /**
  2999. * Check equality between this matrix and a second one
  3000. * @param value defines the second matrix to compare
  3001. * @returns true is the current matrix and the given one values are strictly equal
  3002. */
  3003. equals(value: DeepImmutable<Matrix>): boolean;
  3004. /**
  3005. * Clone the current matrix
  3006. * @returns a new matrix from the current matrix
  3007. */
  3008. clone(): Matrix;
  3009. /**
  3010. * Returns the name of the current matrix class
  3011. * @returns the string "Matrix"
  3012. */
  3013. getClassName(): string;
  3014. /**
  3015. * Gets the hash code of the current matrix
  3016. * @returns the hash code
  3017. */
  3018. getHashCode(): number;
  3019. /**
  3020. * Decomposes the current Matrix into a translation, rotation and scaling components
  3021. * @param scale defines the scale vector3 given as a reference to update
  3022. * @param rotation defines the rotation quaternion given as a reference to update
  3023. * @param translation defines the translation vector3 given as a reference to update
  3024. * @returns true if operation was successful
  3025. */
  3026. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3027. /**
  3028. * Gets specific row of the matrix
  3029. * @param index defines the number of the row to get
  3030. * @returns the index-th row of the current matrix as a new Vector4
  3031. */
  3032. getRow(index: number): Nullable<Vector4>;
  3033. /**
  3034. * Sets the index-th row of the current matrix to the vector4 values
  3035. * @param index defines the number of the row to set
  3036. * @param row defines the target vector4
  3037. * @returns the updated current matrix
  3038. */
  3039. setRow(index: number, row: Vector4): Matrix;
  3040. /**
  3041. * Compute the transpose of the matrix
  3042. * @returns the new transposed matrix
  3043. */
  3044. transpose(): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix and store it in a given matrix
  3047. * @param result defines the target matrix
  3048. * @returns the current matrix
  3049. */
  3050. transposeToRef(result: Matrix): Matrix;
  3051. /**
  3052. * Sets the index-th row of the current matrix with the given 4 x float values
  3053. * @param index defines the row index
  3054. * @param x defines the x component to set
  3055. * @param y defines the y component to set
  3056. * @param z defines the z component to set
  3057. * @param w defines the w component to set
  3058. * @returns the updated current matrix
  3059. */
  3060. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3061. /**
  3062. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3063. * @param scale defines the scale factor
  3064. * @returns a new matrix
  3065. */
  3066. scale(scale: number): Matrix;
  3067. /**
  3068. * Scale the current matrix values by a factor to a given result matrix
  3069. * @param scale defines the scale factor
  3070. * @param result defines the matrix to store the result
  3071. * @returns the current matrix
  3072. */
  3073. scaleToRef(scale: number, result: Matrix): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor and add the result to a given matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the Matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3083. * @param ref matrix to store the result
  3084. */
  3085. toNormalMatrix(ref: Matrix): void;
  3086. /**
  3087. * Gets only rotation part of the current matrix
  3088. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3089. */
  3090. getRotationMatrix(): Matrix;
  3091. /**
  3092. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3093. * @param result defines the target matrix to store data to
  3094. * @returns the current matrix
  3095. */
  3096. getRotationMatrixToRef(result: Matrix): Matrix;
  3097. /**
  3098. * Toggles model matrix from being right handed to left handed in place and vice versa
  3099. */
  3100. toggleModelMatrixHandInPlace(): void;
  3101. /**
  3102. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3103. */
  3104. toggleProjectionMatrixHandInPlace(): void;
  3105. /**
  3106. * Creates a matrix from an array
  3107. * @param array defines the source array
  3108. * @param offset defines an offset in the source array
  3109. * @returns a new Matrix set from the starting index of the given array
  3110. */
  3111. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3112. /**
  3113. * Copy the content of an array into a given matrix
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @param result defines the target matrix
  3117. */
  3118. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3119. /**
  3120. * Stores an array into a matrix after having multiplied each component by a given factor
  3121. * @param array defines the source array
  3122. * @param offset defines the offset in the source array
  3123. * @param scale defines the scaling factor
  3124. * @param result defines the target matrix
  3125. */
  3126. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3127. /**
  3128. * Gets an identity matrix that must not be updated
  3129. */
  3130. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3131. /**
  3132. * Stores a list of values (16) inside a given matrix
  3133. * @param initialM11 defines 1st value of 1st row
  3134. * @param initialM12 defines 2nd value of 1st row
  3135. * @param initialM13 defines 3rd value of 1st row
  3136. * @param initialM14 defines 4th value of 1st row
  3137. * @param initialM21 defines 1st value of 2nd row
  3138. * @param initialM22 defines 2nd value of 2nd row
  3139. * @param initialM23 defines 3rd value of 2nd row
  3140. * @param initialM24 defines 4th value of 2nd row
  3141. * @param initialM31 defines 1st value of 3rd row
  3142. * @param initialM32 defines 2nd value of 3rd row
  3143. * @param initialM33 defines 3rd value of 3rd row
  3144. * @param initialM34 defines 4th value of 3rd row
  3145. * @param initialM41 defines 1st value of 4th row
  3146. * @param initialM42 defines 2nd value of 4th row
  3147. * @param initialM43 defines 3rd value of 4th row
  3148. * @param initialM44 defines 4th value of 4th row
  3149. * @param result defines the target matrix
  3150. */
  3151. 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;
  3152. /**
  3153. * Creates new matrix from a list of values (16)
  3154. * @param initialM11 defines 1st value of 1st row
  3155. * @param initialM12 defines 2nd value of 1st row
  3156. * @param initialM13 defines 3rd value of 1st row
  3157. * @param initialM14 defines 4th value of 1st row
  3158. * @param initialM21 defines 1st value of 2nd row
  3159. * @param initialM22 defines 2nd value of 2nd row
  3160. * @param initialM23 defines 3rd value of 2nd row
  3161. * @param initialM24 defines 4th value of 2nd row
  3162. * @param initialM31 defines 1st value of 3rd row
  3163. * @param initialM32 defines 2nd value of 3rd row
  3164. * @param initialM33 defines 3rd value of 3rd row
  3165. * @param initialM34 defines 4th value of 3rd row
  3166. * @param initialM41 defines 1st value of 4th row
  3167. * @param initialM42 defines 2nd value of 4th row
  3168. * @param initialM43 defines 3rd value of 4th row
  3169. * @param initialM44 defines 4th value of 4th row
  3170. * @returns the new matrix
  3171. */
  3172. 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;
  3173. /**
  3174. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3175. * @param scale defines the scale vector3
  3176. * @param rotation defines the rotation quaternion
  3177. * @param translation defines the translation vector3
  3178. * @returns a new matrix
  3179. */
  3180. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3181. /**
  3182. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3183. * @param scale defines the scale vector3
  3184. * @param rotation defines the rotation quaternion
  3185. * @param translation defines the translation vector3
  3186. * @param result defines the target matrix
  3187. */
  3188. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3189. /**
  3190. * Creates a new identity matrix
  3191. * @returns a new identity matrix
  3192. */
  3193. static Identity(): Matrix;
  3194. /**
  3195. * Creates a new identity matrix and stores the result in a given matrix
  3196. * @param result defines the target matrix
  3197. */
  3198. static IdentityToRef(result: Matrix): void;
  3199. /**
  3200. * Creates a new zero matrix
  3201. * @returns a new zero matrix
  3202. */
  3203. static Zero(): Matrix;
  3204. /**
  3205. * Creates a new rotation matrix for "angle" radians around the X axis
  3206. * @param angle defines the angle (in radians) to use
  3207. * @return the new matrix
  3208. */
  3209. static RotationX(angle: number): Matrix;
  3210. /**
  3211. * Creates a new matrix as the invert of a given matrix
  3212. * @param source defines the source matrix
  3213. * @returns the new matrix
  3214. */
  3215. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3216. /**
  3217. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3218. * @param angle defines the angle (in radians) to use
  3219. * @param result defines the target matrix
  3220. */
  3221. static RotationXToRef(angle: number, result: Matrix): void;
  3222. /**
  3223. * Creates a new rotation matrix for "angle" radians around the Y axis
  3224. * @param angle defines the angle (in radians) to use
  3225. * @return the new matrix
  3226. */
  3227. static RotationY(angle: number): Matrix;
  3228. /**
  3229. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3230. * @param angle defines the angle (in radians) to use
  3231. * @param result defines the target matrix
  3232. */
  3233. static RotationYToRef(angle: number, result: Matrix): void;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the Z axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationZ(angle: number): Matrix;
  3240. /**
  3241. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3242. * @param angle defines the angle (in radians) to use
  3243. * @param result defines the target matrix
  3244. */
  3245. static RotationZToRef(angle: number, result: Matrix): void;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the given axis
  3248. * @param axis defines the axis to use
  3249. * @param angle defines the angle (in radians) to use
  3250. * @return the new matrix
  3251. */
  3252. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @param result defines the target matrix
  3258. */
  3259. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3260. /**
  3261. * Creates a rotation matrix
  3262. * @param yaw defines the yaw angle in radians (Y axis)
  3263. * @param pitch defines the pitch angle in radians (X axis)
  3264. * @param roll defines the roll angle in radians (X axis)
  3265. * @returns the new rotation matrix
  3266. */
  3267. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3268. /**
  3269. * Creates a rotation matrix and stores it in a given matrix
  3270. * @param yaw defines the yaw angle in radians (Y axis)
  3271. * @param pitch defines the pitch angle in radians (X axis)
  3272. * @param roll defines the roll angle in radians (X axis)
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3276. /**
  3277. * Creates a scaling matrix
  3278. * @param x defines the scale factor on X axis
  3279. * @param y defines the scale factor on Y axis
  3280. * @param z defines the scale factor on Z axis
  3281. * @returns the new matrix
  3282. */
  3283. static Scaling(x: number, y: number, z: number): Matrix;
  3284. /**
  3285. * Creates a scaling matrix and stores it in a given matrix
  3286. * @param x defines the scale factor on X axis
  3287. * @param y defines the scale factor on Y axis
  3288. * @param z defines the scale factor on Z axis
  3289. * @param result defines the target matrix
  3290. */
  3291. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3292. /**
  3293. * Creates a translation matrix
  3294. * @param x defines the translation on X axis
  3295. * @param y defines the translation on Y axis
  3296. * @param z defines the translationon Z axis
  3297. * @returns the new matrix
  3298. */
  3299. static Translation(x: number, y: number, z: number): Matrix;
  3300. /**
  3301. * Creates a translation matrix and stores it in a given matrix
  3302. * @param x defines the translation on X axis
  3303. * @param y defines the translation on Y axis
  3304. * @param z defines the translationon Z axis
  3305. * @param result defines the target matrix
  3306. */
  3307. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3308. /**
  3309. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3310. * @param startValue defines the start value
  3311. * @param endValue defines the end value
  3312. * @param gradient defines the gradient factor
  3313. * @returns the new matrix
  3314. */
  3315. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3316. /**
  3317. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3318. * @param startValue defines the start value
  3319. * @param endValue defines the end value
  3320. * @param gradient defines the gradient factor
  3321. * @param result defines the Matrix object where to store data
  3322. */
  3323. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3324. /**
  3325. * Builds a new matrix whose values are computed by:
  3326. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3327. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3328. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3329. * @param startValue defines the first matrix
  3330. * @param endValue defines the second matrix
  3331. * @param gradient defines the gradient between the two matrices
  3332. * @returns the new matrix
  3333. */
  3334. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3335. /**
  3336. * Update a matrix to values which are computed by:
  3337. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3338. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3339. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3340. * @param startValue defines the first matrix
  3341. * @param endValue defines the second matrix
  3342. * @param gradient defines the gradient between the two matrices
  3343. * @param result defines the target matrix
  3344. */
  3345. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3346. /**
  3347. * 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"
  3348. * This function works in left handed mode
  3349. * @param eye defines the final position of the entity
  3350. * @param target defines where the entity should look at
  3351. * @param up defines the up vector for the entity
  3352. * @returns the new matrix
  3353. */
  3354. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3355. /**
  3356. * 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".
  3357. * This function works in left handed mode
  3358. * @param eye defines the final position of the entity
  3359. * @param target defines where the entity should look at
  3360. * @param up defines the up vector for the entity
  3361. * @param result defines the target matrix
  3362. */
  3363. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3364. /**
  3365. * 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"
  3366. * This function works in right handed mode
  3367. * @param eye defines the final position of the entity
  3368. * @param target defines where the entity should look at
  3369. * @param up defines the up vector for the entity
  3370. * @returns the new matrix
  3371. */
  3372. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3373. /**
  3374. * 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".
  3375. * This function works in right handed mode
  3376. * @param eye defines the final position of the entity
  3377. * @param target defines where the entity should look at
  3378. * @param up defines the up vector for the entity
  3379. * @param result defines the target matrix
  3380. */
  3381. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3382. /**
  3383. * Create a left-handed orthographic projection matrix
  3384. * @param width defines the viewport width
  3385. * @param height defines the viewport height
  3386. * @param znear defines the near clip plane
  3387. * @param zfar defines the far clip plane
  3388. * @returns a new matrix as a left-handed orthographic projection matrix
  3389. */
  3390. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3391. /**
  3392. * Store a left-handed orthographic projection to a given matrix
  3393. * @param width defines the viewport width
  3394. * @param height defines the viewport height
  3395. * @param znear defines the near clip plane
  3396. * @param zfar defines the far clip plane
  3397. * @param result defines the target matrix
  3398. */
  3399. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3400. /**
  3401. * Create a left-handed orthographic projection matrix
  3402. * @param left defines the viewport left coordinate
  3403. * @param right defines the viewport right coordinate
  3404. * @param bottom defines the viewport bottom coordinate
  3405. * @param top defines the viewport top coordinate
  3406. * @param znear defines the near clip plane
  3407. * @param zfar defines the far clip plane
  3408. * @returns a new matrix as a left-handed orthographic projection matrix
  3409. */
  3410. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3411. /**
  3412. * Stores a left-handed orthographic projection into a given matrix
  3413. * @param left defines the viewport left coordinate
  3414. * @param right defines the viewport right coordinate
  3415. * @param bottom defines the viewport bottom coordinate
  3416. * @param top defines the viewport top coordinate
  3417. * @param znear defines the near clip plane
  3418. * @param zfar defines the far clip plane
  3419. * @param result defines the target matrix
  3420. */
  3421. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3422. /**
  3423. * Creates a right-handed orthographic projection matrix
  3424. * @param left defines the viewport left coordinate
  3425. * @param right defines the viewport right coordinate
  3426. * @param bottom defines the viewport bottom coordinate
  3427. * @param top defines the viewport top coordinate
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @returns a new matrix as a right-handed orthographic projection matrix
  3431. */
  3432. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3433. /**
  3434. * Stores a right-handed orthographic projection into a given matrix
  3435. * @param left defines the viewport left coordinate
  3436. * @param right defines the viewport right coordinate
  3437. * @param bottom defines the viewport bottom coordinate
  3438. * @param top defines the viewport top coordinate
  3439. * @param znear defines the near clip plane
  3440. * @param zfar defines the far clip plane
  3441. * @param result defines the target matrix
  3442. */
  3443. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3444. /**
  3445. * Creates a left-handed perspective projection matrix
  3446. * @param width defines the viewport width
  3447. * @param height defines the viewport height
  3448. * @param znear defines the near clip plane
  3449. * @param zfar defines the far clip plane
  3450. * @returns a new matrix as a left-handed perspective projection matrix
  3451. */
  3452. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3453. /**
  3454. * Creates a left-handed perspective projection matrix
  3455. * @param fov defines the horizontal field of view
  3456. * @param aspect defines the aspect ratio
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @returns a new matrix as a left-handed perspective projection matrix
  3460. */
  3461. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3462. /**
  3463. * Stores a left-handed perspective projection into a given matrix
  3464. * @param fov defines the horizontal field of view
  3465. * @param aspect defines the aspect ratio
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @param result defines the target matrix
  3469. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3470. */
  3471. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3472. /**
  3473. * Creates a right-handed perspective projection matrix
  3474. * @param fov defines the horizontal field of view
  3475. * @param aspect defines the aspect ratio
  3476. * @param znear defines the near clip plane
  3477. * @param zfar defines the far clip plane
  3478. * @returns a new matrix as a right-handed perspective projection matrix
  3479. */
  3480. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3481. /**
  3482. * Stores a right-handed perspective projection into a given matrix
  3483. * @param fov defines the horizontal field of view
  3484. * @param aspect defines the aspect ratio
  3485. * @param znear defines the near clip plane
  3486. * @param zfar defines the far clip plane
  3487. * @param result defines the target matrix
  3488. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3489. */
  3490. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3491. /**
  3492. * Stores a perspective projection for WebVR info a given matrix
  3493. * @param fov defines the field of view
  3494. * @param znear defines the near clip plane
  3495. * @param zfar defines the far clip plane
  3496. * @param result defines the target matrix
  3497. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3498. */
  3499. static PerspectiveFovWebVRToRef(fov: {
  3500. upDegrees: number;
  3501. downDegrees: number;
  3502. leftDegrees: number;
  3503. rightDegrees: number;
  3504. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3505. /**
  3506. * Computes a complete transformation matrix
  3507. * @param viewport defines the viewport to use
  3508. * @param world defines the world matrix
  3509. * @param view defines the view matrix
  3510. * @param projection defines the projection matrix
  3511. * @param zmin defines the near clip plane
  3512. * @param zmax defines the far clip plane
  3513. * @returns the transformation matrix
  3514. */
  3515. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3516. /**
  3517. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3518. * @param matrix defines the matrix to use
  3519. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3520. */
  3521. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3522. /**
  3523. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3524. * @param matrix defines the matrix to use
  3525. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3526. */
  3527. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3528. /**
  3529. * Compute the transpose of a given matrix
  3530. * @param matrix defines the matrix to transpose
  3531. * @returns the new matrix
  3532. */
  3533. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3534. /**
  3535. * Compute the transpose of a matrix and store it in a target matrix
  3536. * @param matrix defines the matrix to transpose
  3537. * @param result defines the target matrix
  3538. */
  3539. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3540. /**
  3541. * Computes a reflection matrix from a plane
  3542. * @param plane defines the reflection plane
  3543. * @returns a new matrix
  3544. */
  3545. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3546. /**
  3547. * Computes a reflection matrix from a plane
  3548. * @param plane defines the reflection plane
  3549. * @param result defines the target matrix
  3550. */
  3551. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3552. /**
  3553. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3554. * @param xaxis defines the value of the 1st axis
  3555. * @param yaxis defines the value of the 2nd axis
  3556. * @param zaxis defines the value of the 3rd axis
  3557. * @param result defines the target matrix
  3558. */
  3559. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3560. /**
  3561. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3562. * @param quat defines the quaternion to use
  3563. * @param result defines the target matrix
  3564. */
  3565. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3566. }
  3567. /**
  3568. * Represens a plane by the equation ax + by + cz + d = 0
  3569. */
  3570. export class Plane {
  3571. /**
  3572. * Normal of the plane (a,b,c)
  3573. */
  3574. normal: Vector3;
  3575. /**
  3576. * d component of the plane
  3577. */
  3578. d: number;
  3579. /**
  3580. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3581. * @param a a component of the plane
  3582. * @param b b component of the plane
  3583. * @param c c component of the plane
  3584. * @param d d component of the plane
  3585. */
  3586. constructor(a: number, b: number, c: number, d: number);
  3587. /**
  3588. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3589. */
  3590. asArray(): number[];
  3591. /**
  3592. * @returns a new plane copied from the current Plane.
  3593. */
  3594. clone(): Plane;
  3595. /**
  3596. * @returns the string "Plane".
  3597. */
  3598. getClassName(): string;
  3599. /**
  3600. * @returns the Plane hash code.
  3601. */
  3602. getHashCode(): number;
  3603. /**
  3604. * Normalize the current Plane in place.
  3605. * @returns the updated Plane.
  3606. */
  3607. normalize(): Plane;
  3608. /**
  3609. * Applies a transformation the plane and returns the result
  3610. * @param transformation the transformation matrix to be applied to the plane
  3611. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3612. */
  3613. transform(transformation: DeepImmutable<Matrix>): Plane;
  3614. /**
  3615. * Calcualtte the dot product between the point and the plane normal
  3616. * @param point point to calculate the dot product with
  3617. * @returns the dot product (float) of the point coordinates and the plane normal.
  3618. */
  3619. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3620. /**
  3621. * Updates the current Plane from the plane defined by the three given points.
  3622. * @param point1 one of the points used to contruct the plane
  3623. * @param point2 one of the points used to contruct the plane
  3624. * @param point3 one of the points used to contruct the plane
  3625. * @returns the updated Plane.
  3626. */
  3627. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3628. /**
  3629. * Checks if the plane is facing a given direction
  3630. * @param direction the direction to check if the plane is facing
  3631. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3632. * @returns True is the vector "direction" is the same side than the plane normal.
  3633. */
  3634. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3635. /**
  3636. * Calculates the distance to a point
  3637. * @param point point to calculate distance to
  3638. * @returns the signed distance (float) from the given point to the Plane.
  3639. */
  3640. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3641. /**
  3642. * Creates a plane from an array
  3643. * @param array the array to create a plane from
  3644. * @returns a new Plane from the given array.
  3645. */
  3646. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3647. /**
  3648. * Creates a plane from three points
  3649. * @param point1 point used to create the plane
  3650. * @param point2 point used to create the plane
  3651. * @param point3 point used to create the plane
  3652. * @returns a new Plane defined by the three given points.
  3653. */
  3654. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3655. /**
  3656. * Creates a plane from an origin point and a normal
  3657. * @param origin origin of the plane to be constructed
  3658. * @param normal normal of the plane to be constructed
  3659. * @returns a new Plane the normal vector to this plane at the given origin point.
  3660. * Note : the vector "normal" is updated because normalized.
  3661. */
  3662. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3663. /**
  3664. * Calculates the distance from a plane and a point
  3665. * @param origin origin of the plane to be constructed
  3666. * @param normal normal of the plane to be constructed
  3667. * @param point point to calculate distance to
  3668. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3669. */
  3670. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3671. }
  3672. /**
  3673. * Class used to represent a viewport on screen
  3674. */
  3675. export class Viewport {
  3676. /** viewport left coordinate */
  3677. x: number;
  3678. /** viewport top coordinate */
  3679. y: number;
  3680. /**viewport width */
  3681. width: number;
  3682. /** viewport height */
  3683. height: number;
  3684. /**
  3685. * Creates a Viewport object located at (x, y) and sized (width, height)
  3686. * @param x defines viewport left coordinate
  3687. * @param y defines viewport top coordinate
  3688. * @param width defines the viewport width
  3689. * @param height defines the viewport height
  3690. */
  3691. constructor(
  3692. /** viewport left coordinate */
  3693. x: number,
  3694. /** viewport top coordinate */
  3695. y: number,
  3696. /**viewport width */
  3697. width: number,
  3698. /** viewport height */
  3699. height: number);
  3700. /**
  3701. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3702. * @param renderWidth defines the rendering width
  3703. * @param renderHeight defines the rendering height
  3704. * @returns a new Viewport
  3705. */
  3706. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3707. /**
  3708. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3709. * @param renderWidth defines the rendering width
  3710. * @param renderHeight defines the rendering height
  3711. * @param ref defines the target viewport
  3712. * @returns the current viewport
  3713. */
  3714. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3715. /**
  3716. * Returns a new Viewport copied from the current one
  3717. * @returns a new Viewport
  3718. */
  3719. clone(): Viewport;
  3720. }
  3721. /**
  3722. * Reprasents a camera frustum
  3723. */
  3724. export class Frustum {
  3725. /**
  3726. * Gets the planes representing the frustum
  3727. * @param transform matrix to be applied to the returned planes
  3728. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3729. */
  3730. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3731. /**
  3732. * Gets the near frustum plane transformed by the transform matrix
  3733. * @param transform transformation matrix to be applied to the resulting frustum plane
  3734. * @param frustumPlane the resuling frustum plane
  3735. */
  3736. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3737. /**
  3738. * Gets the far frustum plane transformed by the transform matrix
  3739. * @param transform transformation matrix to be applied to the resulting frustum plane
  3740. * @param frustumPlane the resuling frustum plane
  3741. */
  3742. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3743. /**
  3744. * Gets the left frustum plane transformed by the transform matrix
  3745. * @param transform transformation matrix to be applied to the resulting frustum plane
  3746. * @param frustumPlane the resuling frustum plane
  3747. */
  3748. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3749. /**
  3750. * Gets the right frustum plane transformed by the transform matrix
  3751. * @param transform transformation matrix to be applied to the resulting frustum plane
  3752. * @param frustumPlane the resuling frustum plane
  3753. */
  3754. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3755. /**
  3756. * Gets the top frustum plane transformed by the transform matrix
  3757. * @param transform transformation matrix to be applied to the resulting frustum plane
  3758. * @param frustumPlane the resuling frustum plane
  3759. */
  3760. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3761. /**
  3762. * Gets the bottom frustum plane transformed by the transform matrix
  3763. * @param transform transformation matrix to be applied to the resulting frustum plane
  3764. * @param frustumPlane the resuling frustum plane
  3765. */
  3766. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3767. /**
  3768. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3769. * @param transform transformation matrix to be applied to the resulting frustum planes
  3770. * @param frustumPlanes the resuling frustum planes
  3771. */
  3772. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3773. }
  3774. /** Defines supported spaces */
  3775. export enum Space {
  3776. /** Local (object) space */
  3777. LOCAL = 0,
  3778. /** World space */
  3779. WORLD = 1,
  3780. /** Bone space */
  3781. BONE = 2
  3782. }
  3783. /** Defines the 3 main axes */
  3784. export class Axis {
  3785. /** X axis */
  3786. static X: Vector3;
  3787. /** Y axis */
  3788. static Y: Vector3;
  3789. /** Z axis */
  3790. static Z: Vector3;
  3791. }
  3792. /** Class used to represent a Bezier curve */
  3793. export class BezierCurve {
  3794. /**
  3795. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3796. * @param t defines the time
  3797. * @param x1 defines the left coordinate on X axis
  3798. * @param y1 defines the left coordinate on Y axis
  3799. * @param x2 defines the right coordinate on X axis
  3800. * @param y2 defines the right coordinate on Y axis
  3801. * @returns the interpolated value
  3802. */
  3803. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3804. }
  3805. /**
  3806. * Defines potential orientation for back face culling
  3807. */
  3808. export enum Orientation {
  3809. /**
  3810. * Clockwise
  3811. */
  3812. CW = 0,
  3813. /** Counter clockwise */
  3814. CCW = 1
  3815. }
  3816. /**
  3817. * Defines angle representation
  3818. */
  3819. export class Angle {
  3820. private _radians;
  3821. /**
  3822. * Creates an Angle object of "radians" radians (float).
  3823. * @param radians the angle in radians
  3824. */
  3825. constructor(radians: number);
  3826. /**
  3827. * Get value in degrees
  3828. * @returns the Angle value in degrees (float)
  3829. */
  3830. degrees(): number;
  3831. /**
  3832. * Get value in radians
  3833. * @returns the Angle value in radians (float)
  3834. */
  3835. radians(): number;
  3836. /**
  3837. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3838. * @param a defines first vector
  3839. * @param b defines second vector
  3840. * @returns a new Angle
  3841. */
  3842. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3843. /**
  3844. * Gets a new Angle object from the given float in radians
  3845. * @param radians defines the angle value in radians
  3846. * @returns a new Angle
  3847. */
  3848. static FromRadians(radians: number): Angle;
  3849. /**
  3850. * Gets a new Angle object from the given float in degrees
  3851. * @param degrees defines the angle value in degrees
  3852. * @returns a new Angle
  3853. */
  3854. static FromDegrees(degrees: number): Angle;
  3855. }
  3856. /**
  3857. * This represents an arc in a 2d space.
  3858. */
  3859. export class Arc2 {
  3860. /** Defines the start point of the arc */
  3861. startPoint: Vector2;
  3862. /** Defines the mid point of the arc */
  3863. midPoint: Vector2;
  3864. /** Defines the end point of the arc */
  3865. endPoint: Vector2;
  3866. /**
  3867. * Defines the center point of the arc.
  3868. */
  3869. centerPoint: Vector2;
  3870. /**
  3871. * Defines the radius of the arc.
  3872. */
  3873. radius: number;
  3874. /**
  3875. * Defines the angle of the arc (from mid point to end point).
  3876. */
  3877. angle: Angle;
  3878. /**
  3879. * Defines the start angle of the arc (from start point to middle point).
  3880. */
  3881. startAngle: Angle;
  3882. /**
  3883. * Defines the orientation of the arc (clock wise/counter clock wise).
  3884. */
  3885. orientation: Orientation;
  3886. /**
  3887. * Creates an Arc object from the three given points : start, middle and end.
  3888. * @param startPoint Defines the start point of the arc
  3889. * @param midPoint Defines the midlle point of the arc
  3890. * @param endPoint Defines the end point of the arc
  3891. */
  3892. constructor(
  3893. /** Defines the start point of the arc */
  3894. startPoint: Vector2,
  3895. /** Defines the mid point of the arc */
  3896. midPoint: Vector2,
  3897. /** Defines the end point of the arc */
  3898. endPoint: Vector2);
  3899. }
  3900. /**
  3901. * Represents a 2D path made up of multiple 2D points
  3902. */
  3903. export class Path2 {
  3904. private _points;
  3905. private _length;
  3906. /**
  3907. * If the path start and end point are the same
  3908. */
  3909. closed: boolean;
  3910. /**
  3911. * Creates a Path2 object from the starting 2D coordinates x and y.
  3912. * @param x the starting points x value
  3913. * @param y the starting points y value
  3914. */
  3915. constructor(x: number, y: number);
  3916. /**
  3917. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3918. * @param x the added points x value
  3919. * @param y the added points y value
  3920. * @returns the updated Path2.
  3921. */
  3922. addLineTo(x: number, y: number): Path2;
  3923. /**
  3924. * 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.
  3925. * @param midX middle point x value
  3926. * @param midY middle point y value
  3927. * @param endX end point x value
  3928. * @param endY end point y value
  3929. * @param numberOfSegments (default: 36)
  3930. * @returns the updated Path2.
  3931. */
  3932. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3933. /**
  3934. * Closes the Path2.
  3935. * @returns the Path2.
  3936. */
  3937. close(): Path2;
  3938. /**
  3939. * Gets the sum of the distance between each sequential point in the path
  3940. * @returns the Path2 total length (float).
  3941. */
  3942. length(): number;
  3943. /**
  3944. * Gets the points which construct the path
  3945. * @returns the Path2 internal array of points.
  3946. */
  3947. getPoints(): Vector2[];
  3948. /**
  3949. * Retreives the point at the distance aways from the starting point
  3950. * @param normalizedLengthPosition the length along the path to retreive the point from
  3951. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3952. */
  3953. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3954. /**
  3955. * Creates a new path starting from an x and y position
  3956. * @param x starting x value
  3957. * @param y starting y value
  3958. * @returns a new Path2 starting at the coordinates (x, y).
  3959. */
  3960. static StartingAt(x: number, y: number): Path2;
  3961. }
  3962. /**
  3963. * Represents a 3D path made up of multiple 3D points
  3964. */
  3965. export class Path3D {
  3966. /**
  3967. * an array of Vector3, the curve axis of the Path3D
  3968. */
  3969. path: Vector3[];
  3970. private _curve;
  3971. private _distances;
  3972. private _tangents;
  3973. private _normals;
  3974. private _binormals;
  3975. private _raw;
  3976. /**
  3977. * new Path3D(path, normal, raw)
  3978. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3979. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3980. * @param path an array of Vector3, the curve axis of the Path3D
  3981. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3982. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3983. */
  3984. constructor(
  3985. /**
  3986. * an array of Vector3, the curve axis of the Path3D
  3987. */
  3988. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3989. /**
  3990. * Returns the Path3D array of successive Vector3 designing its curve.
  3991. * @returns the Path3D array of successive Vector3 designing its curve.
  3992. */
  3993. getCurve(): Vector3[];
  3994. /**
  3995. * Returns an array populated with tangent vectors on each Path3D curve point.
  3996. * @returns an array populated with tangent vectors on each Path3D curve point.
  3997. */
  3998. getTangents(): Vector3[];
  3999. /**
  4000. * Returns an array populated with normal vectors on each Path3D curve point.
  4001. * @returns an array populated with normal vectors on each Path3D curve point.
  4002. */
  4003. getNormals(): Vector3[];
  4004. /**
  4005. * Returns an array populated with binormal vectors on each Path3D curve point.
  4006. * @returns an array populated with binormal vectors on each Path3D curve point.
  4007. */
  4008. getBinormals(): Vector3[];
  4009. /**
  4010. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4012. */
  4013. getDistances(): number[];
  4014. /**
  4015. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4016. * @param path path which all values are copied into the curves points
  4017. * @param firstNormal which should be projected onto the curve
  4018. * @returns the same object updated.
  4019. */
  4020. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4021. private _compute;
  4022. private _getFirstNonNullVector;
  4023. private _getLastNonNullVector;
  4024. private _normalVector;
  4025. }
  4026. /**
  4027. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4028. * A Curve3 is designed from a series of successive Vector3.
  4029. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4030. */
  4031. export class Curve3 {
  4032. private _points;
  4033. private _length;
  4034. /**
  4035. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4036. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4037. * @param v1 (Vector3) the control point
  4038. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4039. * @param nbPoints (integer) the wanted number of points in the curve
  4040. * @returns the created Curve3
  4041. */
  4042. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4043. /**
  4044. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4045. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4046. * @param v1 (Vector3) the first control point
  4047. * @param v2 (Vector3) the second control point
  4048. * @param v3 (Vector3) the end point of the Cubic Bezier
  4049. * @param nbPoints (integer) the wanted number of points in the curve
  4050. * @returns the created Curve3
  4051. */
  4052. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4053. /**
  4054. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4055. * @param p1 (Vector3) the origin point of the Hermite Spline
  4056. * @param t1 (Vector3) the tangent vector at the origin point
  4057. * @param p2 (Vector3) the end point of the Hermite Spline
  4058. * @param t2 (Vector3) the tangent vector at the end point
  4059. * @param nbPoints (integer) the wanted number of points in the curve
  4060. * @returns the created Curve3
  4061. */
  4062. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4063. /**
  4064. * Returns a Curve3 object along a CatmullRom Spline curve :
  4065. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4066. * @param nbPoints (integer) the wanted number of points between each curve control points
  4067. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4068. * @returns the created Curve3
  4069. */
  4070. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4071. /**
  4072. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4073. * A Curve3 is designed from a series of successive Vector3.
  4074. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4075. * @param points points which make up the curve
  4076. */
  4077. constructor(points: Vector3[]);
  4078. /**
  4079. * @returns the Curve3 stored array of successive Vector3
  4080. */
  4081. getPoints(): Vector3[];
  4082. /**
  4083. * @returns the computed length (float) of the curve.
  4084. */
  4085. length(): number;
  4086. /**
  4087. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4088. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4089. * curveA and curveB keep unchanged.
  4090. * @param curve the curve to continue from this curve
  4091. * @returns the newly constructed curve
  4092. */
  4093. continue(curve: DeepImmutable<Curve3>): Curve3;
  4094. private _computeLength;
  4095. }
  4096. /**
  4097. * Contains position and normal vectors for a vertex
  4098. */
  4099. export class PositionNormalVertex {
  4100. /** the position of the vertex (defaut: 0,0,0) */
  4101. position: Vector3;
  4102. /** the normal of the vertex (defaut: 0,1,0) */
  4103. normal: Vector3;
  4104. /**
  4105. * Creates a PositionNormalVertex
  4106. * @param position the position of the vertex (defaut: 0,0,0)
  4107. * @param normal the normal of the vertex (defaut: 0,1,0)
  4108. */
  4109. constructor(
  4110. /** the position of the vertex (defaut: 0,0,0) */
  4111. position?: Vector3,
  4112. /** the normal of the vertex (defaut: 0,1,0) */
  4113. normal?: Vector3);
  4114. /**
  4115. * Clones the PositionNormalVertex
  4116. * @returns the cloned PositionNormalVertex
  4117. */
  4118. clone(): PositionNormalVertex;
  4119. }
  4120. /**
  4121. * Contains position, normal and uv vectors for a vertex
  4122. */
  4123. export class PositionNormalTextureVertex {
  4124. /** the position of the vertex (defaut: 0,0,0) */
  4125. position: Vector3;
  4126. /** the normal of the vertex (defaut: 0,1,0) */
  4127. normal: Vector3;
  4128. /** the uv of the vertex (default: 0,0) */
  4129. uv: Vector2;
  4130. /**
  4131. * Creates a PositionNormalTextureVertex
  4132. * @param position the position of the vertex (defaut: 0,0,0)
  4133. * @param normal the normal of the vertex (defaut: 0,1,0)
  4134. * @param uv the uv of the vertex (default: 0,0)
  4135. */
  4136. constructor(
  4137. /** the position of the vertex (defaut: 0,0,0) */
  4138. position?: Vector3,
  4139. /** the normal of the vertex (defaut: 0,1,0) */
  4140. normal?: Vector3,
  4141. /** the uv of the vertex (default: 0,0) */
  4142. uv?: Vector2);
  4143. /**
  4144. * Clones the PositionNormalTextureVertex
  4145. * @returns the cloned PositionNormalTextureVertex
  4146. */
  4147. clone(): PositionNormalTextureVertex;
  4148. }
  4149. /**
  4150. * @hidden
  4151. */
  4152. export class Tmp {
  4153. static Color3: Color3[];
  4154. static Color4: Color4[];
  4155. static Vector2: Vector2[];
  4156. static Vector3: Vector3[];
  4157. static Vector4: Vector4[];
  4158. static Quaternion: Quaternion[];
  4159. static Matrix: Matrix[];
  4160. }
  4161. }
  4162. declare module "babylonjs/Offline/IOfflineProvider" {
  4163. /**
  4164. * Class used to enable access to offline support
  4165. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4166. */
  4167. export interface IOfflineProvider {
  4168. /**
  4169. * Gets a boolean indicating if scene must be saved in the database
  4170. */
  4171. enableSceneOffline: boolean;
  4172. /**
  4173. * Gets a boolean indicating if textures must be saved in the database
  4174. */
  4175. enableTexturesOffline: boolean;
  4176. /**
  4177. * Open the offline support and make it available
  4178. * @param successCallback defines the callback to call on success
  4179. * @param errorCallback defines the callback to call on error
  4180. */
  4181. open(successCallback: () => void, errorCallback: () => void): void;
  4182. /**
  4183. * Loads an image from the offline support
  4184. * @param url defines the url to load from
  4185. * @param image defines the target DOM image
  4186. */
  4187. loadImage(url: string, image: HTMLImageElement): void;
  4188. /**
  4189. * Loads a file from offline support
  4190. * @param url defines the URL to load from
  4191. * @param sceneLoaded defines a callback to call on success
  4192. * @param progressCallBack defines a callback to call when progress changed
  4193. * @param errorCallback defines a callback to call on error
  4194. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4195. */
  4196. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4197. }
  4198. }
  4199. declare module "babylonjs/Misc/observable" {
  4200. import { Nullable } from "babylonjs/types";
  4201. /**
  4202. * A class serves as a medium between the observable and its observers
  4203. */
  4204. export class EventState {
  4205. /**
  4206. * Create a new EventState
  4207. * @param mask defines the mask associated with this state
  4208. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4209. * @param target defines the original target of the state
  4210. * @param currentTarget defines the current target of the state
  4211. */
  4212. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4213. /**
  4214. * Initialize the current event state
  4215. * @param mask defines the mask associated with this state
  4216. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4217. * @param target defines the original target of the state
  4218. * @param currentTarget defines the current target of the state
  4219. * @returns the current event state
  4220. */
  4221. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4222. /**
  4223. * An Observer can set this property to true to prevent subsequent observers of being notified
  4224. */
  4225. skipNextObservers: boolean;
  4226. /**
  4227. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4228. */
  4229. mask: number;
  4230. /**
  4231. * The object that originally notified the event
  4232. */
  4233. target?: any;
  4234. /**
  4235. * The current object in the bubbling phase
  4236. */
  4237. currentTarget?: any;
  4238. /**
  4239. * This will be populated with the return value of the last function that was executed.
  4240. * If it is the first function in the callback chain it will be the event data.
  4241. */
  4242. lastReturnValue?: any;
  4243. }
  4244. /**
  4245. * Represent an Observer registered to a given Observable object.
  4246. */
  4247. export class Observer<T> {
  4248. /**
  4249. * Defines the callback to call when the observer is notified
  4250. */
  4251. callback: (eventData: T, eventState: EventState) => void;
  4252. /**
  4253. * Defines the mask of the observer (used to filter notifications)
  4254. */
  4255. mask: number;
  4256. /**
  4257. * Defines the current scope used to restore the JS context
  4258. */
  4259. scope: any;
  4260. /** @hidden */
  4261. _willBeUnregistered: boolean;
  4262. /**
  4263. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4264. */
  4265. unregisterOnNextCall: boolean;
  4266. /**
  4267. * Creates a new observer
  4268. * @param callback defines the callback to call when the observer is notified
  4269. * @param mask defines the mask of the observer (used to filter notifications)
  4270. * @param scope defines the current scope used to restore the JS context
  4271. */
  4272. constructor(
  4273. /**
  4274. * Defines the callback to call when the observer is notified
  4275. */
  4276. callback: (eventData: T, eventState: EventState) => void,
  4277. /**
  4278. * Defines the mask of the observer (used to filter notifications)
  4279. */
  4280. mask: number,
  4281. /**
  4282. * Defines the current scope used to restore the JS context
  4283. */
  4284. scope?: any);
  4285. }
  4286. /**
  4287. * Represent a list of observers registered to multiple Observables object.
  4288. */
  4289. export class MultiObserver<T> {
  4290. private _observers;
  4291. private _observables;
  4292. /**
  4293. * Release associated resources
  4294. */
  4295. dispose(): void;
  4296. /**
  4297. * Raise a callback when one of the observable will notify
  4298. * @param observables defines a list of observables to watch
  4299. * @param callback defines the callback to call on notification
  4300. * @param mask defines the mask used to filter notifications
  4301. * @param scope defines the current scope used to restore the JS context
  4302. * @returns the new MultiObserver
  4303. */
  4304. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4305. }
  4306. /**
  4307. * The Observable class is a simple implementation of the Observable pattern.
  4308. *
  4309. * 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.
  4310. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4311. * 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).
  4312. * 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.
  4313. */
  4314. export class Observable<T> {
  4315. private _observers;
  4316. private _eventState;
  4317. private _onObserverAdded;
  4318. /**
  4319. * Creates a new observable
  4320. * @param onObserverAdded defines a callback to call when a new observer is added
  4321. */
  4322. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4323. /**
  4324. * Create a new Observer with the specified callback
  4325. * @param callback the callback that will be executed for that Observer
  4326. * @param mask the mask used to filter observers
  4327. * @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.
  4328. * @param scope optional scope for the callback to be called from
  4329. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4330. * @returns the new observer created for the callback
  4331. */
  4332. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4333. /**
  4334. * Create a new Observer with the specified callback and unregisters after the next notification
  4335. * @param callback the callback that will be executed for that Observer
  4336. * @returns the new observer created for the callback
  4337. */
  4338. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4339. /**
  4340. * Remove an Observer from the Observable object
  4341. * @param observer the instance of the Observer to remove
  4342. * @returns false if it doesn't belong to this Observable
  4343. */
  4344. remove(observer: Nullable<Observer<T>>): boolean;
  4345. /**
  4346. * Remove a callback from the Observable object
  4347. * @param callback the callback to remove
  4348. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4349. * @returns false if it doesn't belong to this Observable
  4350. */
  4351. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4352. private _deferUnregister;
  4353. private _remove;
  4354. /**
  4355. * Notify all Observers by calling their respective callback with the given data
  4356. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4357. * @param eventData defines the data to send to all observers
  4358. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4359. * @param target defines the original target of the state
  4360. * @param currentTarget defines the current target of the state
  4361. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4362. */
  4363. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4364. /**
  4365. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4366. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4367. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4368. * and it is crucial that all callbacks will be executed.
  4369. * The order of the callbacks is kept, callbacks are not executed parallel.
  4370. *
  4371. * @param eventData The data to be sent to each callback
  4372. * @param mask is used to filter observers defaults to -1
  4373. * @param target defines the callback target (see EventState)
  4374. * @param currentTarget defines he current object in the bubbling phase
  4375. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4376. */
  4377. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4378. /**
  4379. * Notify a specific observer
  4380. * @param observer defines the observer to notify
  4381. * @param eventData defines the data to be sent to each callback
  4382. * @param mask is used to filter observers defaults to -1
  4383. */
  4384. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4385. /**
  4386. * Gets a boolean indicating if the observable has at least one observer
  4387. * @returns true is the Observable has at least one Observer registered
  4388. */
  4389. hasObservers(): boolean;
  4390. /**
  4391. * Clear the list of observers
  4392. */
  4393. clear(): void;
  4394. /**
  4395. * Clone the current observable
  4396. * @returns a new observable
  4397. */
  4398. clone(): Observable<T>;
  4399. /**
  4400. * Does this observable handles observer registered with a given mask
  4401. * @param mask defines the mask to be tested
  4402. * @return whether or not one observer registered with the given mask is handeled
  4403. **/
  4404. hasSpecificMask(mask?: number): boolean;
  4405. }
  4406. }
  4407. declare module "babylonjs/Misc/filesInputStore" {
  4408. /**
  4409. * Class used to help managing file picking and drag'n'drop
  4410. * File Storage
  4411. */
  4412. export class FilesInputStore {
  4413. /**
  4414. * List of files ready to be loaded
  4415. */
  4416. static FilesToLoad: {
  4417. [key: string]: File;
  4418. };
  4419. }
  4420. }
  4421. declare module "babylonjs/Engines/constants" {
  4422. /** Defines the cross module used constants to avoid circular dependncies */
  4423. export class Constants {
  4424. /** Defines that alpha blending is disabled */
  4425. static readonly ALPHA_DISABLE: number;
  4426. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4427. static readonly ALPHA_ADD: number;
  4428. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4429. static readonly ALPHA_COMBINE: number;
  4430. /** Defines that alpha blending to DEST - SRC * DEST */
  4431. static readonly ALPHA_SUBTRACT: number;
  4432. /** Defines that alpha blending to SRC * DEST */
  4433. static readonly ALPHA_MULTIPLY: number;
  4434. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4435. static readonly ALPHA_MAXIMIZED: number;
  4436. /** Defines that alpha blending to SRC + DEST */
  4437. static readonly ALPHA_ONEONE: number;
  4438. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4439. static readonly ALPHA_PREMULTIPLIED: number;
  4440. /**
  4441. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4442. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4443. */
  4444. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4445. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4446. static readonly ALPHA_INTERPOLATE: number;
  4447. /**
  4448. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4449. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4450. */
  4451. static readonly ALPHA_SCREENMODE: number;
  4452. /** Defines that the ressource is not delayed*/
  4453. static readonly DELAYLOADSTATE_NONE: number;
  4454. /** Defines that the ressource was successfully delay loaded */
  4455. static readonly DELAYLOADSTATE_LOADED: number;
  4456. /** Defines that the ressource is currently delay loading */
  4457. static readonly DELAYLOADSTATE_LOADING: number;
  4458. /** Defines that the ressource is delayed and has not started loading */
  4459. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4460. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4461. static readonly NEVER: number;
  4462. /** 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 */
  4463. static readonly ALWAYS: number;
  4464. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4465. static readonly LESS: number;
  4466. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4467. static readonly EQUAL: number;
  4468. /** 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 */
  4469. static readonly LEQUAL: number;
  4470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4471. static readonly GREATER: number;
  4472. /** 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 */
  4473. static readonly GEQUAL: number;
  4474. /** 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 */
  4475. static readonly NOTEQUAL: number;
  4476. /** Passed to stencilOperation to specify that stencil value must be kept */
  4477. static readonly KEEP: number;
  4478. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4479. static readonly REPLACE: number;
  4480. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4481. static readonly INCR: number;
  4482. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4483. static readonly DECR: number;
  4484. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4485. static readonly INVERT: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4487. static readonly INCR_WRAP: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4489. static readonly DECR_WRAP: number;
  4490. /** Texture is not repeating outside of 0..1 UVs */
  4491. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4492. /** Texture is repeating outside of 0..1 UVs */
  4493. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4494. /** Texture is repeating and mirrored */
  4495. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4496. /** ALPHA */
  4497. static readonly TEXTUREFORMAT_ALPHA: number;
  4498. /** LUMINANCE */
  4499. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4500. /** LUMINANCE_ALPHA */
  4501. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4502. /** RGB */
  4503. static readonly TEXTUREFORMAT_RGB: number;
  4504. /** RGBA */
  4505. static readonly TEXTUREFORMAT_RGBA: number;
  4506. /** RED */
  4507. static readonly TEXTUREFORMAT_RED: number;
  4508. /** RED (2nd reference) */
  4509. static readonly TEXTUREFORMAT_R: number;
  4510. /** RG */
  4511. static readonly TEXTUREFORMAT_RG: number;
  4512. /** RED_INTEGER */
  4513. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4514. /** RED_INTEGER (2nd reference) */
  4515. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4516. /** RG_INTEGER */
  4517. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4518. /** RGB_INTEGER */
  4519. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4520. /** RGBA_INTEGER */
  4521. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4522. /** UNSIGNED_BYTE */
  4523. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4524. /** UNSIGNED_BYTE (2nd reference) */
  4525. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4526. /** FLOAT */
  4527. static readonly TEXTURETYPE_FLOAT: number;
  4528. /** HALF_FLOAT */
  4529. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4530. /** BYTE */
  4531. static readonly TEXTURETYPE_BYTE: number;
  4532. /** SHORT */
  4533. static readonly TEXTURETYPE_SHORT: number;
  4534. /** UNSIGNED_SHORT */
  4535. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4536. /** INT */
  4537. static readonly TEXTURETYPE_INT: number;
  4538. /** UNSIGNED_INT */
  4539. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4540. /** UNSIGNED_SHORT_4_4_4_4 */
  4541. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4542. /** UNSIGNED_SHORT_5_5_5_1 */
  4543. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4544. /** UNSIGNED_SHORT_5_6_5 */
  4545. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4546. /** UNSIGNED_INT_2_10_10_10_REV */
  4547. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4548. /** UNSIGNED_INT_24_8 */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4550. /** UNSIGNED_INT_10F_11F_11F_REV */
  4551. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4552. /** UNSIGNED_INT_5_9_9_9_REV */
  4553. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4554. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4555. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4556. /** nearest is mag = nearest and min = nearest and mip = linear */
  4557. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4558. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4559. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4560. /** Trilinear is mag = linear and min = linear and mip = linear */
  4561. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4562. /** nearest is mag = nearest and min = nearest and mip = linear */
  4563. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4564. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4565. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4566. /** Trilinear is mag = linear and min = linear and mip = linear */
  4567. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4568. /** mag = nearest and min = nearest and mip = nearest */
  4569. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4570. /** mag = nearest and min = linear and mip = nearest */
  4571. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4572. /** mag = nearest and min = linear and mip = linear */
  4573. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4574. /** mag = nearest and min = linear and mip = none */
  4575. static readonly TEXTURE_NEAREST_LINEAR: number;
  4576. /** mag = nearest and min = nearest and mip = none */
  4577. static readonly TEXTURE_NEAREST_NEAREST: number;
  4578. /** mag = linear and min = nearest and mip = nearest */
  4579. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4580. /** mag = linear and min = nearest and mip = linear */
  4581. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4582. /** mag = linear and min = linear and mip = none */
  4583. static readonly TEXTURE_LINEAR_LINEAR: number;
  4584. /** mag = linear and min = nearest and mip = none */
  4585. static readonly TEXTURE_LINEAR_NEAREST: number;
  4586. /** Explicit coordinates mode */
  4587. static readonly TEXTURE_EXPLICIT_MODE: number;
  4588. /** Spherical coordinates mode */
  4589. static readonly TEXTURE_SPHERICAL_MODE: number;
  4590. /** Planar coordinates mode */
  4591. static readonly TEXTURE_PLANAR_MODE: number;
  4592. /** Cubic coordinates mode */
  4593. static readonly TEXTURE_CUBIC_MODE: number;
  4594. /** Projection coordinates mode */
  4595. static readonly TEXTURE_PROJECTION_MODE: number;
  4596. /** Skybox coordinates mode */
  4597. static readonly TEXTURE_SKYBOX_MODE: number;
  4598. /** Inverse Cubic coordinates mode */
  4599. static readonly TEXTURE_INVCUBIC_MODE: number;
  4600. /** Equirectangular coordinates mode */
  4601. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4602. /** Equirectangular Fixed coordinates mode */
  4603. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4604. /** Equirectangular Fixed Mirrored coordinates mode */
  4605. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4606. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4607. static readonly SCALEMODE_FLOOR: number;
  4608. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4609. static readonly SCALEMODE_NEAREST: number;
  4610. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4611. static readonly SCALEMODE_CEILING: number;
  4612. /**
  4613. * The dirty texture flag value
  4614. */
  4615. static readonly MATERIAL_TextureDirtyFlag: number;
  4616. /**
  4617. * The dirty light flag value
  4618. */
  4619. static readonly MATERIAL_LightDirtyFlag: number;
  4620. /**
  4621. * The dirty fresnel flag value
  4622. */
  4623. static readonly MATERIAL_FresnelDirtyFlag: number;
  4624. /**
  4625. * The dirty attribute flag value
  4626. */
  4627. static readonly MATERIAL_AttributesDirtyFlag: number;
  4628. /**
  4629. * The dirty misc flag value
  4630. */
  4631. static readonly MATERIAL_MiscDirtyFlag: number;
  4632. /**
  4633. * The all dirty flag value
  4634. */
  4635. static readonly MATERIAL_AllDirtyFlag: number;
  4636. /**
  4637. * Returns the triangle fill mode
  4638. */
  4639. static readonly MATERIAL_TriangleFillMode: number;
  4640. /**
  4641. * Returns the wireframe mode
  4642. */
  4643. static readonly MATERIAL_WireFrameFillMode: number;
  4644. /**
  4645. * Returns the point fill mode
  4646. */
  4647. static readonly MATERIAL_PointFillMode: number;
  4648. /**
  4649. * Returns the point list draw mode
  4650. */
  4651. static readonly MATERIAL_PointListDrawMode: number;
  4652. /**
  4653. * Returns the line list draw mode
  4654. */
  4655. static readonly MATERIAL_LineListDrawMode: number;
  4656. /**
  4657. * Returns the line loop draw mode
  4658. */
  4659. static readonly MATERIAL_LineLoopDrawMode: number;
  4660. /**
  4661. * Returns the line strip draw mode
  4662. */
  4663. static readonly MATERIAL_LineStripDrawMode: number;
  4664. /**
  4665. * Returns the triangle strip draw mode
  4666. */
  4667. static readonly MATERIAL_TriangleStripDrawMode: number;
  4668. /**
  4669. * Returns the triangle fan draw mode
  4670. */
  4671. static readonly MATERIAL_TriangleFanDrawMode: number;
  4672. /**
  4673. * Stores the clock-wise side orientation
  4674. */
  4675. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4676. /**
  4677. * Stores the counter clock-wise side orientation
  4678. */
  4679. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4680. /**
  4681. * Nothing
  4682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4683. */
  4684. static readonly ACTION_NothingTrigger: number;
  4685. /**
  4686. * On pick
  4687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4688. */
  4689. static readonly ACTION_OnPickTrigger: number;
  4690. /**
  4691. * On left pick
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_OnLeftPickTrigger: number;
  4695. /**
  4696. * On right pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnRightPickTrigger: number;
  4700. /**
  4701. * On center pick
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnCenterPickTrigger: number;
  4705. /**
  4706. * On pick down
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnPickDownTrigger: number;
  4710. /**
  4711. * On double pick
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnDoublePickTrigger: number;
  4715. /**
  4716. * On pick up
  4717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4718. */
  4719. static readonly ACTION_OnPickUpTrigger: number;
  4720. /**
  4721. * On pick out.
  4722. * This trigger will only be raised if you also declared a OnPickDown
  4723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4724. */
  4725. static readonly ACTION_OnPickOutTrigger: number;
  4726. /**
  4727. * On long press
  4728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4729. */
  4730. static readonly ACTION_OnLongPressTrigger: number;
  4731. /**
  4732. * On pointer over
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnPointerOverTrigger: number;
  4736. /**
  4737. * On pointer out
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnPointerOutTrigger: number;
  4741. /**
  4742. * On every frame
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnEveryFrameTrigger: number;
  4746. /**
  4747. * On intersection enter
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4751. /**
  4752. * On intersection exit
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnIntersectionExitTrigger: number;
  4756. /**
  4757. * On key down
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnKeyDownTrigger: number;
  4761. /**
  4762. * On key up
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnKeyUpTrigger: number;
  4766. /**
  4767. * Billboard mode will only apply to Y axis
  4768. */
  4769. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4770. /**
  4771. * Billboard mode will apply to all axes
  4772. */
  4773. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4774. /**
  4775. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4776. */
  4777. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4778. /**
  4779. * Gets or sets base Assets URL
  4780. */
  4781. static readonly PARTICLES_BaseAssetsUrl: string;
  4782. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4783. * Test order :
  4784. * Is the bounding sphere outside the frustum ?
  4785. * If not, are the bounding box vertices outside the frustum ?
  4786. * It not, then the cullable object is in the frustum.
  4787. */
  4788. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4789. /** Culling strategy : Bounding Sphere Only.
  4790. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4791. * It's also less accurate than the standard because some not visible objects can still be selected.
  4792. * Test : is the bounding sphere outside the frustum ?
  4793. * If not, then the cullable object is in the frustum.
  4794. */
  4795. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4796. /** Culling strategy : Optimistic Inclusion.
  4797. * This in an inclusion test first, then the standard exclusion test.
  4798. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4799. * 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.
  4800. * Anyway, it's as accurate as the standard strategy.
  4801. * Test :
  4802. * Is the cullable object bounding sphere center in the frustum ?
  4803. * If not, apply the default culling strategy.
  4804. */
  4805. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4806. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4807. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4808. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4809. * 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.
  4810. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4811. * Test :
  4812. * Is the cullable object bounding sphere center in the frustum ?
  4813. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4816. /**
  4817. * No logging while loading
  4818. */
  4819. static readonly SCENELOADER_NO_LOGGING: number;
  4820. /**
  4821. * Minimal logging while loading
  4822. */
  4823. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4824. /**
  4825. * Summary logging while loading
  4826. */
  4827. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4828. /**
  4829. * Detailled logging while loading
  4830. */
  4831. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4832. }
  4833. }
  4834. declare module "babylonjs/Misc/domManagement" {
  4835. /**
  4836. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4837. * Babylon.js
  4838. */
  4839. export class DomManagement {
  4840. /**
  4841. * Checks if the window object exists
  4842. * @returns true if the window object exists
  4843. */
  4844. static IsWindowObjectExist(): boolean;
  4845. /**
  4846. * Extracts text content from a DOM element hierarchy
  4847. * @param element defines the root element
  4848. * @returns a string
  4849. */
  4850. static GetDOMTextContent(element: HTMLElement): string;
  4851. }
  4852. }
  4853. declare module "babylonjs/Misc/logger" {
  4854. /**
  4855. * Logger used througouht the application to allow configuration of
  4856. * the log level required for the messages.
  4857. */
  4858. export class Logger {
  4859. /**
  4860. * No log
  4861. */
  4862. static readonly NoneLogLevel: number;
  4863. /**
  4864. * Only message logs
  4865. */
  4866. static readonly MessageLogLevel: number;
  4867. /**
  4868. * Only warning logs
  4869. */
  4870. static readonly WarningLogLevel: number;
  4871. /**
  4872. * Only error logs
  4873. */
  4874. static readonly ErrorLogLevel: number;
  4875. /**
  4876. * All logs
  4877. */
  4878. static readonly AllLogLevel: number;
  4879. private static _LogCache;
  4880. /**
  4881. * Gets a value indicating the number of loading errors
  4882. * @ignorenaming
  4883. */
  4884. static errorsCount: number;
  4885. /**
  4886. * Callback called when a new log is added
  4887. */
  4888. static OnNewCacheEntry: (entry: string) => void;
  4889. private static _AddLogEntry;
  4890. private static _FormatMessage;
  4891. private static _LogDisabled;
  4892. private static _LogEnabled;
  4893. private static _WarnDisabled;
  4894. private static _WarnEnabled;
  4895. private static _ErrorDisabled;
  4896. private static _ErrorEnabled;
  4897. /**
  4898. * Log a message to the console
  4899. */
  4900. static Log: (message: string) => void;
  4901. /**
  4902. * Write a warning message to the console
  4903. */
  4904. static Warn: (message: string) => void;
  4905. /**
  4906. * Write an error message to the console
  4907. */
  4908. static Error: (message: string) => void;
  4909. /**
  4910. * Gets current log cache (list of logs)
  4911. */
  4912. static readonly LogCache: string;
  4913. /**
  4914. * Clears the log cache
  4915. */
  4916. static ClearLogCache(): void;
  4917. /**
  4918. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4919. */
  4920. static LogLevels: number;
  4921. }
  4922. }
  4923. declare module "babylonjs/Misc/typeStore" {
  4924. /** @hidden */
  4925. export class _TypeStore {
  4926. /** @hidden */
  4927. static RegisteredTypes: {
  4928. [key: string]: Object;
  4929. };
  4930. /** @hidden */
  4931. static GetClass(fqdn: string): any;
  4932. }
  4933. }
  4934. declare module "babylonjs/Misc/deepCopier" {
  4935. /**
  4936. * Class containing a set of static utilities functions for deep copy.
  4937. */
  4938. export class DeepCopier {
  4939. /**
  4940. * Tries to copy an object by duplicating every property
  4941. * @param source defines the source object
  4942. * @param destination defines the target object
  4943. * @param doNotCopyList defines a list of properties to avoid
  4944. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4945. */
  4946. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4947. }
  4948. }
  4949. declare module "babylonjs/Misc/precisionDate" {
  4950. /**
  4951. * Class containing a set of static utilities functions for precision date
  4952. */
  4953. export class PrecisionDate {
  4954. /**
  4955. * Gets either window.performance.now() if supported or Date.now() else
  4956. */
  4957. static readonly Now: number;
  4958. }
  4959. }
  4960. declare module "babylonjs/Misc/devTools" {
  4961. /** @hidden */
  4962. export class _DevTools {
  4963. static WarnImport(name: string): string;
  4964. }
  4965. }
  4966. declare module "babylonjs/Misc/andOrNotEvaluator" {
  4967. /**
  4968. * Class used to evalaute queries containing `and` and `or` operators
  4969. */
  4970. export class AndOrNotEvaluator {
  4971. /**
  4972. * Evaluate a query
  4973. * @param query defines the query to evaluate
  4974. * @param evaluateCallback defines the callback used to filter result
  4975. * @returns true if the query matches
  4976. */
  4977. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4978. private static _HandleParenthesisContent;
  4979. private static _SimplifyNegation;
  4980. }
  4981. }
  4982. declare module "babylonjs/Misc/tags" {
  4983. /**
  4984. * Class used to store custom tags
  4985. */
  4986. export class Tags {
  4987. /**
  4988. * Adds support for tags on the given object
  4989. * @param obj defines the object to use
  4990. */
  4991. static EnableFor(obj: any): void;
  4992. /**
  4993. * Removes tags support
  4994. * @param obj defines the object to use
  4995. */
  4996. static DisableFor(obj: any): void;
  4997. /**
  4998. * Gets a boolean indicating if the given object has tags
  4999. * @param obj defines the object to use
  5000. * @returns a boolean
  5001. */
  5002. static HasTags(obj: any): boolean;
  5003. /**
  5004. * Gets the tags available on a given object
  5005. * @param obj defines the object to use
  5006. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5007. * @returns the tags
  5008. */
  5009. static GetTags(obj: any, asString?: boolean): any;
  5010. /**
  5011. * Adds tags to an object
  5012. * @param obj defines the object to use
  5013. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5014. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5015. */
  5016. static AddTagsTo(obj: any, tagsString: string): void;
  5017. /**
  5018. * @hidden
  5019. */
  5020. static _AddTagTo(obj: any, tag: string): void;
  5021. /**
  5022. * Removes specific tags from a specific object
  5023. * @param obj defines the object to use
  5024. * @param tagsString defines the tags to remove
  5025. */
  5026. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5027. /**
  5028. * @hidden
  5029. */
  5030. static _RemoveTagFrom(obj: any, tag: string): void;
  5031. /**
  5032. * Defines if tags hosted on an object match a given query
  5033. * @param obj defines the object to use
  5034. * @param tagsQuery defines the tag query
  5035. * @returns a boolean
  5036. */
  5037. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5038. }
  5039. }
  5040. declare module "babylonjs/Materials/materialDefines" {
  5041. /**
  5042. * Manages the defines for the Material
  5043. */
  5044. export class MaterialDefines {
  5045. private _keys;
  5046. private _isDirty;
  5047. /** @hidden */
  5048. _renderId: number;
  5049. /** @hidden */
  5050. _areLightsDirty: boolean;
  5051. /** @hidden */
  5052. _areAttributesDirty: boolean;
  5053. /** @hidden */
  5054. _areTexturesDirty: boolean;
  5055. /** @hidden */
  5056. _areFresnelDirty: boolean;
  5057. /** @hidden */
  5058. _areMiscDirty: boolean;
  5059. /** @hidden */
  5060. _areImageProcessingDirty: boolean;
  5061. /** @hidden */
  5062. _normals: boolean;
  5063. /** @hidden */
  5064. _uvs: boolean;
  5065. /** @hidden */
  5066. _needNormals: boolean;
  5067. /** @hidden */
  5068. _needUVs: boolean;
  5069. /**
  5070. * Specifies if the material needs to be re-calculated
  5071. */
  5072. readonly isDirty: boolean;
  5073. /**
  5074. * Marks the material to indicate that it has been re-calculated
  5075. */
  5076. markAsProcessed(): void;
  5077. /**
  5078. * Marks the material to indicate that it needs to be re-calculated
  5079. */
  5080. markAsUnprocessed(): void;
  5081. /**
  5082. * Marks the material to indicate all of its defines need to be re-calculated
  5083. */
  5084. markAllAsDirty(): void;
  5085. /**
  5086. * Marks the material to indicate that image processing needs to be re-calculated
  5087. */
  5088. markAsImageProcessingDirty(): void;
  5089. /**
  5090. * Marks the material to indicate the lights need to be re-calculated
  5091. */
  5092. markAsLightDirty(): void;
  5093. /**
  5094. * Marks the attribute state as changed
  5095. */
  5096. markAsAttributesDirty(): void;
  5097. /**
  5098. * Marks the texture state as changed
  5099. */
  5100. markAsTexturesDirty(): void;
  5101. /**
  5102. * Marks the fresnel state as changed
  5103. */
  5104. markAsFresnelDirty(): void;
  5105. /**
  5106. * Marks the misc state as changed
  5107. */
  5108. markAsMiscDirty(): void;
  5109. /**
  5110. * Rebuilds the material defines
  5111. */
  5112. rebuild(): void;
  5113. /**
  5114. * Specifies if two material defines are equal
  5115. * @param other - A material define instance to compare to
  5116. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5117. */
  5118. isEqual(other: MaterialDefines): boolean;
  5119. /**
  5120. * Clones this instance's defines to another instance
  5121. * @param other - material defines to clone values to
  5122. */
  5123. cloneTo(other: MaterialDefines): void;
  5124. /**
  5125. * Resets the material define values
  5126. */
  5127. reset(): void;
  5128. /**
  5129. * Converts the material define values to a string
  5130. * @returns - String of material define information
  5131. */
  5132. toString(): string;
  5133. }
  5134. }
  5135. declare module "babylonjs/Misc/performanceMonitor" {
  5136. /**
  5137. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5138. */
  5139. export class PerformanceMonitor {
  5140. private _enabled;
  5141. private _rollingFrameTime;
  5142. private _lastFrameTimeMs;
  5143. /**
  5144. * constructor
  5145. * @param frameSampleSize The number of samples required to saturate the sliding window
  5146. */
  5147. constructor(frameSampleSize?: number);
  5148. /**
  5149. * Samples current frame
  5150. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5151. */
  5152. sampleFrame(timeMs?: number): void;
  5153. /**
  5154. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5155. */
  5156. readonly averageFrameTime: number;
  5157. /**
  5158. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5159. */
  5160. readonly averageFrameTimeVariance: number;
  5161. /**
  5162. * Returns the frame time of the most recent frame
  5163. */
  5164. readonly instantaneousFrameTime: number;
  5165. /**
  5166. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5167. */
  5168. readonly averageFPS: number;
  5169. /**
  5170. * Returns the average framerate in frames per second using the most recent frame time
  5171. */
  5172. readonly instantaneousFPS: number;
  5173. /**
  5174. * Returns true if enough samples have been taken to completely fill the sliding window
  5175. */
  5176. readonly isSaturated: boolean;
  5177. /**
  5178. * Enables contributions to the sliding window sample set
  5179. */
  5180. enable(): void;
  5181. /**
  5182. * Disables contributions to the sliding window sample set
  5183. * Samples will not be interpolated over the disabled period
  5184. */
  5185. disable(): void;
  5186. /**
  5187. * Returns true if sampling is enabled
  5188. */
  5189. readonly isEnabled: boolean;
  5190. /**
  5191. * Resets performance monitor
  5192. */
  5193. reset(): void;
  5194. }
  5195. /**
  5196. * RollingAverage
  5197. *
  5198. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5199. */
  5200. export class RollingAverage {
  5201. /**
  5202. * Current average
  5203. */
  5204. average: number;
  5205. /**
  5206. * Current variance
  5207. */
  5208. variance: number;
  5209. protected _samples: Array<number>;
  5210. protected _sampleCount: number;
  5211. protected _pos: number;
  5212. protected _m2: number;
  5213. /**
  5214. * constructor
  5215. * @param length The number of samples required to saturate the sliding window
  5216. */
  5217. constructor(length: number);
  5218. /**
  5219. * Adds a sample to the sample set
  5220. * @param v The sample value
  5221. */
  5222. add(v: number): void;
  5223. /**
  5224. * Returns previously added values or null if outside of history or outside the sliding window domain
  5225. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5226. * @return Value previously recorded with add() or null if outside of range
  5227. */
  5228. history(i: number): number;
  5229. /**
  5230. * Returns true if enough samples have been taken to completely fill the sliding window
  5231. * @return true if sample-set saturated
  5232. */
  5233. isSaturated(): boolean;
  5234. /**
  5235. * Resets the rolling average (equivalent to 0 samples taken so far)
  5236. */
  5237. reset(): void;
  5238. /**
  5239. * Wraps a value around the sample range boundaries
  5240. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5241. * @return Wrapped position in sample range
  5242. */
  5243. protected _wrapPosition(i: number): number;
  5244. }
  5245. }
  5246. declare module "babylonjs/Misc/stringDictionary" {
  5247. import { Nullable } from "babylonjs/types";
  5248. /**
  5249. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5250. * The underlying implementation relies on an associative array to ensure the best performances.
  5251. * The value can be anything including 'null' but except 'undefined'
  5252. */
  5253. export class StringDictionary<T> {
  5254. /**
  5255. * This will clear this dictionary and copy the content from the 'source' one.
  5256. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5257. * @param source the dictionary to take the content from and copy to this dictionary
  5258. */
  5259. copyFrom(source: StringDictionary<T>): void;
  5260. /**
  5261. * Get a value based from its key
  5262. * @param key the given key to get the matching value from
  5263. * @return the value if found, otherwise undefined is returned
  5264. */
  5265. get(key: string): T | undefined;
  5266. /**
  5267. * Get a value from its key or add it if it doesn't exist.
  5268. * This method will ensure you that a given key/data will be present in the dictionary.
  5269. * @param key the given key to get the matching value from
  5270. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5271. * The factory will only be invoked if there's no data for the given key.
  5272. * @return the value corresponding to the key.
  5273. */
  5274. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5275. /**
  5276. * Get a value from its key if present in the dictionary otherwise add it
  5277. * @param key the key to get the value from
  5278. * @param val if there's no such key/value pair in the dictionary add it with this value
  5279. * @return the value corresponding to the key
  5280. */
  5281. getOrAdd(key: string, val: T): T;
  5282. /**
  5283. * Check if there's a given key in the dictionary
  5284. * @param key the key to check for
  5285. * @return true if the key is present, false otherwise
  5286. */
  5287. contains(key: string): boolean;
  5288. /**
  5289. * Add a new key and its corresponding value
  5290. * @param key the key to add
  5291. * @param value the value corresponding to the key
  5292. * @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
  5293. */
  5294. add(key: string, value: T): boolean;
  5295. /**
  5296. * Update a specific value associated to a key
  5297. * @param key defines the key to use
  5298. * @param value defines the value to store
  5299. * @returns true if the value was updated (or false if the key was not found)
  5300. */
  5301. set(key: string, value: T): boolean;
  5302. /**
  5303. * Get the element of the given key and remove it from the dictionary
  5304. * @param key defines the key to search
  5305. * @returns the value associated with the key or null if not found
  5306. */
  5307. getAndRemove(key: string): Nullable<T>;
  5308. /**
  5309. * Remove a key/value from the dictionary.
  5310. * @param key the key to remove
  5311. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5312. */
  5313. remove(key: string): boolean;
  5314. /**
  5315. * Clear the whole content of the dictionary
  5316. */
  5317. clear(): void;
  5318. /**
  5319. * Gets the current count
  5320. */
  5321. readonly count: number;
  5322. /**
  5323. * Execute a callback on each key/val of the dictionary.
  5324. * Note that you can remove any element in this dictionary in the callback implementation
  5325. * @param callback the callback to execute on a given key/value pair
  5326. */
  5327. forEach(callback: (key: string, val: T) => void): void;
  5328. /**
  5329. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5330. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5331. * Note that you can remove any element in this dictionary in the callback implementation
  5332. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5333. * @returns the first item
  5334. */
  5335. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5336. private _count;
  5337. private _data;
  5338. }
  5339. }
  5340. declare module "babylonjs/Misc/promise" {
  5341. /**
  5342. * Helper class that provides a small promise polyfill
  5343. */
  5344. export class PromisePolyfill {
  5345. /**
  5346. * Static function used to check if the polyfill is required
  5347. * If this is the case then the function will inject the polyfill to window.Promise
  5348. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5349. */
  5350. static Apply(force?: boolean): void;
  5351. }
  5352. }
  5353. declare module "babylonjs/Meshes/buffer" {
  5354. import { Nullable, DataArray } from "babylonjs/types";
  5355. /**
  5356. * Class used to store data that will be store in GPU memory
  5357. */
  5358. export class Buffer {
  5359. private _engine;
  5360. private _buffer;
  5361. /** @hidden */
  5362. _data: Nullable<DataArray>;
  5363. private _updatable;
  5364. private _instanced;
  5365. /**
  5366. * Gets the byte stride.
  5367. */
  5368. readonly byteStride: number;
  5369. /**
  5370. * Constructor
  5371. * @param engine the engine
  5372. * @param data the data to use for this buffer
  5373. * @param updatable whether the data is updatable
  5374. * @param stride the stride (optional)
  5375. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5376. * @param instanced whether the buffer is instanced (optional)
  5377. * @param useBytes set to true if the stride in in bytes (optional)
  5378. */
  5379. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5380. /**
  5381. * Create a new VertexBuffer based on the current buffer
  5382. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5383. * @param offset defines offset in the buffer (0 by default)
  5384. * @param size defines the size in floats of attributes (position is 3 for instance)
  5385. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5386. * @param instanced defines if the vertex buffer contains indexed data
  5387. * @param useBytes defines if the offset and stride are in bytes
  5388. * @returns the new vertex buffer
  5389. */
  5390. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5391. /**
  5392. * Gets a boolean indicating if the Buffer is updatable?
  5393. * @returns true if the buffer is updatable
  5394. */
  5395. isUpdatable(): boolean;
  5396. /**
  5397. * Gets current buffer's data
  5398. * @returns a DataArray or null
  5399. */
  5400. getData(): Nullable<DataArray>;
  5401. /**
  5402. * Gets underlying native buffer
  5403. * @returns underlying native buffer
  5404. */
  5405. getBuffer(): Nullable<WebGLBuffer>;
  5406. /**
  5407. * Gets the stride in float32 units (i.e. byte stride / 4).
  5408. * May not be an integer if the byte stride is not divisible by 4.
  5409. * DEPRECATED. Use byteStride instead.
  5410. * @returns the stride in float32 units
  5411. */
  5412. getStrideSize(): number;
  5413. /**
  5414. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5415. * @param data defines the data to store
  5416. */
  5417. create(data?: Nullable<DataArray>): void;
  5418. /** @hidden */
  5419. _rebuild(): void;
  5420. /**
  5421. * Update current buffer data
  5422. * @param data defines the data to store
  5423. */
  5424. update(data: DataArray): void;
  5425. /**
  5426. * Updates the data directly.
  5427. * @param data the new data
  5428. * @param offset the new offset
  5429. * @param vertexCount the vertex count (optional)
  5430. * @param useBytes set to true if the offset is in bytes
  5431. */
  5432. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5433. /**
  5434. * Release all resources
  5435. */
  5436. dispose(): void;
  5437. }
  5438. /**
  5439. * Specialized buffer used to store vertex data
  5440. */
  5441. export class VertexBuffer {
  5442. /** @hidden */
  5443. _buffer: Buffer;
  5444. private _kind;
  5445. private _size;
  5446. private _ownsBuffer;
  5447. private _instanced;
  5448. private _instanceDivisor;
  5449. /**
  5450. * The byte type.
  5451. */
  5452. static readonly BYTE: number;
  5453. /**
  5454. * The unsigned byte type.
  5455. */
  5456. static readonly UNSIGNED_BYTE: number;
  5457. /**
  5458. * The short type.
  5459. */
  5460. static readonly SHORT: number;
  5461. /**
  5462. * The unsigned short type.
  5463. */
  5464. static readonly UNSIGNED_SHORT: number;
  5465. /**
  5466. * The integer type.
  5467. */
  5468. static readonly INT: number;
  5469. /**
  5470. * The unsigned integer type.
  5471. */
  5472. static readonly UNSIGNED_INT: number;
  5473. /**
  5474. * The float type.
  5475. */
  5476. static readonly FLOAT: number;
  5477. /**
  5478. * Gets or sets the instance divisor when in instanced mode
  5479. */
  5480. instanceDivisor: number;
  5481. /**
  5482. * Gets the byte stride.
  5483. */
  5484. readonly byteStride: number;
  5485. /**
  5486. * Gets the byte offset.
  5487. */
  5488. readonly byteOffset: number;
  5489. /**
  5490. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5491. */
  5492. readonly normalized: boolean;
  5493. /**
  5494. * Gets the data type of each component in the array.
  5495. */
  5496. readonly type: number;
  5497. /**
  5498. * Constructor
  5499. * @param engine the engine
  5500. * @param data the data to use for this vertex buffer
  5501. * @param kind the vertex buffer kind
  5502. * @param updatable whether the data is updatable
  5503. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5504. * @param stride the stride (optional)
  5505. * @param instanced whether the buffer is instanced (optional)
  5506. * @param offset the offset of the data (optional)
  5507. * @param size the number of components (optional)
  5508. * @param type the type of the component (optional)
  5509. * @param normalized whether the data contains normalized data (optional)
  5510. * @param useBytes set to true if stride and offset are in bytes (optional)
  5511. */
  5512. 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);
  5513. /** @hidden */
  5514. _rebuild(): void;
  5515. /**
  5516. * Returns the kind of the VertexBuffer (string)
  5517. * @returns a string
  5518. */
  5519. getKind(): string;
  5520. /**
  5521. * Gets a boolean indicating if the VertexBuffer is updatable?
  5522. * @returns true if the buffer is updatable
  5523. */
  5524. isUpdatable(): boolean;
  5525. /**
  5526. * Gets current buffer's data
  5527. * @returns a DataArray or null
  5528. */
  5529. getData(): Nullable<DataArray>;
  5530. /**
  5531. * Gets underlying native buffer
  5532. * @returns underlying native buffer
  5533. */
  5534. getBuffer(): Nullable<WebGLBuffer>;
  5535. /**
  5536. * Gets the stride in float32 units (i.e. byte stride / 4).
  5537. * May not be an integer if the byte stride is not divisible by 4.
  5538. * DEPRECATED. Use byteStride instead.
  5539. * @returns the stride in float32 units
  5540. */
  5541. getStrideSize(): number;
  5542. /**
  5543. * Returns the offset as a multiple of the type byte length.
  5544. * DEPRECATED. Use byteOffset instead.
  5545. * @returns the offset in bytes
  5546. */
  5547. getOffset(): number;
  5548. /**
  5549. * Returns the number of components per vertex attribute (integer)
  5550. * @returns the size in float
  5551. */
  5552. getSize(): number;
  5553. /**
  5554. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5555. * @returns true if this buffer is instanced
  5556. */
  5557. getIsInstanced(): boolean;
  5558. /**
  5559. * Returns the instancing divisor, zero for non-instanced (integer).
  5560. * @returns a number
  5561. */
  5562. getInstanceDivisor(): number;
  5563. /**
  5564. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5565. * @param data defines the data to store
  5566. */
  5567. create(data?: DataArray): void;
  5568. /**
  5569. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5570. * This function will create a new buffer if the current one is not updatable
  5571. * @param data defines the data to store
  5572. */
  5573. update(data: DataArray): void;
  5574. /**
  5575. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5576. * Returns the directly updated WebGLBuffer.
  5577. * @param data the new data
  5578. * @param offset the new offset
  5579. * @param useBytes set to true if the offset is in bytes
  5580. */
  5581. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5582. /**
  5583. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5584. */
  5585. dispose(): void;
  5586. /**
  5587. * Enumerates each value of this vertex buffer as numbers.
  5588. * @param count the number of values to enumerate
  5589. * @param callback the callback function called for each value
  5590. */
  5591. forEach(count: number, callback: (value: number, index: number) => void): void;
  5592. /**
  5593. * Positions
  5594. */
  5595. static readonly PositionKind: string;
  5596. /**
  5597. * Normals
  5598. */
  5599. static readonly NormalKind: string;
  5600. /**
  5601. * Tangents
  5602. */
  5603. static readonly TangentKind: string;
  5604. /**
  5605. * Texture coordinates
  5606. */
  5607. static readonly UVKind: string;
  5608. /**
  5609. * Texture coordinates 2
  5610. */
  5611. static readonly UV2Kind: string;
  5612. /**
  5613. * Texture coordinates 3
  5614. */
  5615. static readonly UV3Kind: string;
  5616. /**
  5617. * Texture coordinates 4
  5618. */
  5619. static readonly UV4Kind: string;
  5620. /**
  5621. * Texture coordinates 5
  5622. */
  5623. static readonly UV5Kind: string;
  5624. /**
  5625. * Texture coordinates 6
  5626. */
  5627. static readonly UV6Kind: string;
  5628. /**
  5629. * Colors
  5630. */
  5631. static readonly ColorKind: string;
  5632. /**
  5633. * Matrix indices (for bones)
  5634. */
  5635. static readonly MatricesIndicesKind: string;
  5636. /**
  5637. * Matrix weights (for bones)
  5638. */
  5639. static readonly MatricesWeightsKind: string;
  5640. /**
  5641. * Additional matrix indices (for bones)
  5642. */
  5643. static readonly MatricesIndicesExtraKind: string;
  5644. /**
  5645. * Additional matrix weights (for bones)
  5646. */
  5647. static readonly MatricesWeightsExtraKind: string;
  5648. /**
  5649. * Deduces the stride given a kind.
  5650. * @param kind The kind string to deduce
  5651. * @returns The deduced stride
  5652. */
  5653. static DeduceStride(kind: string): number;
  5654. /**
  5655. * Gets the byte length of the given type.
  5656. * @param type the type
  5657. * @returns the number of bytes
  5658. */
  5659. static GetTypeByteLength(type: number): number;
  5660. /**
  5661. * Enumerates each value of the given parameters as numbers.
  5662. * @param data the data to enumerate
  5663. * @param byteOffset the byte offset of the data
  5664. * @param byteStride the byte stride of the data
  5665. * @param componentCount the number of components per element
  5666. * @param componentType the type of the component
  5667. * @param count the total number of components
  5668. * @param normalized whether the data is normalized
  5669. * @param callback the callback function called for each value
  5670. */
  5671. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5672. private static _GetFloatValue;
  5673. }
  5674. }
  5675. declare module "babylonjs/Maths/sphericalPolynomial" {
  5676. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5677. /**
  5678. * Class representing spherical polynomial coefficients to the 3rd degree
  5679. */
  5680. export class SphericalPolynomial {
  5681. /**
  5682. * The x coefficients of the spherical polynomial
  5683. */
  5684. x: Vector3;
  5685. /**
  5686. * The y coefficients of the spherical polynomial
  5687. */
  5688. y: Vector3;
  5689. /**
  5690. * The z coefficients of the spherical polynomial
  5691. */
  5692. z: Vector3;
  5693. /**
  5694. * The xx coefficients of the spherical polynomial
  5695. */
  5696. xx: Vector3;
  5697. /**
  5698. * The yy coefficients of the spherical polynomial
  5699. */
  5700. yy: Vector3;
  5701. /**
  5702. * The zz coefficients of the spherical polynomial
  5703. */
  5704. zz: Vector3;
  5705. /**
  5706. * The xy coefficients of the spherical polynomial
  5707. */
  5708. xy: Vector3;
  5709. /**
  5710. * The yz coefficients of the spherical polynomial
  5711. */
  5712. yz: Vector3;
  5713. /**
  5714. * The zx coefficients of the spherical polynomial
  5715. */
  5716. zx: Vector3;
  5717. /**
  5718. * Adds an ambient color to the spherical polynomial
  5719. * @param color the color to add
  5720. */
  5721. addAmbient(color: Color3): void;
  5722. /**
  5723. * Scales the spherical polynomial by the given amount
  5724. * @param scale the amount to scale
  5725. */
  5726. scale(scale: number): void;
  5727. /**
  5728. * Gets the spherical polynomial from harmonics
  5729. * @param harmonics the spherical harmonics
  5730. * @returns the spherical polynomial
  5731. */
  5732. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5733. /**
  5734. * Constructs a spherical polynomial from an array.
  5735. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5736. * @returns the spherical polynomial
  5737. */
  5738. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5739. }
  5740. /**
  5741. * Class representing spherical harmonics coefficients to the 3rd degree
  5742. */
  5743. export class SphericalHarmonics {
  5744. /**
  5745. * The l0,0 coefficients of the spherical harmonics
  5746. */
  5747. l00: Vector3;
  5748. /**
  5749. * The l1,-1 coefficients of the spherical harmonics
  5750. */
  5751. l1_1: Vector3;
  5752. /**
  5753. * The l1,0 coefficients of the spherical harmonics
  5754. */
  5755. l10: Vector3;
  5756. /**
  5757. * The l1,1 coefficients of the spherical harmonics
  5758. */
  5759. l11: Vector3;
  5760. /**
  5761. * The l2,-2 coefficients of the spherical harmonics
  5762. */
  5763. l2_2: Vector3;
  5764. /**
  5765. * The l2,-1 coefficients of the spherical harmonics
  5766. */
  5767. l2_1: Vector3;
  5768. /**
  5769. * The l2,0 coefficients of the spherical harmonics
  5770. */
  5771. l20: Vector3;
  5772. /**
  5773. * The l2,1 coefficients of the spherical harmonics
  5774. */
  5775. l21: Vector3;
  5776. /**
  5777. * The l2,2 coefficients of the spherical harmonics
  5778. */
  5779. lL22: Vector3;
  5780. /**
  5781. * Adds a light to the spherical harmonics
  5782. * @param direction the direction of the light
  5783. * @param color the color of the light
  5784. * @param deltaSolidAngle the delta solid angle of the light
  5785. */
  5786. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5787. /**
  5788. * Scales the spherical harmonics by the given amount
  5789. * @param scale the amount to scale
  5790. */
  5791. scale(scale: number): void;
  5792. /**
  5793. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5794. *
  5795. * ```
  5796. * E_lm = A_l * L_lm
  5797. * ```
  5798. *
  5799. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5800. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5801. * the scaling factors are given in equation 9.
  5802. */
  5803. convertIncidentRadianceToIrradiance(): void;
  5804. /**
  5805. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5806. *
  5807. * ```
  5808. * L = (1/pi) * E * rho
  5809. * ```
  5810. *
  5811. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5812. */
  5813. convertIrradianceToLambertianRadiance(): void;
  5814. /**
  5815. * Gets the spherical harmonics from polynomial
  5816. * @param polynomial the spherical polynomial
  5817. * @returns the spherical harmonics
  5818. */
  5819. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5820. /**
  5821. * Constructs a spherical harmonics from an array.
  5822. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5823. * @returns the spherical harmonics
  5824. */
  5825. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5826. }
  5827. }
  5828. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5829. import { Nullable } from "babylonjs/types";
  5830. /**
  5831. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5832. */
  5833. export interface CubeMapInfo {
  5834. /**
  5835. * The pixel array for the front face.
  5836. * This is stored in format, left to right, up to down format.
  5837. */
  5838. front: Nullable<ArrayBufferView>;
  5839. /**
  5840. * The pixel array for the back face.
  5841. * This is stored in format, left to right, up to down format.
  5842. */
  5843. back: Nullable<ArrayBufferView>;
  5844. /**
  5845. * The pixel array for the left face.
  5846. * This is stored in format, left to right, up to down format.
  5847. */
  5848. left: Nullable<ArrayBufferView>;
  5849. /**
  5850. * The pixel array for the right face.
  5851. * This is stored in format, left to right, up to down format.
  5852. */
  5853. right: Nullable<ArrayBufferView>;
  5854. /**
  5855. * The pixel array for the up face.
  5856. * This is stored in format, left to right, up to down format.
  5857. */
  5858. up: Nullable<ArrayBufferView>;
  5859. /**
  5860. * The pixel array for the down face.
  5861. * This is stored in format, left to right, up to down format.
  5862. */
  5863. down: Nullable<ArrayBufferView>;
  5864. /**
  5865. * The size of the cubemap stored.
  5866. *
  5867. * Each faces will be size * size pixels.
  5868. */
  5869. size: number;
  5870. /**
  5871. * The format of the texture.
  5872. *
  5873. * RGBA, RGB.
  5874. */
  5875. format: number;
  5876. /**
  5877. * The type of the texture data.
  5878. *
  5879. * UNSIGNED_INT, FLOAT.
  5880. */
  5881. type: number;
  5882. /**
  5883. * Specifies whether the texture is in gamma space.
  5884. */
  5885. gammaSpace: boolean;
  5886. }
  5887. /**
  5888. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5889. */
  5890. export class PanoramaToCubeMapTools {
  5891. private static FACE_FRONT;
  5892. private static FACE_BACK;
  5893. private static FACE_RIGHT;
  5894. private static FACE_LEFT;
  5895. private static FACE_DOWN;
  5896. private static FACE_UP;
  5897. /**
  5898. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5899. *
  5900. * @param float32Array The source data.
  5901. * @param inputWidth The width of the input panorama.
  5902. * @param inputHeight The height of the input panorama.
  5903. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5904. * @return The cubemap data
  5905. */
  5906. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5907. private static CreateCubemapTexture;
  5908. private static CalcProjectionSpherical;
  5909. }
  5910. }
  5911. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5912. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5913. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5914. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5915. /**
  5916. * Helper class dealing with the extraction of spherical polynomial dataArray
  5917. * from a cube map.
  5918. */
  5919. export class CubeMapToSphericalPolynomialTools {
  5920. private static FileFaces;
  5921. /**
  5922. * Converts a texture to the according Spherical Polynomial data.
  5923. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5924. *
  5925. * @param texture The texture to extract the information from.
  5926. * @return The Spherical Polynomial data.
  5927. */
  5928. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5929. /**
  5930. * Converts a cubemap to the according Spherical Polynomial data.
  5931. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5932. *
  5933. * @param cubeInfo The Cube map to extract the information from.
  5934. * @return The Spherical Polynomial data.
  5935. */
  5936. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5937. }
  5938. }
  5939. declare module "babylonjs/Engines/engineStore" {
  5940. import { Nullable } from "babylonjs/types";
  5941. import { Engine } from "babylonjs/Engines/engine";
  5942. import { Scene } from "babylonjs/scene";
  5943. /**
  5944. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5945. * during the life time of the application.
  5946. */
  5947. export class EngineStore {
  5948. /** Gets the list of created engines */
  5949. static Instances: import("babylonjs/Engines/engine").Engine[];
  5950. /**
  5951. * Gets the latest created engine
  5952. */
  5953. static readonly LastCreatedEngine: Nullable<Engine>;
  5954. /**
  5955. * Gets the latest created scene
  5956. */
  5957. static readonly LastCreatedScene: Nullable<Scene>;
  5958. }
  5959. }
  5960. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5961. /**
  5962. * Define options used to create a render target texture
  5963. */
  5964. export class RenderTargetCreationOptions {
  5965. /**
  5966. * Specifies is mipmaps must be generated
  5967. */
  5968. generateMipMaps?: boolean;
  5969. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5970. generateDepthBuffer?: boolean;
  5971. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5972. generateStencilBuffer?: boolean;
  5973. /** Defines texture type (int by default) */
  5974. type?: number;
  5975. /** Defines sampling mode (trilinear by default) */
  5976. samplingMode?: number;
  5977. /** Defines format (RGBA by default) */
  5978. format?: number;
  5979. }
  5980. }
  5981. declare module "babylonjs/States/alphaCullingState" {
  5982. /**
  5983. * @hidden
  5984. **/
  5985. export class _AlphaState {
  5986. private _isAlphaBlendDirty;
  5987. private _isBlendFunctionParametersDirty;
  5988. private _isBlendEquationParametersDirty;
  5989. private _isBlendConstantsDirty;
  5990. private _alphaBlend;
  5991. private _blendFunctionParameters;
  5992. private _blendEquationParameters;
  5993. private _blendConstants;
  5994. /**
  5995. * Initializes the state.
  5996. */
  5997. constructor();
  5998. readonly isDirty: boolean;
  5999. alphaBlend: boolean;
  6000. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6001. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6002. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6003. reset(): void;
  6004. apply(gl: WebGLRenderingContext): void;
  6005. }
  6006. }
  6007. declare module "babylonjs/States/depthCullingState" {
  6008. import { Nullable } from "babylonjs/types";
  6009. /**
  6010. * @hidden
  6011. **/
  6012. export class _DepthCullingState {
  6013. private _isDepthTestDirty;
  6014. private _isDepthMaskDirty;
  6015. private _isDepthFuncDirty;
  6016. private _isCullFaceDirty;
  6017. private _isCullDirty;
  6018. private _isZOffsetDirty;
  6019. private _isFrontFaceDirty;
  6020. private _depthTest;
  6021. private _depthMask;
  6022. private _depthFunc;
  6023. private _cull;
  6024. private _cullFace;
  6025. private _zOffset;
  6026. private _frontFace;
  6027. /**
  6028. * Initializes the state.
  6029. */
  6030. constructor();
  6031. readonly isDirty: boolean;
  6032. zOffset: number;
  6033. cullFace: Nullable<number>;
  6034. cull: Nullable<boolean>;
  6035. depthFunc: Nullable<number>;
  6036. depthMask: boolean;
  6037. depthTest: boolean;
  6038. frontFace: Nullable<number>;
  6039. reset(): void;
  6040. apply(gl: WebGLRenderingContext): void;
  6041. }
  6042. }
  6043. declare module "babylonjs/States/stencilState" {
  6044. /**
  6045. * @hidden
  6046. **/
  6047. export class _StencilState {
  6048. /** 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 */
  6049. static readonly ALWAYS: number;
  6050. /** Passed to stencilOperation to specify that stencil value must be kept */
  6051. static readonly KEEP: number;
  6052. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6053. static readonly REPLACE: number;
  6054. private _isStencilTestDirty;
  6055. private _isStencilMaskDirty;
  6056. private _isStencilFuncDirty;
  6057. private _isStencilOpDirty;
  6058. private _stencilTest;
  6059. private _stencilMask;
  6060. private _stencilFunc;
  6061. private _stencilFuncRef;
  6062. private _stencilFuncMask;
  6063. private _stencilOpStencilFail;
  6064. private _stencilOpDepthFail;
  6065. private _stencilOpStencilDepthPass;
  6066. readonly isDirty: boolean;
  6067. stencilFunc: number;
  6068. stencilFuncRef: number;
  6069. stencilFuncMask: number;
  6070. stencilOpStencilFail: number;
  6071. stencilOpDepthFail: number;
  6072. stencilOpStencilDepthPass: number;
  6073. stencilMask: number;
  6074. stencilTest: boolean;
  6075. constructor();
  6076. reset(): void;
  6077. apply(gl: WebGLRenderingContext): void;
  6078. }
  6079. }
  6080. declare module "babylonjs/States/index" {
  6081. export * from "babylonjs/States/alphaCullingState";
  6082. export * from "babylonjs/States/depthCullingState";
  6083. export * from "babylonjs/States/stencilState";
  6084. }
  6085. declare module "babylonjs/Instrumentation/timeToken" {
  6086. import { Nullable } from "babylonjs/types";
  6087. /**
  6088. * @hidden
  6089. **/
  6090. export class _TimeToken {
  6091. _startTimeQuery: Nullable<WebGLQuery>;
  6092. _endTimeQuery: Nullable<WebGLQuery>;
  6093. _timeElapsedQuery: Nullable<WebGLQuery>;
  6094. _timeElapsedQueryEnded: boolean;
  6095. }
  6096. }
  6097. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6098. import { Nullable } from "babylonjs/types";
  6099. /**
  6100. * Internal interface used to track InternalTexture already bound to the GL context
  6101. */
  6102. export interface IInternalTextureTracker {
  6103. /**
  6104. * Gets or set the previous tracker in the list
  6105. */
  6106. previous: Nullable<IInternalTextureTracker>;
  6107. /**
  6108. * Gets or set the next tracker in the list
  6109. */
  6110. next: Nullable<IInternalTextureTracker>;
  6111. }
  6112. /**
  6113. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6114. */
  6115. export class DummyInternalTextureTracker {
  6116. /**
  6117. * Gets or set the previous tracker in the list
  6118. */
  6119. previous: Nullable<IInternalTextureTracker>;
  6120. /**
  6121. * Gets or set the next tracker in the list
  6122. */
  6123. next: Nullable<IInternalTextureTracker>;
  6124. }
  6125. }
  6126. declare module "babylonjs/Materials/Textures/internalTexture" {
  6127. import { Observable } from "babylonjs/Misc/observable";
  6128. import { Nullable, int } from "babylonjs/types";
  6129. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6130. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6131. import { Engine } from "babylonjs/Engines/engine";
  6132. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6133. /**
  6134. * Class used to store data associated with WebGL texture data for the engine
  6135. * This class should not be used directly
  6136. */
  6137. export class InternalTexture implements IInternalTextureTracker {
  6138. /** hidden */
  6139. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6140. /**
  6141. * The source of the texture data is unknown
  6142. */
  6143. static DATASOURCE_UNKNOWN: number;
  6144. /**
  6145. * Texture data comes from an URL
  6146. */
  6147. static DATASOURCE_URL: number;
  6148. /**
  6149. * Texture data is only used for temporary storage
  6150. */
  6151. static DATASOURCE_TEMP: number;
  6152. /**
  6153. * Texture data comes from raw data (ArrayBuffer)
  6154. */
  6155. static DATASOURCE_RAW: number;
  6156. /**
  6157. * Texture content is dynamic (video or dynamic texture)
  6158. */
  6159. static DATASOURCE_DYNAMIC: number;
  6160. /**
  6161. * Texture content is generated by rendering to it
  6162. */
  6163. static DATASOURCE_RENDERTARGET: number;
  6164. /**
  6165. * Texture content is part of a multi render target process
  6166. */
  6167. static DATASOURCE_MULTIRENDERTARGET: number;
  6168. /**
  6169. * Texture data comes from a cube data file
  6170. */
  6171. static DATASOURCE_CUBE: number;
  6172. /**
  6173. * Texture data comes from a raw cube data
  6174. */
  6175. static DATASOURCE_CUBERAW: number;
  6176. /**
  6177. * Texture data come from a prefiltered cube data file
  6178. */
  6179. static DATASOURCE_CUBEPREFILTERED: number;
  6180. /**
  6181. * Texture content is raw 3D data
  6182. */
  6183. static DATASOURCE_RAW3D: number;
  6184. /**
  6185. * Texture content is a depth texture
  6186. */
  6187. static DATASOURCE_DEPTHTEXTURE: number;
  6188. /**
  6189. * Texture data comes from a raw cube data encoded with RGBD
  6190. */
  6191. static DATASOURCE_CUBERAW_RGBD: number;
  6192. /**
  6193. * Defines if the texture is ready
  6194. */
  6195. isReady: boolean;
  6196. /**
  6197. * Defines if the texture is a cube texture
  6198. */
  6199. isCube: boolean;
  6200. /**
  6201. * Defines if the texture contains 3D data
  6202. */
  6203. is3D: boolean;
  6204. /**
  6205. * Gets the URL used to load this texture
  6206. */
  6207. url: string;
  6208. /**
  6209. * Gets the sampling mode of the texture
  6210. */
  6211. samplingMode: number;
  6212. /**
  6213. * Gets a boolean indicating if the texture needs mipmaps generation
  6214. */
  6215. generateMipMaps: boolean;
  6216. /**
  6217. * Gets the number of samples used by the texture (WebGL2+ only)
  6218. */
  6219. samples: number;
  6220. /**
  6221. * Gets the type of the texture (int, float...)
  6222. */
  6223. type: number;
  6224. /**
  6225. * Gets the format of the texture (RGB, RGBA...)
  6226. */
  6227. format: number;
  6228. /**
  6229. * Observable called when the texture is loaded
  6230. */
  6231. onLoadedObservable: Observable<InternalTexture>;
  6232. /**
  6233. * Gets the width of the texture
  6234. */
  6235. width: number;
  6236. /**
  6237. * Gets the height of the texture
  6238. */
  6239. height: number;
  6240. /**
  6241. * Gets the depth of the texture
  6242. */
  6243. depth: number;
  6244. /**
  6245. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6246. */
  6247. baseWidth: number;
  6248. /**
  6249. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6250. */
  6251. baseHeight: number;
  6252. /**
  6253. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6254. */
  6255. baseDepth: number;
  6256. /**
  6257. * Gets a boolean indicating if the texture is inverted on Y axis
  6258. */
  6259. invertY: boolean;
  6260. /**
  6261. * Gets or set the previous tracker in the list
  6262. */
  6263. previous: Nullable<IInternalTextureTracker>;
  6264. /**
  6265. * Gets or set the next tracker in the list
  6266. */
  6267. next: Nullable<IInternalTextureTracker>;
  6268. /** @hidden */
  6269. _invertVScale: boolean;
  6270. /** @hidden */
  6271. _initialSlot: number;
  6272. /** @hidden */
  6273. _designatedSlot: number;
  6274. /** @hidden */
  6275. _dataSource: number;
  6276. /** @hidden */
  6277. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6278. /** @hidden */
  6279. _bufferView: Nullable<ArrayBufferView>;
  6280. /** @hidden */
  6281. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6282. /** @hidden */
  6283. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6284. /** @hidden */
  6285. _size: number;
  6286. /** @hidden */
  6287. _extension: string;
  6288. /** @hidden */
  6289. _files: Nullable<string[]>;
  6290. /** @hidden */
  6291. _workingCanvas: HTMLCanvasElement;
  6292. /** @hidden */
  6293. _workingContext: CanvasRenderingContext2D;
  6294. /** @hidden */
  6295. _framebuffer: Nullable<WebGLFramebuffer>;
  6296. /** @hidden */
  6297. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6298. /** @hidden */
  6299. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6300. /** @hidden */
  6301. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6302. /** @hidden */
  6303. _attachments: Nullable<number[]>;
  6304. /** @hidden */
  6305. _cachedCoordinatesMode: Nullable<number>;
  6306. /** @hidden */
  6307. _cachedWrapU: Nullable<number>;
  6308. /** @hidden */
  6309. _cachedWrapV: Nullable<number>;
  6310. /** @hidden */
  6311. _cachedWrapR: Nullable<number>;
  6312. /** @hidden */
  6313. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6314. /** @hidden */
  6315. _isDisabled: boolean;
  6316. /** @hidden */
  6317. _compression: Nullable<string>;
  6318. /** @hidden */
  6319. _generateStencilBuffer: boolean;
  6320. /** @hidden */
  6321. _generateDepthBuffer: boolean;
  6322. /** @hidden */
  6323. _comparisonFunction: number;
  6324. /** @hidden */
  6325. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6326. /** @hidden */
  6327. _lodGenerationScale: number;
  6328. /** @hidden */
  6329. _lodGenerationOffset: number;
  6330. /** @hidden */
  6331. _lodTextureHigh: BaseTexture;
  6332. /** @hidden */
  6333. _lodTextureMid: BaseTexture;
  6334. /** @hidden */
  6335. _lodTextureLow: BaseTexture;
  6336. /** @hidden */
  6337. _isRGBD: boolean;
  6338. /** @hidden */
  6339. _webGLTexture: Nullable<WebGLTexture>;
  6340. /** @hidden */
  6341. _references: number;
  6342. private _engine;
  6343. /**
  6344. * Gets the Engine the texture belongs to.
  6345. * @returns The babylon engine
  6346. */
  6347. getEngine(): Engine;
  6348. /**
  6349. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6350. */
  6351. readonly dataSource: number;
  6352. /**
  6353. * Creates a new InternalTexture
  6354. * @param engine defines the engine to use
  6355. * @param dataSource defines the type of data that will be used
  6356. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6357. */
  6358. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6359. /**
  6360. * Increments the number of references (ie. the number of Texture that point to it)
  6361. */
  6362. incrementReferences(): void;
  6363. /**
  6364. * Change the size of the texture (not the size of the content)
  6365. * @param width defines the new width
  6366. * @param height defines the new height
  6367. * @param depth defines the new depth (1 by default)
  6368. */
  6369. updateSize(width: int, height: int, depth?: int): void;
  6370. /** @hidden */
  6371. _rebuild(): void;
  6372. /** @hidden */
  6373. _swapAndDie(target: InternalTexture): void;
  6374. /**
  6375. * Dispose the current allocated resources
  6376. */
  6377. dispose(): void;
  6378. }
  6379. }
  6380. declare module "babylonjs/Animations/easing" {
  6381. /**
  6382. * This represents the main contract an easing function should follow.
  6383. * Easing functions are used throughout the animation system.
  6384. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6385. */
  6386. export interface IEasingFunction {
  6387. /**
  6388. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6389. * of the easing function.
  6390. * The link below provides some of the most common examples of easing functions.
  6391. * @see https://easings.net/
  6392. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6393. * @returns the corresponding value on the curve defined by the easing function
  6394. */
  6395. ease(gradient: number): number;
  6396. }
  6397. /**
  6398. * Base class used for every default easing function.
  6399. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6400. */
  6401. export class EasingFunction implements IEasingFunction {
  6402. /**
  6403. * Interpolation follows the mathematical formula associated with the easing function.
  6404. */
  6405. static readonly EASINGMODE_EASEIN: number;
  6406. /**
  6407. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6408. */
  6409. static readonly EASINGMODE_EASEOUT: number;
  6410. /**
  6411. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6412. */
  6413. static readonly EASINGMODE_EASEINOUT: number;
  6414. private _easingMode;
  6415. /**
  6416. * Sets the easing mode of the current function.
  6417. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6418. */
  6419. setEasingMode(easingMode: number): void;
  6420. /**
  6421. * Gets the current easing mode.
  6422. * @returns the easing mode
  6423. */
  6424. getEasingMode(): number;
  6425. /**
  6426. * @hidden
  6427. */
  6428. easeInCore(gradient: number): number;
  6429. /**
  6430. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6431. * of the easing function.
  6432. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6433. * @returns the corresponding value on the curve defined by the easing function
  6434. */
  6435. ease(gradient: number): number;
  6436. }
  6437. /**
  6438. * Easing function with a circle shape (see link below).
  6439. * @see https://easings.net/#easeInCirc
  6440. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6441. */
  6442. export class CircleEase extends EasingFunction implements IEasingFunction {
  6443. /** @hidden */
  6444. easeInCore(gradient: number): number;
  6445. }
  6446. /**
  6447. * Easing function with a ease back shape (see link below).
  6448. * @see https://easings.net/#easeInBack
  6449. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6450. */
  6451. export class BackEase extends EasingFunction implements IEasingFunction {
  6452. /** Defines the amplitude of the function */
  6453. amplitude: number;
  6454. /**
  6455. * Instantiates a back ease easing
  6456. * @see https://easings.net/#easeInBack
  6457. * @param amplitude Defines the amplitude of the function
  6458. */
  6459. constructor(
  6460. /** Defines the amplitude of the function */
  6461. amplitude?: number);
  6462. /** @hidden */
  6463. easeInCore(gradient: number): number;
  6464. }
  6465. /**
  6466. * Easing function with a bouncing shape (see link below).
  6467. * @see https://easings.net/#easeInBounce
  6468. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6469. */
  6470. export class BounceEase extends EasingFunction implements IEasingFunction {
  6471. /** Defines the number of bounces */
  6472. bounces: number;
  6473. /** Defines the amplitude of the bounce */
  6474. bounciness: number;
  6475. /**
  6476. * Instantiates a bounce easing
  6477. * @see https://easings.net/#easeInBounce
  6478. * @param bounces Defines the number of bounces
  6479. * @param bounciness Defines the amplitude of the bounce
  6480. */
  6481. constructor(
  6482. /** Defines the number of bounces */
  6483. bounces?: number,
  6484. /** Defines the amplitude of the bounce */
  6485. bounciness?: number);
  6486. /** @hidden */
  6487. easeInCore(gradient: number): number;
  6488. }
  6489. /**
  6490. * Easing function with a power of 3 shape (see link below).
  6491. * @see https://easings.net/#easeInCubic
  6492. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6493. */
  6494. export class CubicEase extends EasingFunction implements IEasingFunction {
  6495. /** @hidden */
  6496. easeInCore(gradient: number): number;
  6497. }
  6498. /**
  6499. * Easing function with an elastic shape (see link below).
  6500. * @see https://easings.net/#easeInElastic
  6501. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6502. */
  6503. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6504. /** Defines the number of oscillations*/
  6505. oscillations: number;
  6506. /** Defines the amplitude of the oscillations*/
  6507. springiness: number;
  6508. /**
  6509. * Instantiates an elastic easing function
  6510. * @see https://easings.net/#easeInElastic
  6511. * @param oscillations Defines the number of oscillations
  6512. * @param springiness Defines the amplitude of the oscillations
  6513. */
  6514. constructor(
  6515. /** Defines the number of oscillations*/
  6516. oscillations?: number,
  6517. /** Defines the amplitude of the oscillations*/
  6518. springiness?: number);
  6519. /** @hidden */
  6520. easeInCore(gradient: number): number;
  6521. }
  6522. /**
  6523. * Easing function with an exponential shape (see link below).
  6524. * @see https://easings.net/#easeInExpo
  6525. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6526. */
  6527. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6528. /** Defines the exponent of the function */
  6529. exponent: number;
  6530. /**
  6531. * Instantiates an exponential easing function
  6532. * @see https://easings.net/#easeInExpo
  6533. * @param exponent Defines the exponent of the function
  6534. */
  6535. constructor(
  6536. /** Defines the exponent of the function */
  6537. exponent?: number);
  6538. /** @hidden */
  6539. easeInCore(gradient: number): number;
  6540. }
  6541. /**
  6542. * Easing function with a power shape (see link below).
  6543. * @see https://easings.net/#easeInQuad
  6544. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6545. */
  6546. export class PowerEase extends EasingFunction implements IEasingFunction {
  6547. /** Defines the power of the function */
  6548. power: number;
  6549. /**
  6550. * Instantiates an power base easing function
  6551. * @see https://easings.net/#easeInQuad
  6552. * @param power Defines the power of the function
  6553. */
  6554. constructor(
  6555. /** Defines the power of the function */
  6556. power?: number);
  6557. /** @hidden */
  6558. easeInCore(gradient: number): number;
  6559. }
  6560. /**
  6561. * Easing function with a power of 2 shape (see link below).
  6562. * @see https://easings.net/#easeInQuad
  6563. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6564. */
  6565. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6566. /** @hidden */
  6567. easeInCore(gradient: number): number;
  6568. }
  6569. /**
  6570. * Easing function with a power of 4 shape (see link below).
  6571. * @see https://easings.net/#easeInQuart
  6572. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6573. */
  6574. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6575. /** @hidden */
  6576. easeInCore(gradient: number): number;
  6577. }
  6578. /**
  6579. * Easing function with a power of 5 shape (see link below).
  6580. * @see https://easings.net/#easeInQuint
  6581. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6582. */
  6583. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6584. /** @hidden */
  6585. easeInCore(gradient: number): number;
  6586. }
  6587. /**
  6588. * Easing function with a sin shape (see link below).
  6589. * @see https://easings.net/#easeInSine
  6590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6591. */
  6592. export class SineEase extends EasingFunction implements IEasingFunction {
  6593. /** @hidden */
  6594. easeInCore(gradient: number): number;
  6595. }
  6596. /**
  6597. * Easing function with a bezier shape (see link below).
  6598. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6599. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6600. */
  6601. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6602. /** Defines the x component of the start tangent in the bezier curve */
  6603. x1: number;
  6604. /** Defines the y component of the start tangent in the bezier curve */
  6605. y1: number;
  6606. /** Defines the x component of the end tangent in the bezier curve */
  6607. x2: number;
  6608. /** Defines the y component of the end tangent in the bezier curve */
  6609. y2: number;
  6610. /**
  6611. * Instantiates a bezier function
  6612. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6613. * @param x1 Defines the x component of the start tangent in the bezier curve
  6614. * @param y1 Defines the y component of the start tangent in the bezier curve
  6615. * @param x2 Defines the x component of the end tangent in the bezier curve
  6616. * @param y2 Defines the y component of the end tangent in the bezier curve
  6617. */
  6618. constructor(
  6619. /** Defines the x component of the start tangent in the bezier curve */
  6620. x1?: number,
  6621. /** Defines the y component of the start tangent in the bezier curve */
  6622. y1?: number,
  6623. /** Defines the x component of the end tangent in the bezier curve */
  6624. x2?: number,
  6625. /** Defines the y component of the end tangent in the bezier curve */
  6626. y2?: number);
  6627. /** @hidden */
  6628. easeInCore(gradient: number): number;
  6629. }
  6630. }
  6631. declare module "babylonjs/Animations/animationKey" {
  6632. /**
  6633. * Defines an interface which represents an animation key frame
  6634. */
  6635. export interface IAnimationKey {
  6636. /**
  6637. * Frame of the key frame
  6638. */
  6639. frame: number;
  6640. /**
  6641. * Value at the specifies key frame
  6642. */
  6643. value: any;
  6644. /**
  6645. * The input tangent for the cubic hermite spline
  6646. */
  6647. inTangent?: any;
  6648. /**
  6649. * The output tangent for the cubic hermite spline
  6650. */
  6651. outTangent?: any;
  6652. /**
  6653. * The animation interpolation type
  6654. */
  6655. interpolation?: AnimationKeyInterpolation;
  6656. }
  6657. /**
  6658. * Enum for the animation key frame interpolation type
  6659. */
  6660. export enum AnimationKeyInterpolation {
  6661. /**
  6662. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6663. */
  6664. STEP = 1
  6665. }
  6666. }
  6667. declare module "babylonjs/Animations/animationRange" {
  6668. /**
  6669. * Represents the range of an animation
  6670. */
  6671. export class AnimationRange {
  6672. /**The name of the animation range**/
  6673. name: string;
  6674. /**The starting frame of the animation */
  6675. from: number;
  6676. /**The ending frame of the animation*/
  6677. to: number;
  6678. /**
  6679. * Initializes the range of an animation
  6680. * @param name The name of the animation range
  6681. * @param from The starting frame of the animation
  6682. * @param to The ending frame of the animation
  6683. */
  6684. constructor(
  6685. /**The name of the animation range**/
  6686. name: string,
  6687. /**The starting frame of the animation */
  6688. from: number,
  6689. /**The ending frame of the animation*/
  6690. to: number);
  6691. /**
  6692. * Makes a copy of the animation range
  6693. * @returns A copy of the animation range
  6694. */
  6695. clone(): AnimationRange;
  6696. }
  6697. }
  6698. declare module "babylonjs/Animations/animationEvent" {
  6699. /**
  6700. * Composed of a frame, and an action function
  6701. */
  6702. export class AnimationEvent {
  6703. /** The frame for which the event is triggered **/
  6704. frame: number;
  6705. /** The event to perform when triggered **/
  6706. action: (currentFrame: number) => void;
  6707. /** Specifies if the event should be triggered only once**/
  6708. onlyOnce?: boolean | undefined;
  6709. /**
  6710. * Specifies if the animation event is done
  6711. */
  6712. isDone: boolean;
  6713. /**
  6714. * Initializes the animation event
  6715. * @param frame The frame for which the event is triggered
  6716. * @param action The event to perform when triggered
  6717. * @param onlyOnce Specifies if the event should be triggered only once
  6718. */
  6719. constructor(
  6720. /** The frame for which the event is triggered **/
  6721. frame: number,
  6722. /** The event to perform when triggered **/
  6723. action: (currentFrame: number) => void,
  6724. /** Specifies if the event should be triggered only once**/
  6725. onlyOnce?: boolean | undefined);
  6726. /** @hidden */
  6727. _clone(): AnimationEvent;
  6728. }
  6729. }
  6730. declare module "babylonjs/Behaviors/behavior" {
  6731. import { Nullable } from "babylonjs/types";
  6732. /**
  6733. * Interface used to define a behavior
  6734. */
  6735. export interface Behavior<T> {
  6736. /** gets or sets behavior's name */
  6737. name: string;
  6738. /**
  6739. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6740. */
  6741. init(): void;
  6742. /**
  6743. * Called when the behavior is attached to a target
  6744. * @param target defines the target where the behavior is attached to
  6745. */
  6746. attach(target: T): void;
  6747. /**
  6748. * Called when the behavior is detached from its target
  6749. */
  6750. detach(): void;
  6751. }
  6752. /**
  6753. * Interface implemented by classes supporting behaviors
  6754. */
  6755. export interface IBehaviorAware<T> {
  6756. /**
  6757. * Attach a behavior
  6758. * @param behavior defines the behavior to attach
  6759. * @returns the current host
  6760. */
  6761. addBehavior(behavior: Behavior<T>): T;
  6762. /**
  6763. * Remove a behavior from the current object
  6764. * @param behavior defines the behavior to detach
  6765. * @returns the current host
  6766. */
  6767. removeBehavior(behavior: Behavior<T>): T;
  6768. /**
  6769. * Gets a behavior using its name to search
  6770. * @param name defines the name to search
  6771. * @returns the behavior or null if not found
  6772. */
  6773. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6774. }
  6775. }
  6776. declare module "babylonjs/Collisions/intersectionInfo" {
  6777. import { Nullable } from "babylonjs/types";
  6778. /**
  6779. * @hidden
  6780. */
  6781. export class IntersectionInfo {
  6782. bu: Nullable<number>;
  6783. bv: Nullable<number>;
  6784. distance: number;
  6785. faceId: number;
  6786. subMeshId: number;
  6787. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6788. }
  6789. }
  6790. declare module "babylonjs/Culling/boundingSphere" {
  6791. import { DeepImmutable } from "babylonjs/types";
  6792. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6793. /**
  6794. * Class used to store bounding sphere information
  6795. */
  6796. export class BoundingSphere {
  6797. /**
  6798. * Gets the center of the bounding sphere in local space
  6799. */
  6800. readonly center: Vector3;
  6801. /**
  6802. * Radius of the bounding sphere in local space
  6803. */
  6804. radius: number;
  6805. /**
  6806. * Gets the center of the bounding sphere in world space
  6807. */
  6808. readonly centerWorld: Vector3;
  6809. /**
  6810. * Radius of the bounding sphere in world space
  6811. */
  6812. radiusWorld: number;
  6813. /**
  6814. * Gets the minimum vector in local space
  6815. */
  6816. readonly minimum: Vector3;
  6817. /**
  6818. * Gets the maximum vector in local space
  6819. */
  6820. readonly maximum: Vector3;
  6821. private _worldMatrix;
  6822. private static readonly TmpVector3;
  6823. /**
  6824. * Creates a new bounding sphere
  6825. * @param min defines the minimum vector (in local space)
  6826. * @param max defines the maximum vector (in local space)
  6827. * @param worldMatrix defines the new world matrix
  6828. */
  6829. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6830. /**
  6831. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6832. * @param min defines the new minimum vector (in local space)
  6833. * @param max defines the new maximum vector (in local space)
  6834. * @param worldMatrix defines the new world matrix
  6835. */
  6836. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6837. /**
  6838. * Scale the current bounding sphere by applying a scale factor
  6839. * @param factor defines the scale factor to apply
  6840. * @returns the current bounding box
  6841. */
  6842. scale(factor: number): BoundingSphere;
  6843. /**
  6844. * Gets the world matrix of the bounding box
  6845. * @returns a matrix
  6846. */
  6847. getWorldMatrix(): DeepImmutable<Matrix>;
  6848. /** @hidden */
  6849. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6850. /**
  6851. * Tests if the bounding sphere is intersecting the frustum planes
  6852. * @param frustumPlanes defines the frustum planes to test
  6853. * @returns true if there is an intersection
  6854. */
  6855. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6856. /**
  6857. * Tests if the bounding sphere center is in between the frustum planes.
  6858. * Used for optimistic fast inclusion.
  6859. * @param frustumPlanes defines the frustum planes to test
  6860. * @returns true if the sphere center is in between the frustum planes
  6861. */
  6862. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6863. /**
  6864. * Tests if a point is inside the bounding sphere
  6865. * @param point defines the point to test
  6866. * @returns true if the point is inside the bounding sphere
  6867. */
  6868. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6869. /**
  6870. * Checks if two sphere intersct
  6871. * @param sphere0 sphere 0
  6872. * @param sphere1 sphere 1
  6873. * @returns true if the speres intersect
  6874. */
  6875. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6876. }
  6877. }
  6878. declare module "babylonjs/Culling/boundingBox" {
  6879. import { DeepImmutable } from "babylonjs/types";
  6880. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6881. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6882. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6883. /**
  6884. * Class used to store bounding box information
  6885. */
  6886. export class BoundingBox implements ICullable {
  6887. /**
  6888. * Gets the 8 vectors representing the bounding box in local space
  6889. */
  6890. readonly vectors: Vector3[];
  6891. /**
  6892. * Gets the center of the bounding box in local space
  6893. */
  6894. readonly center: Vector3;
  6895. /**
  6896. * Gets the center of the bounding box in world space
  6897. */
  6898. readonly centerWorld: Vector3;
  6899. /**
  6900. * Gets the extend size in local space
  6901. */
  6902. readonly extendSize: Vector3;
  6903. /**
  6904. * Gets the extend size in world space
  6905. */
  6906. readonly extendSizeWorld: Vector3;
  6907. /**
  6908. * Gets the OBB (object bounding box) directions
  6909. */
  6910. readonly directions: Vector3[];
  6911. /**
  6912. * Gets the 8 vectors representing the bounding box in world space
  6913. */
  6914. readonly vectorsWorld: Vector3[];
  6915. /**
  6916. * Gets the minimum vector in world space
  6917. */
  6918. readonly minimumWorld: Vector3;
  6919. /**
  6920. * Gets the maximum vector in world space
  6921. */
  6922. readonly maximumWorld: Vector3;
  6923. /**
  6924. * Gets the minimum vector in local space
  6925. */
  6926. readonly minimum: Vector3;
  6927. /**
  6928. * Gets the maximum vector in local space
  6929. */
  6930. readonly maximum: Vector3;
  6931. private _worldMatrix;
  6932. private static readonly TmpVector3;
  6933. /**
  6934. * @hidden
  6935. */
  6936. _tag: number;
  6937. /**
  6938. * Creates a new bounding box
  6939. * @param min defines the minimum vector (in local space)
  6940. * @param max defines the maximum vector (in local space)
  6941. * @param worldMatrix defines the new world matrix
  6942. */
  6943. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6944. /**
  6945. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6946. * @param min defines the new minimum vector (in local space)
  6947. * @param max defines the new maximum vector (in local space)
  6948. * @param worldMatrix defines the new world matrix
  6949. */
  6950. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6951. /**
  6952. * Scale the current bounding box by applying a scale factor
  6953. * @param factor defines the scale factor to apply
  6954. * @returns the current bounding box
  6955. */
  6956. scale(factor: number): BoundingBox;
  6957. /**
  6958. * Gets the world matrix of the bounding box
  6959. * @returns a matrix
  6960. */
  6961. getWorldMatrix(): DeepImmutable<Matrix>;
  6962. /** @hidden */
  6963. _update(world: DeepImmutable<Matrix>): void;
  6964. /**
  6965. * Tests if the bounding box is intersecting the frustum planes
  6966. * @param frustumPlanes defines the frustum planes to test
  6967. * @returns true if there is an intersection
  6968. */
  6969. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6970. /**
  6971. * Tests if the bounding box is entirely inside the frustum planes
  6972. * @param frustumPlanes defines the frustum planes to test
  6973. * @returns true if there is an inclusion
  6974. */
  6975. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6976. /**
  6977. * Tests if a point is inside the bounding box
  6978. * @param point defines the point to test
  6979. * @returns true if the point is inside the bounding box
  6980. */
  6981. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6982. /**
  6983. * Tests if the bounding box intersects with a bounding sphere
  6984. * @param sphere defines the sphere to test
  6985. * @returns true if there is an intersection
  6986. */
  6987. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6988. /**
  6989. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6990. * @param min defines the min vector to use
  6991. * @param max defines the max vector to use
  6992. * @returns true if there is an intersection
  6993. */
  6994. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6995. /**
  6996. * Tests if two bounding boxes are intersections
  6997. * @param box0 defines the first box to test
  6998. * @param box1 defines the second box to test
  6999. * @returns true if there is an intersection
  7000. */
  7001. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7002. /**
  7003. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7004. * @param minPoint defines the minimum vector of the bounding box
  7005. * @param maxPoint defines the maximum vector of the bounding box
  7006. * @param sphereCenter defines the sphere center
  7007. * @param sphereRadius defines the sphere radius
  7008. * @returns true if there is an intersection
  7009. */
  7010. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7011. /**
  7012. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7013. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7014. * @param frustumPlanes defines the frustum planes to test
  7015. * @return true if there is an inclusion
  7016. */
  7017. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7018. /**
  7019. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7020. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7021. * @param frustumPlanes defines the frustum planes to test
  7022. * @return true if there is an intersection
  7023. */
  7024. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7025. }
  7026. }
  7027. declare module "babylonjs/Collisions/collider" {
  7028. import { Nullable, IndicesArray } from "babylonjs/types";
  7029. import { Vector3, Plane } from "babylonjs/Maths/math";
  7030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7031. /** @hidden */
  7032. export class Collider {
  7033. /** Define if a collision was found */
  7034. collisionFound: boolean;
  7035. /**
  7036. * Define last intersection point in local space
  7037. */
  7038. intersectionPoint: Vector3;
  7039. /**
  7040. * Define last collided mesh
  7041. */
  7042. collidedMesh: Nullable<AbstractMesh>;
  7043. private _collisionPoint;
  7044. private _planeIntersectionPoint;
  7045. private _tempVector;
  7046. private _tempVector2;
  7047. private _tempVector3;
  7048. private _tempVector4;
  7049. private _edge;
  7050. private _baseToVertex;
  7051. private _destinationPoint;
  7052. private _slidePlaneNormal;
  7053. private _displacementVector;
  7054. /** @hidden */
  7055. _radius: Vector3;
  7056. /** @hidden */
  7057. _retry: number;
  7058. private _velocity;
  7059. private _basePoint;
  7060. private _epsilon;
  7061. /** @hidden */
  7062. _velocityWorldLength: number;
  7063. /** @hidden */
  7064. _basePointWorld: Vector3;
  7065. private _velocityWorld;
  7066. private _normalizedVelocity;
  7067. /** @hidden */
  7068. _initialVelocity: Vector3;
  7069. /** @hidden */
  7070. _initialPosition: Vector3;
  7071. private _nearestDistance;
  7072. private _collisionMask;
  7073. collisionMask: number;
  7074. /**
  7075. * Gets the plane normal used to compute the sliding response (in local space)
  7076. */
  7077. readonly slidePlaneNormal: Vector3;
  7078. /** @hidden */
  7079. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7080. /** @hidden */
  7081. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7082. /** @hidden */
  7083. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7084. /** @hidden */
  7085. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7086. /** @hidden */
  7087. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7088. /** @hidden */
  7089. _getResponse(pos: Vector3, vel: Vector3): void;
  7090. }
  7091. }
  7092. declare module "babylonjs/Culling/boundingInfo" {
  7093. import { DeepImmutable } from "babylonjs/types";
  7094. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7095. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7096. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7097. import { Collider } from "babylonjs/Collisions/collider";
  7098. /**
  7099. * Interface for cullable objects
  7100. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7101. */
  7102. export interface ICullable {
  7103. /**
  7104. * Checks if the object or part of the object is in the frustum
  7105. * @param frustumPlanes Camera near/planes
  7106. * @returns true if the object is in frustum otherwise false
  7107. */
  7108. isInFrustum(frustumPlanes: Plane[]): boolean;
  7109. /**
  7110. * Checks if a cullable object (mesh...) is in the camera frustum
  7111. * Unlike isInFrustum this cheks the full bounding box
  7112. * @param frustumPlanes Camera near/planes
  7113. * @returns true if the object is in frustum otherwise false
  7114. */
  7115. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7116. }
  7117. /**
  7118. * Info for a bounding data of a mesh
  7119. */
  7120. export class BoundingInfo implements ICullable {
  7121. /**
  7122. * Bounding box for the mesh
  7123. */
  7124. readonly boundingBox: BoundingBox;
  7125. /**
  7126. * Bounding sphere for the mesh
  7127. */
  7128. readonly boundingSphere: BoundingSphere;
  7129. private _isLocked;
  7130. private static readonly TmpVector3;
  7131. /**
  7132. * Constructs bounding info
  7133. * @param minimum min vector of the bounding box/sphere
  7134. * @param maximum max vector of the bounding box/sphere
  7135. * @param worldMatrix defines the new world matrix
  7136. */
  7137. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7138. /**
  7139. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7140. * @param min defines the new minimum vector (in local space)
  7141. * @param max defines the new maximum vector (in local space)
  7142. * @param worldMatrix defines the new world matrix
  7143. */
  7144. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7145. /**
  7146. * min vector of the bounding box/sphere
  7147. */
  7148. readonly minimum: Vector3;
  7149. /**
  7150. * max vector of the bounding box/sphere
  7151. */
  7152. readonly maximum: Vector3;
  7153. /**
  7154. * If the info is locked and won't be updated to avoid perf overhead
  7155. */
  7156. isLocked: boolean;
  7157. /**
  7158. * Updates the bounding sphere and box
  7159. * @param world world matrix to be used to update
  7160. */
  7161. update(world: DeepImmutable<Matrix>): void;
  7162. /**
  7163. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7164. * @param center New center of the bounding info
  7165. * @param extend New extend of the bounding info
  7166. * @returns the current bounding info
  7167. */
  7168. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7169. /**
  7170. * Scale the current bounding info by applying a scale factor
  7171. * @param factor defines the scale factor to apply
  7172. * @returns the current bounding info
  7173. */
  7174. scale(factor: number): BoundingInfo;
  7175. /**
  7176. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7177. * @param frustumPlanes defines the frustum to test
  7178. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7179. * @returns true if the bounding info is in the frustum planes
  7180. */
  7181. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7182. /**
  7183. * Gets the world distance between the min and max points of the bounding box
  7184. */
  7185. readonly diagonalLength: number;
  7186. /**
  7187. * Checks if a cullable object (mesh...) is in the camera frustum
  7188. * Unlike isInFrustum this cheks the full bounding box
  7189. * @param frustumPlanes Camera near/planes
  7190. * @returns true if the object is in frustum otherwise false
  7191. */
  7192. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7193. /** @hidden */
  7194. _checkCollision(collider: Collider): boolean;
  7195. /**
  7196. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7197. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7198. * @param point the point to check intersection with
  7199. * @returns if the point intersects
  7200. */
  7201. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7202. /**
  7203. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7204. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7205. * @param boundingInfo the bounding info to check intersection with
  7206. * @param precise if the intersection should be done using OBB
  7207. * @returns if the bounding info intersects
  7208. */
  7209. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7210. }
  7211. }
  7212. declare module "babylonjs/Misc/smartArray" {
  7213. /**
  7214. * Defines an array and its length.
  7215. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7216. */
  7217. export interface ISmartArrayLike<T> {
  7218. /**
  7219. * The data of the array.
  7220. */
  7221. data: Array<T>;
  7222. /**
  7223. * The active length of the array.
  7224. */
  7225. length: number;
  7226. }
  7227. /**
  7228. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7229. */
  7230. export class SmartArray<T> implements ISmartArrayLike<T> {
  7231. /**
  7232. * The full set of data from the array.
  7233. */
  7234. data: Array<T>;
  7235. /**
  7236. * The active length of the array.
  7237. */
  7238. length: number;
  7239. protected _id: number;
  7240. /**
  7241. * Instantiates a Smart Array.
  7242. * @param capacity defines the default capacity of the array.
  7243. */
  7244. constructor(capacity: number);
  7245. /**
  7246. * Pushes a value at the end of the active data.
  7247. * @param value defines the object to push in the array.
  7248. */
  7249. push(value: T): void;
  7250. /**
  7251. * Iterates over the active data and apply the lambda to them.
  7252. * @param func defines the action to apply on each value.
  7253. */
  7254. forEach(func: (content: T) => void): void;
  7255. /**
  7256. * Sorts the full sets of data.
  7257. * @param compareFn defines the comparison function to apply.
  7258. */
  7259. sort(compareFn: (a: T, b: T) => number): void;
  7260. /**
  7261. * Resets the active data to an empty array.
  7262. */
  7263. reset(): void;
  7264. /**
  7265. * Releases all the data from the array as well as the array.
  7266. */
  7267. dispose(): void;
  7268. /**
  7269. * Concats the active data with a given array.
  7270. * @param array defines the data to concatenate with.
  7271. */
  7272. concat(array: any): void;
  7273. /**
  7274. * Returns the position of a value in the active data.
  7275. * @param value defines the value to find the index for
  7276. * @returns the index if found in the active data otherwise -1
  7277. */
  7278. indexOf(value: T): number;
  7279. /**
  7280. * Returns whether an element is part of the active data.
  7281. * @param value defines the value to look for
  7282. * @returns true if found in the active data otherwise false
  7283. */
  7284. contains(value: T): boolean;
  7285. private static _GlobalId;
  7286. }
  7287. /**
  7288. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7289. * The data in this array can only be present once
  7290. */
  7291. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7292. private _duplicateId;
  7293. /**
  7294. * Pushes a value at the end of the active data.
  7295. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7296. * @param value defines the object to push in the array.
  7297. */
  7298. push(value: T): void;
  7299. /**
  7300. * Pushes a value at the end of the active data.
  7301. * If the data is already present, it won t be added again
  7302. * @param value defines the object to push in the array.
  7303. * @returns true if added false if it was already present
  7304. */
  7305. pushNoDuplicate(value: T): boolean;
  7306. /**
  7307. * Resets the active data to an empty array.
  7308. */
  7309. reset(): void;
  7310. /**
  7311. * Concats the active data with a given array.
  7312. * This ensures no dupplicate will be present in the result.
  7313. * @param array defines the data to concatenate with.
  7314. */
  7315. concatWithNoDuplicate(array: any): void;
  7316. }
  7317. }
  7318. declare module "babylonjs/Materials/multiMaterial" {
  7319. import { Nullable } from "babylonjs/types";
  7320. import { Scene } from "babylonjs/scene";
  7321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7322. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7323. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7324. import { Material } from "babylonjs/Materials/material";
  7325. /**
  7326. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7327. * separate meshes. This can be use to improve performances.
  7328. * @see http://doc.babylonjs.com/how_to/multi_materials
  7329. */
  7330. export class MultiMaterial extends Material {
  7331. private _subMaterials;
  7332. /**
  7333. * Gets or Sets the list of Materials used within the multi material.
  7334. * They need to be ordered according to the submeshes order in the associated mesh
  7335. */
  7336. subMaterials: Nullable<Material>[];
  7337. /**
  7338. * Function used to align with Node.getChildren()
  7339. * @returns the list of Materials used within the multi material
  7340. */
  7341. getChildren(): Nullable<Material>[];
  7342. /**
  7343. * Instantiates a new Multi Material
  7344. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7345. * separate meshes. This can be use to improve performances.
  7346. * @see http://doc.babylonjs.com/how_to/multi_materials
  7347. * @param name Define the name in the scene
  7348. * @param scene Define the scene the material belongs to
  7349. */
  7350. constructor(name: string, scene: Scene);
  7351. private _hookArray;
  7352. /**
  7353. * Get one of the submaterial by its index in the submaterials array
  7354. * @param index The index to look the sub material at
  7355. * @returns The Material if the index has been defined
  7356. */
  7357. getSubMaterial(index: number): Nullable<Material>;
  7358. /**
  7359. * Get the list of active textures for the whole sub materials list.
  7360. * @returns All the textures that will be used during the rendering
  7361. */
  7362. getActiveTextures(): BaseTexture[];
  7363. /**
  7364. * Gets the current class name of the material e.g. "MultiMaterial"
  7365. * Mainly use in serialization.
  7366. * @returns the class name
  7367. */
  7368. getClassName(): string;
  7369. /**
  7370. * Checks if the material is ready to render the requested sub mesh
  7371. * @param mesh Define the mesh the submesh belongs to
  7372. * @param subMesh Define the sub mesh to look readyness for
  7373. * @param useInstances Define whether or not the material is used with instances
  7374. * @returns true if ready, otherwise false
  7375. */
  7376. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7377. /**
  7378. * Clones the current material and its related sub materials
  7379. * @param name Define the name of the newly cloned material
  7380. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7381. * @returns the cloned material
  7382. */
  7383. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7384. /**
  7385. * Serializes the materials into a JSON representation.
  7386. * @returns the JSON representation
  7387. */
  7388. serialize(): any;
  7389. /**
  7390. * Dispose the material and release its associated resources
  7391. * @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)
  7392. * @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)
  7393. * @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)
  7394. */
  7395. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7396. /**
  7397. * Creates a MultiMaterial from parsed MultiMaterial data.
  7398. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7399. * @param scene defines the hosting scene
  7400. * @returns a new MultiMaterial
  7401. */
  7402. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7403. }
  7404. }
  7405. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7406. /**
  7407. * Class used to represent data loading progression
  7408. */
  7409. export class SceneLoaderFlags {
  7410. private static _ForceFullSceneLoadingForIncremental;
  7411. private static _ShowLoadingScreen;
  7412. private static _CleanBoneMatrixWeights;
  7413. private static _loggingLevel;
  7414. /**
  7415. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7416. */
  7417. static ForceFullSceneLoadingForIncremental: boolean;
  7418. /**
  7419. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7420. */
  7421. static ShowLoadingScreen: boolean;
  7422. /**
  7423. * Defines the current logging level (while loading the scene)
  7424. * @ignorenaming
  7425. */
  7426. static loggingLevel: number;
  7427. /**
  7428. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7429. */
  7430. static CleanBoneMatrixWeights: boolean;
  7431. }
  7432. }
  7433. declare module "babylonjs/Meshes/transformNode" {
  7434. import { DeepImmutable } from "babylonjs/types";
  7435. import { Observable } from "babylonjs/Misc/observable";
  7436. import { Nullable } from "babylonjs/types";
  7437. import { Camera } from "babylonjs/Cameras/camera";
  7438. import { Scene } from "babylonjs/scene";
  7439. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7440. import { Node } from "babylonjs/node";
  7441. import { Bone } from "babylonjs/Bones/bone";
  7442. /**
  7443. * 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.
  7444. * @see https://doc.babylonjs.com/how_to/transformnode
  7445. */
  7446. export class TransformNode extends Node {
  7447. /**
  7448. * Object will not rotate to face the camera
  7449. */
  7450. static BILLBOARDMODE_NONE: number;
  7451. /**
  7452. * Object will rotate to face the camera but only on the x axis
  7453. */
  7454. static BILLBOARDMODE_X: number;
  7455. /**
  7456. * Object will rotate to face the camera but only on the y axis
  7457. */
  7458. static BILLBOARDMODE_Y: number;
  7459. /**
  7460. * Object will rotate to face the camera but only on the z axis
  7461. */
  7462. static BILLBOARDMODE_Z: number;
  7463. /**
  7464. * Object will rotate to face the camera
  7465. */
  7466. static BILLBOARDMODE_ALL: number;
  7467. private _forward;
  7468. private _forwardInverted;
  7469. private _up;
  7470. private _right;
  7471. private _rightInverted;
  7472. private _position;
  7473. private _rotation;
  7474. private _rotationQuaternion;
  7475. protected _scaling: Vector3;
  7476. protected _isDirty: boolean;
  7477. private _transformToBoneReferal;
  7478. /**
  7479. * Set the billboard mode. Default is 0.
  7480. *
  7481. * | Value | Type | Description |
  7482. * | --- | --- | --- |
  7483. * | 0 | BILLBOARDMODE_NONE | |
  7484. * | 1 | BILLBOARDMODE_X | |
  7485. * | 2 | BILLBOARDMODE_Y | |
  7486. * | 4 | BILLBOARDMODE_Z | |
  7487. * | 7 | BILLBOARDMODE_ALL | |
  7488. *
  7489. */
  7490. billboardMode: number;
  7491. /**
  7492. * 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
  7493. */
  7494. scalingDeterminant: number;
  7495. /**
  7496. * Sets the distance of the object to max, often used by skybox
  7497. */
  7498. infiniteDistance: boolean;
  7499. /**
  7500. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7501. * By default the system will update normals to compensate
  7502. */
  7503. ignoreNonUniformScaling: boolean;
  7504. /** @hidden */
  7505. _poseMatrix: Matrix;
  7506. /** @hidden */
  7507. _localMatrix: Matrix;
  7508. private _absolutePosition;
  7509. private _pivotMatrix;
  7510. private _pivotMatrixInverse;
  7511. protected _postMultiplyPivotMatrix: boolean;
  7512. private _tempMatrix;
  7513. protected _isWorldMatrixFrozen: boolean;
  7514. /** @hidden */
  7515. _indexInSceneTransformNodesArray: number;
  7516. /**
  7517. * An event triggered after the world matrix is updated
  7518. */
  7519. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7520. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7521. /**
  7522. * Gets a string identifying the name of the class
  7523. * @returns "TransformNode" string
  7524. */
  7525. getClassName(): string;
  7526. /**
  7527. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7528. */
  7529. position: Vector3;
  7530. /**
  7531. * 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)).
  7532. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7533. */
  7534. rotation: Vector3;
  7535. /**
  7536. * 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)).
  7537. */
  7538. scaling: Vector3;
  7539. /**
  7540. * 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).
  7541. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7542. */
  7543. rotationQuaternion: Nullable<Quaternion>;
  7544. /**
  7545. * The forward direction of that transform in world space.
  7546. */
  7547. readonly forward: Vector3;
  7548. /**
  7549. * The up direction of that transform in world space.
  7550. */
  7551. readonly up: Vector3;
  7552. /**
  7553. * The right direction of that transform in world space.
  7554. */
  7555. readonly right: Vector3;
  7556. /**
  7557. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7558. * @param matrix the matrix to copy the pose from
  7559. * @returns this TransformNode.
  7560. */
  7561. updatePoseMatrix(matrix: Matrix): TransformNode;
  7562. /**
  7563. * Returns the mesh Pose matrix.
  7564. * @returns the pose matrix
  7565. */
  7566. getPoseMatrix(): Matrix;
  7567. /** @hidden */
  7568. _isSynchronized(): boolean;
  7569. /** @hidden */
  7570. _initCache(): void;
  7571. /**
  7572. * Flag the transform node as dirty (Forcing it to update everything)
  7573. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7574. * @returns this transform node
  7575. */
  7576. markAsDirty(property: string): TransformNode;
  7577. /**
  7578. * Returns the current mesh absolute position.
  7579. * Returns a Vector3.
  7580. */
  7581. readonly absolutePosition: Vector3;
  7582. /**
  7583. * Sets a new matrix to apply before all other transformation
  7584. * @param matrix defines the transform matrix
  7585. * @returns the current TransformNode
  7586. */
  7587. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7588. /**
  7589. * Sets a new pivot matrix to the current node
  7590. * @param matrix defines the new pivot matrix to use
  7591. * @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
  7592. * @returns the current TransformNode
  7593. */
  7594. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7595. /**
  7596. * Returns the mesh pivot matrix.
  7597. * Default : Identity.
  7598. * @returns the matrix
  7599. */
  7600. getPivotMatrix(): Matrix;
  7601. /**
  7602. * Prevents the World matrix to be computed any longer.
  7603. * @returns the TransformNode.
  7604. */
  7605. freezeWorldMatrix(): TransformNode;
  7606. /**
  7607. * Allows back the World matrix computation.
  7608. * @returns the TransformNode.
  7609. */
  7610. unfreezeWorldMatrix(): this;
  7611. /**
  7612. * True if the World matrix has been frozen.
  7613. */
  7614. readonly isWorldMatrixFrozen: boolean;
  7615. /**
  7616. * Retuns the mesh absolute position in the World.
  7617. * @returns a Vector3.
  7618. */
  7619. getAbsolutePosition(): Vector3;
  7620. /**
  7621. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7622. * @param absolutePosition the absolute position to set
  7623. * @returns the TransformNode.
  7624. */
  7625. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7626. /**
  7627. * Sets the mesh position in its local space.
  7628. * @param vector3 the position to set in localspace
  7629. * @returns the TransformNode.
  7630. */
  7631. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7632. /**
  7633. * Returns the mesh position in the local space from the current World matrix values.
  7634. * @returns a new Vector3.
  7635. */
  7636. getPositionExpressedInLocalSpace(): Vector3;
  7637. /**
  7638. * Translates the mesh along the passed Vector3 in its local space.
  7639. * @param vector3 the distance to translate in localspace
  7640. * @returns the TransformNode.
  7641. */
  7642. locallyTranslate(vector3: Vector3): TransformNode;
  7643. private static _lookAtVectorCache;
  7644. /**
  7645. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7646. * @param targetPoint the position (must be in same space as current mesh) to look at
  7647. * @param yawCor optional yaw (y-axis) correction in radians
  7648. * @param pitchCor optional pitch (x-axis) correction in radians
  7649. * @param rollCor optional roll (z-axis) correction in radians
  7650. * @param space the choosen space of the target
  7651. * @returns the TransformNode.
  7652. */
  7653. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7654. /**
  7655. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7656. * This Vector3 is expressed in the World space.
  7657. * @param localAxis axis to rotate
  7658. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7659. */
  7660. getDirection(localAxis: Vector3): Vector3;
  7661. /**
  7662. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7663. * localAxis is expressed in the mesh local space.
  7664. * result is computed in the Wordl space from the mesh World matrix.
  7665. * @param localAxis axis to rotate
  7666. * @param result the resulting transformnode
  7667. * @returns this TransformNode.
  7668. */
  7669. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7670. /**
  7671. * Sets this transform node rotation to the given local axis.
  7672. * @param localAxis the axis in local space
  7673. * @param yawCor optional yaw (y-axis) correction in radians
  7674. * @param pitchCor optional pitch (x-axis) correction in radians
  7675. * @param rollCor optional roll (z-axis) correction in radians
  7676. * @returns this TransformNode
  7677. */
  7678. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7679. /**
  7680. * Sets a new pivot point to the current node
  7681. * @param point defines the new pivot point to use
  7682. * @param space defines if the point is in world or local space (local by default)
  7683. * @returns the current TransformNode
  7684. */
  7685. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7686. /**
  7687. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7688. * @returns the pivot point
  7689. */
  7690. getPivotPoint(): Vector3;
  7691. /**
  7692. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7693. * @param result the vector3 to store the result
  7694. * @returns this TransformNode.
  7695. */
  7696. getPivotPointToRef(result: Vector3): TransformNode;
  7697. /**
  7698. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7699. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7700. */
  7701. getAbsolutePivotPoint(): Vector3;
  7702. /**
  7703. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7704. * @param result vector3 to store the result
  7705. * @returns this TransformNode.
  7706. */
  7707. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7708. /**
  7709. * Defines the passed node as the parent of the current node.
  7710. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7711. * @param node the node ot set as the parent
  7712. * @returns this TransformNode.
  7713. */
  7714. setParent(node: Nullable<Node>): TransformNode;
  7715. private _nonUniformScaling;
  7716. /**
  7717. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7718. */
  7719. readonly nonUniformScaling: boolean;
  7720. /** @hidden */
  7721. _updateNonUniformScalingState(value: boolean): boolean;
  7722. /**
  7723. * Attach the current TransformNode to another TransformNode associated with a bone
  7724. * @param bone Bone affecting the TransformNode
  7725. * @param affectedTransformNode TransformNode associated with the bone
  7726. * @returns this object
  7727. */
  7728. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7729. /**
  7730. * Detach the transform node if its associated with a bone
  7731. * @returns this object
  7732. */
  7733. detachFromBone(): TransformNode;
  7734. private static _rotationAxisCache;
  7735. /**
  7736. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7737. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7738. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7739. * The passed axis is also normalized.
  7740. * @param axis the axis to rotate around
  7741. * @param amount the amount to rotate in radians
  7742. * @param space Space to rotate in (Default: local)
  7743. * @returns the TransformNode.
  7744. */
  7745. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7746. /**
  7747. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7748. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7749. * The passed axis is also normalized. .
  7750. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7751. * @param point the point to rotate around
  7752. * @param axis the axis to rotate around
  7753. * @param amount the amount to rotate in radians
  7754. * @returns the TransformNode
  7755. */
  7756. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7757. /**
  7758. * Translates the mesh along the axis vector for the passed distance in the given space.
  7759. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7760. * @param axis the axis to translate in
  7761. * @param distance the distance to translate
  7762. * @param space Space to rotate in (Default: local)
  7763. * @returns the TransformNode.
  7764. */
  7765. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7766. /**
  7767. * Adds a rotation step to the mesh current rotation.
  7768. * x, y, z are Euler angles expressed in radians.
  7769. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7770. * This means this rotation is made in the mesh local space only.
  7771. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7772. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7773. * ```javascript
  7774. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7775. * ```
  7776. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7777. * 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.
  7778. * @param x Rotation to add
  7779. * @param y Rotation to add
  7780. * @param z Rotation to add
  7781. * @returns the TransformNode.
  7782. */
  7783. addRotation(x: number, y: number, z: number): TransformNode;
  7784. /**
  7785. * Computes the world matrix of the node
  7786. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7787. * @returns the world matrix
  7788. */
  7789. computeWorldMatrix(force?: boolean): Matrix;
  7790. protected _afterComputeWorldMatrix(): void;
  7791. /**
  7792. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7793. * @param func callback function to add
  7794. *
  7795. * @returns the TransformNode.
  7796. */
  7797. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7798. /**
  7799. * Removes a registered callback function.
  7800. * @param func callback function to remove
  7801. * @returns the TransformNode.
  7802. */
  7803. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7804. /**
  7805. * Gets the position of the current mesh in camera space
  7806. * @param camera defines the camera to use
  7807. * @returns a position
  7808. */
  7809. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7810. /**
  7811. * Returns the distance from the mesh to the active camera
  7812. * @param camera defines the camera to use
  7813. * @returns the distance
  7814. */
  7815. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7816. /**
  7817. * Clone the current transform node
  7818. * @param name Name of the new clone
  7819. * @param newParent New parent for the clone
  7820. * @param doNotCloneChildren Do not clone children hierarchy
  7821. * @returns the new transform node
  7822. */
  7823. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7824. /**
  7825. * Serializes the objects information.
  7826. * @param currentSerializationObject defines the object to serialize in
  7827. * @returns the serialized object
  7828. */
  7829. serialize(currentSerializationObject?: any): any;
  7830. /**
  7831. * Returns a new TransformNode object parsed from the source provided.
  7832. * @param parsedTransformNode is the source.
  7833. * @param scene the scne the object belongs to
  7834. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7835. * @returns a new TransformNode object parsed from the source provided.
  7836. */
  7837. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7838. /**
  7839. * Get all child-transformNodes of this node
  7840. * @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
  7841. * @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
  7842. * @returns an array of TransformNode
  7843. */
  7844. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7845. /**
  7846. * Releases resources associated with this transform node.
  7847. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7848. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7849. */
  7850. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7851. }
  7852. }
  7853. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7854. /**
  7855. * Class used to override all child animations of a given target
  7856. */
  7857. export class AnimationPropertiesOverride {
  7858. /**
  7859. * Gets or sets a value indicating if animation blending must be used
  7860. */
  7861. enableBlending: boolean;
  7862. /**
  7863. * Gets or sets the blending speed to use when enableBlending is true
  7864. */
  7865. blendingSpeed: number;
  7866. /**
  7867. * Gets or sets the default loop mode to use
  7868. */
  7869. loopMode: number;
  7870. }
  7871. }
  7872. declare module "babylonjs/Bones/bone" {
  7873. import { Skeleton } from "babylonjs/Bones/skeleton";
  7874. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7875. import { Nullable } from "babylonjs/types";
  7876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7877. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7878. import { Node } from "babylonjs/node";
  7879. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7880. /**
  7881. * Class used to store bone information
  7882. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7883. */
  7884. export class Bone extends Node {
  7885. /**
  7886. * defines the bone name
  7887. */
  7888. name: string;
  7889. private static _tmpVecs;
  7890. private static _tmpQuat;
  7891. private static _tmpMats;
  7892. /**
  7893. * Gets the list of child bones
  7894. */
  7895. children: Bone[];
  7896. /** Gets the animations associated with this bone */
  7897. animations: import("babylonjs/Animations/animation").Animation[];
  7898. /**
  7899. * Gets or sets bone length
  7900. */
  7901. length: number;
  7902. /**
  7903. * @hidden Internal only
  7904. * Set this value to map this bone to a different index in the transform matrices
  7905. * Set this value to -1 to exclude the bone from the transform matrices
  7906. */
  7907. _index: Nullable<number>;
  7908. private _skeleton;
  7909. private _localMatrix;
  7910. private _restPose;
  7911. private _baseMatrix;
  7912. private _absoluteTransform;
  7913. private _invertedAbsoluteTransform;
  7914. private _parent;
  7915. private _scalingDeterminant;
  7916. private _worldTransform;
  7917. private _localScaling;
  7918. private _localRotation;
  7919. private _localPosition;
  7920. private _needToDecompose;
  7921. private _needToCompose;
  7922. /** @hidden */
  7923. _linkedTransformNode: Nullable<TransformNode>;
  7924. /** @hidden */
  7925. /** @hidden */
  7926. _matrix: Matrix;
  7927. /**
  7928. * Create a new bone
  7929. * @param name defines the bone name
  7930. * @param skeleton defines the parent skeleton
  7931. * @param parentBone defines the parent (can be null if the bone is the root)
  7932. * @param localMatrix defines the local matrix
  7933. * @param restPose defines the rest pose matrix
  7934. * @param baseMatrix defines the base matrix
  7935. * @param index defines index of the bone in the hiearchy
  7936. */
  7937. constructor(
  7938. /**
  7939. * defines the bone name
  7940. */
  7941. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7942. /**
  7943. * Gets the current object class name.
  7944. * @return the class name
  7945. */
  7946. getClassName(): string;
  7947. /**
  7948. * Gets the parent skeleton
  7949. * @returns a skeleton
  7950. */
  7951. getSkeleton(): Skeleton;
  7952. /**
  7953. * Gets parent bone
  7954. * @returns a bone or null if the bone is the root of the bone hierarchy
  7955. */
  7956. getParent(): Nullable<Bone>;
  7957. /**
  7958. * Returns an array containing the root bones
  7959. * @returns an array containing the root bones
  7960. */
  7961. getChildren(): Array<Bone>;
  7962. /**
  7963. * Sets the parent bone
  7964. * @param parent defines the parent (can be null if the bone is the root)
  7965. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7966. */
  7967. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7968. /**
  7969. * Gets the local matrix
  7970. * @returns a matrix
  7971. */
  7972. getLocalMatrix(): Matrix;
  7973. /**
  7974. * Gets the base matrix (initial matrix which remains unchanged)
  7975. * @returns a matrix
  7976. */
  7977. getBaseMatrix(): Matrix;
  7978. /**
  7979. * Gets the rest pose matrix
  7980. * @returns a matrix
  7981. */
  7982. getRestPose(): Matrix;
  7983. /**
  7984. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7985. */
  7986. getWorldMatrix(): Matrix;
  7987. /**
  7988. * Sets the local matrix to rest pose matrix
  7989. */
  7990. returnToRest(): void;
  7991. /**
  7992. * Gets the inverse of the absolute transform matrix.
  7993. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  7994. * @returns a matrix
  7995. */
  7996. getInvertedAbsoluteTransform(): Matrix;
  7997. /**
  7998. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  7999. * @returns a matrix
  8000. */
  8001. getAbsoluteTransform(): Matrix;
  8002. /**
  8003. * Links with the given transform node.
  8004. * The local matrix of this bone is copied from the transform node every frame.
  8005. * @param transformNode defines the transform node to link to
  8006. */
  8007. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8008. /** Gets or sets current position (in local space) */
  8009. position: Vector3;
  8010. /** Gets or sets current rotation (in local space) */
  8011. rotation: Vector3;
  8012. /** Gets or sets current rotation quaternion (in local space) */
  8013. rotationQuaternion: Quaternion;
  8014. /** Gets or sets current scaling (in local space) */
  8015. scaling: Vector3;
  8016. /**
  8017. * Gets the animation properties override
  8018. */
  8019. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8020. private _decompose;
  8021. private _compose;
  8022. /**
  8023. * Update the base and local matrices
  8024. * @param matrix defines the new base or local matrix
  8025. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8026. * @param updateLocalMatrix defines if the local matrix should be updated
  8027. */
  8028. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8029. /** @hidden */
  8030. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8031. /**
  8032. * Flag the bone as dirty (Forcing it to update everything)
  8033. */
  8034. markAsDirty(): void;
  8035. private _markAsDirtyAndCompose;
  8036. private _markAsDirtyAndDecompose;
  8037. /**
  8038. * Translate the bone in local or world space
  8039. * @param vec The amount to translate the bone
  8040. * @param space The space that the translation is in
  8041. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8042. */
  8043. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8044. /**
  8045. * Set the postion of the bone in local or world space
  8046. * @param position The position to set the bone
  8047. * @param space The space that the position is in
  8048. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8049. */
  8050. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8051. /**
  8052. * Set the absolute position of the bone (world space)
  8053. * @param position The position to set the bone
  8054. * @param mesh The mesh that this bone is attached to
  8055. */
  8056. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8057. /**
  8058. * Scale the bone on the x, y and z axes (in local space)
  8059. * @param x The amount to scale the bone on the x axis
  8060. * @param y The amount to scale the bone on the y axis
  8061. * @param z The amount to scale the bone on the z axis
  8062. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8063. */
  8064. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8065. /**
  8066. * Set the bone scaling in local space
  8067. * @param scale defines the scaling vector
  8068. */
  8069. setScale(scale: Vector3): void;
  8070. /**
  8071. * Gets the current scaling in local space
  8072. * @returns the current scaling vector
  8073. */
  8074. getScale(): Vector3;
  8075. /**
  8076. * Gets the current scaling in local space and stores it in a target vector
  8077. * @param result defines the target vector
  8078. */
  8079. getScaleToRef(result: Vector3): void;
  8080. /**
  8081. * Set the yaw, pitch, and roll of the bone in local or world space
  8082. * @param yaw The rotation of the bone on the y axis
  8083. * @param pitch The rotation of the bone on the x axis
  8084. * @param roll The rotation of the bone on the z axis
  8085. * @param space The space that the axes of rotation are in
  8086. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8087. */
  8088. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8089. /**
  8090. * Add a rotation to the bone on an axis in local or world space
  8091. * @param axis The axis to rotate the bone on
  8092. * @param amount The amount to rotate the bone
  8093. * @param space The space that the axis is in
  8094. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8095. */
  8096. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8097. /**
  8098. * Set the rotation of the bone to a particular axis angle in local or world space
  8099. * @param axis The axis to rotate the bone on
  8100. * @param angle The angle that the bone should be rotated to
  8101. * @param space The space that the axis is in
  8102. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8103. */
  8104. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8105. /**
  8106. * Set the euler rotation of the bone in local of world space
  8107. * @param rotation The euler rotation that the bone should be set to
  8108. * @param space The space that the rotation is in
  8109. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8110. */
  8111. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8112. /**
  8113. * Set the quaternion rotation of the bone in local of world space
  8114. * @param quat The quaternion rotation that the bone should be set to
  8115. * @param space The space that the rotation is in
  8116. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8117. */
  8118. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8119. /**
  8120. * Set the rotation matrix of the bone in local of world space
  8121. * @param rotMat The rotation matrix that the bone should be set to
  8122. * @param space The space that the rotation is in
  8123. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8124. */
  8125. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8126. private _rotateWithMatrix;
  8127. private _getNegativeRotationToRef;
  8128. /**
  8129. * Get the position of the bone in local or world space
  8130. * @param space The space that the returned position is in
  8131. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8132. * @returns The position of the bone
  8133. */
  8134. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8135. /**
  8136. * Copy the position of the bone to a vector3 in local or world space
  8137. * @param space The space that the returned position is in
  8138. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8139. * @param result The vector3 to copy the position to
  8140. */
  8141. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8142. /**
  8143. * Get the absolute position of the bone (world space)
  8144. * @param mesh The mesh that this bone is attached to
  8145. * @returns The absolute position of the bone
  8146. */
  8147. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8148. /**
  8149. * Copy the absolute position of the bone (world space) to the result param
  8150. * @param mesh The mesh that this bone is attached to
  8151. * @param result The vector3 to copy the absolute position to
  8152. */
  8153. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8154. /**
  8155. * Compute the absolute transforms of this bone and its children
  8156. */
  8157. computeAbsoluteTransforms(): void;
  8158. /**
  8159. * Get the world direction from an axis that is in the local space of the bone
  8160. * @param localAxis The local direction that is used to compute the world direction
  8161. * @param mesh The mesh that this bone is attached to
  8162. * @returns The world direction
  8163. */
  8164. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8165. /**
  8166. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8167. * @param localAxis The local direction that is used to compute the world direction
  8168. * @param mesh The mesh that this bone is attached to
  8169. * @param result The vector3 that the world direction will be copied to
  8170. */
  8171. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8172. /**
  8173. * Get the euler rotation of the bone in local or world space
  8174. * @param space The space that the rotation should be in
  8175. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8176. * @returns The euler rotation
  8177. */
  8178. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8179. /**
  8180. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8181. * @param space The space that the rotation should be in
  8182. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8183. * @param result The vector3 that the rotation should be copied to
  8184. */
  8185. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8186. /**
  8187. * Get the quaternion rotation of the bone in either local or world space
  8188. * @param space The space that the rotation should be in
  8189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8190. * @returns The quaternion rotation
  8191. */
  8192. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8193. /**
  8194. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8195. * @param space The space that the rotation should be in
  8196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8197. * @param result The quaternion that the rotation should be copied to
  8198. */
  8199. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8200. /**
  8201. * Get the rotation matrix of the bone in local or world space
  8202. * @param space The space that the rotation should be in
  8203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8204. * @returns The rotation matrix
  8205. */
  8206. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8207. /**
  8208. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8209. * @param space The space that the rotation should be in
  8210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8211. * @param result The quaternion that the rotation should be copied to
  8212. */
  8213. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8214. /**
  8215. * Get the world position of a point that is in the local space of the bone
  8216. * @param position The local position
  8217. * @param mesh The mesh that this bone is attached to
  8218. * @returns The world position
  8219. */
  8220. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8221. /**
  8222. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8223. * @param position The local position
  8224. * @param mesh The mesh that this bone is attached to
  8225. * @param result The vector3 that the world position should be copied to
  8226. */
  8227. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8228. /**
  8229. * Get the local position of a point that is in world space
  8230. * @param position The world position
  8231. * @param mesh The mesh that this bone is attached to
  8232. * @returns The local position
  8233. */
  8234. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8235. /**
  8236. * Get the local position of a point that is in world space and copy it to the result param
  8237. * @param position The world position
  8238. * @param mesh The mesh that this bone is attached to
  8239. * @param result The vector3 that the local position should be copied to
  8240. */
  8241. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8242. }
  8243. }
  8244. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8245. import { Nullable } from "babylonjs/types";
  8246. import { Scene } from "babylonjs/scene";
  8247. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8248. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8249. /**
  8250. * Class for creating a cube texture
  8251. */
  8252. export class CubeTexture extends BaseTexture {
  8253. private _delayedOnLoad;
  8254. /**
  8255. * The url of the texture
  8256. */
  8257. url: string;
  8258. /**
  8259. * Gets or sets the center of the bounding box associated with the cube texture.
  8260. * It must define where the camera used to render the texture was set
  8261. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8262. */
  8263. boundingBoxPosition: Vector3;
  8264. private _boundingBoxSize;
  8265. /**
  8266. * Gets or sets the size of the bounding box associated with the cube texture
  8267. * When defined, the cubemap will switch to local mode
  8268. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8269. * @example https://www.babylonjs-playground.com/#RNASML
  8270. */
  8271. /**
  8272. * Returns the bounding box size
  8273. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8274. */
  8275. boundingBoxSize: Vector3;
  8276. protected _rotationY: number;
  8277. /**
  8278. * Sets texture matrix rotation angle around Y axis in radians.
  8279. */
  8280. /**
  8281. * Gets texture matrix rotation angle around Y axis radians.
  8282. */
  8283. rotationY: number;
  8284. /**
  8285. * Are mip maps generated for this texture or not.
  8286. */
  8287. readonly noMipmap: boolean;
  8288. private _noMipmap;
  8289. private _files;
  8290. private _extensions;
  8291. private _textureMatrix;
  8292. private _format;
  8293. private _createPolynomials;
  8294. /** @hidden */
  8295. _prefiltered: boolean;
  8296. /**
  8297. * Creates a cube texture from an array of image urls
  8298. * @param files defines an array of image urls
  8299. * @param scene defines the hosting scene
  8300. * @param noMipmap specifies if mip maps are not used
  8301. * @returns a cube texture
  8302. */
  8303. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8304. /**
  8305. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8306. * @param url defines the url of the prefiltered texture
  8307. * @param scene defines the scene the texture is attached to
  8308. * @param forcedExtension defines the extension of the file if different from the url
  8309. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8310. * @return the prefiltered texture
  8311. */
  8312. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8313. /**
  8314. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8315. * as prefiltered data.
  8316. * @param rootUrl defines the url of the texture or the root name of the six images
  8317. * @param scene defines the scene the texture is attached to
  8318. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8319. * @param noMipmap defines if mipmaps should be created or not
  8320. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8321. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8322. * @param onError defines a callback triggered in case of error during load
  8323. * @param format defines the internal format to use for the texture once loaded
  8324. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8325. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8326. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8327. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8328. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8329. * @return the cube texture
  8330. */
  8331. 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);
  8332. /**
  8333. * Get the current class name of the texture useful for serialization or dynamic coding.
  8334. * @returns "CubeTexture"
  8335. */
  8336. getClassName(): string;
  8337. /**
  8338. * Update the url (and optional buffer) of this texture if url was null during construction.
  8339. * @param url the url of the texture
  8340. * @param forcedExtension defines the extension to use
  8341. * @param onLoad callback called when the texture is loaded (defaults to null)
  8342. */
  8343. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8344. /**
  8345. * Delays loading of the cube texture
  8346. * @param forcedExtension defines the extension to use
  8347. */
  8348. delayLoad(forcedExtension?: string): void;
  8349. /**
  8350. * Returns the reflection texture matrix
  8351. * @returns the reflection texture matrix
  8352. */
  8353. getReflectionTextureMatrix(): Matrix;
  8354. /**
  8355. * Sets the reflection texture matrix
  8356. * @param value Reflection texture matrix
  8357. */
  8358. setReflectionTextureMatrix(value: Matrix): void;
  8359. /**
  8360. * Parses text to create a cube texture
  8361. * @param parsedTexture define the serialized text to read from
  8362. * @param scene defines the hosting scene
  8363. * @param rootUrl defines the root url of the cube texture
  8364. * @returns a cube texture
  8365. */
  8366. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8367. /**
  8368. * Makes a clone, or deep copy, of the cube texture
  8369. * @returns a new cube texture
  8370. */
  8371. clone(): CubeTexture;
  8372. }
  8373. }
  8374. declare module "babylonjs/Shaders/postprocess.vertex" {
  8375. /** @hidden */
  8376. export var postprocessVertexShader: {
  8377. name: string;
  8378. shader: string;
  8379. };
  8380. }
  8381. declare module "babylonjs/Cameras/targetCamera" {
  8382. import { Nullable } from "babylonjs/types";
  8383. import { Camera } from "babylonjs/Cameras/camera";
  8384. import { Scene } from "babylonjs/scene";
  8385. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8386. /**
  8387. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8388. * This is the base of the follow, arc rotate cameras and Free camera
  8389. * @see http://doc.babylonjs.com/features/cameras
  8390. */
  8391. export class TargetCamera extends Camera {
  8392. private static _RigCamTransformMatrix;
  8393. private static _TargetTransformMatrix;
  8394. private static _TargetFocalPoint;
  8395. /**
  8396. * Define the current direction the camera is moving to
  8397. */
  8398. cameraDirection: Vector3;
  8399. /**
  8400. * Define the current rotation the camera is rotating to
  8401. */
  8402. cameraRotation: Vector2;
  8403. /**
  8404. * When set, the up vector of the camera will be updated by the rotation of the camera
  8405. */
  8406. updateUpVectorFromRotation: boolean;
  8407. private _tmpQuaternion;
  8408. /**
  8409. * Define the current rotation of the camera
  8410. */
  8411. rotation: Vector3;
  8412. /**
  8413. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8414. */
  8415. rotationQuaternion: Quaternion;
  8416. /**
  8417. * Define the current speed of the camera
  8418. */
  8419. speed: number;
  8420. /**
  8421. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8422. * around all axis.
  8423. */
  8424. noRotationConstraint: boolean;
  8425. /**
  8426. * Define the current target of the camera as an object or a position.
  8427. */
  8428. lockedTarget: any;
  8429. /** @hidden */
  8430. _currentTarget: Vector3;
  8431. /** @hidden */
  8432. _initialFocalDistance: number;
  8433. /** @hidden */
  8434. _viewMatrix: Matrix;
  8435. /** @hidden */
  8436. _camMatrix: Matrix;
  8437. /** @hidden */
  8438. _cameraTransformMatrix: Matrix;
  8439. /** @hidden */
  8440. _cameraRotationMatrix: Matrix;
  8441. /** @hidden */
  8442. _referencePoint: Vector3;
  8443. /** @hidden */
  8444. _transformedReferencePoint: Vector3;
  8445. protected _globalCurrentTarget: Vector3;
  8446. protected _globalCurrentUpVector: Vector3;
  8447. /** @hidden */
  8448. _reset: () => void;
  8449. private _defaultUp;
  8450. /**
  8451. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8452. * This is the base of the follow, arc rotate cameras and Free camera
  8453. * @see http://doc.babylonjs.com/features/cameras
  8454. * @param name Defines the name of the camera in the scene
  8455. * @param position Defines the start position of the camera in the scene
  8456. * @param scene Defines the scene the camera belongs to
  8457. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8458. */
  8459. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8460. /**
  8461. * Gets the position in front of the camera at a given distance.
  8462. * @param distance The distance from the camera we want the position to be
  8463. * @returns the position
  8464. */
  8465. getFrontPosition(distance: number): Vector3;
  8466. /** @hidden */
  8467. _getLockedTargetPosition(): Nullable<Vector3>;
  8468. private _storedPosition;
  8469. private _storedRotation;
  8470. private _storedRotationQuaternion;
  8471. /**
  8472. * Store current camera state of the camera (fov, position, rotation, etc..)
  8473. * @returns the camera
  8474. */
  8475. storeState(): Camera;
  8476. /**
  8477. * Restored camera state. You must call storeState() first
  8478. * @returns whether it was successful or not
  8479. * @hidden
  8480. */
  8481. _restoreStateValues(): boolean;
  8482. /** @hidden */
  8483. _initCache(): void;
  8484. /** @hidden */
  8485. _updateCache(ignoreParentClass?: boolean): void;
  8486. /** @hidden */
  8487. _isSynchronizedViewMatrix(): boolean;
  8488. /** @hidden */
  8489. _computeLocalCameraSpeed(): number;
  8490. /**
  8491. * Defines the target the camera should look at.
  8492. * This will automatically adapt alpha beta and radius to fit within the new target.
  8493. * @param target Defines the new target as a Vector or a mesh
  8494. */
  8495. setTarget(target: Vector3): void;
  8496. /**
  8497. * Return the current target position of the camera. This value is expressed in local space.
  8498. * @returns the target position
  8499. */
  8500. getTarget(): Vector3;
  8501. /** @hidden */
  8502. _decideIfNeedsToMove(): boolean;
  8503. /** @hidden */
  8504. _updatePosition(): void;
  8505. /** @hidden */
  8506. _checkInputs(): void;
  8507. protected _updateCameraRotationMatrix(): void;
  8508. /**
  8509. * 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)
  8510. * @returns the current camera
  8511. */
  8512. private _rotateUpVectorWithCameraRotationMatrix;
  8513. private _cachedRotationZ;
  8514. private _cachedQuaternionRotationZ;
  8515. /** @hidden */
  8516. _getViewMatrix(): Matrix;
  8517. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8518. /**
  8519. * @hidden
  8520. */
  8521. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8522. /**
  8523. * @hidden
  8524. */
  8525. _updateRigCameras(): void;
  8526. private _getRigCamPositionAndTarget;
  8527. /**
  8528. * Gets the current object class name.
  8529. * @return the class name
  8530. */
  8531. getClassName(): string;
  8532. }
  8533. }
  8534. declare module "babylonjs/Cameras/cameraInputsManager" {
  8535. import { Nullable } from "babylonjs/types";
  8536. import { Camera } from "babylonjs/Cameras/camera";
  8537. /**
  8538. * @ignore
  8539. * This is a list of all the different input types that are available in the application.
  8540. * Fo instance: ArcRotateCameraGamepadInput...
  8541. */
  8542. export var CameraInputTypes: {};
  8543. /**
  8544. * This is the contract to implement in order to create a new input class.
  8545. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8546. */
  8547. export interface ICameraInput<TCamera extends Camera> {
  8548. /**
  8549. * Defines the camera the input is attached to.
  8550. */
  8551. camera: Nullable<TCamera>;
  8552. /**
  8553. * Gets the class name of the current intput.
  8554. * @returns the class name
  8555. */
  8556. getClassName(): string;
  8557. /**
  8558. * Get the friendly name associated with the input class.
  8559. * @returns the input friendly name
  8560. */
  8561. getSimpleName(): string;
  8562. /**
  8563. * Attach the input controls to a specific dom element to get the input from.
  8564. * @param element Defines the element the controls should be listened from
  8565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8566. */
  8567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8568. /**
  8569. * Detach the current controls from the specified dom element.
  8570. * @param element Defines the element to stop listening the inputs from
  8571. */
  8572. detachControl(element: Nullable<HTMLElement>): void;
  8573. /**
  8574. * Update the current camera state depending on the inputs that have been used this frame.
  8575. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8576. */
  8577. checkInputs?: () => void;
  8578. }
  8579. /**
  8580. * Represents a map of input types to input instance or input index to input instance.
  8581. */
  8582. export interface CameraInputsMap<TCamera extends Camera> {
  8583. /**
  8584. * Accessor to the input by input type.
  8585. */
  8586. [name: string]: ICameraInput<TCamera>;
  8587. /**
  8588. * Accessor to the input by input index.
  8589. */
  8590. [idx: number]: ICameraInput<TCamera>;
  8591. }
  8592. /**
  8593. * This represents the input manager used within a camera.
  8594. * It helps dealing with all the different kind of input attached to a camera.
  8595. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8596. */
  8597. export class CameraInputsManager<TCamera extends Camera> {
  8598. /**
  8599. * Defines the list of inputs attahed to the camera.
  8600. */
  8601. attached: CameraInputsMap<TCamera>;
  8602. /**
  8603. * Defines the dom element the camera is collecting inputs from.
  8604. * This is null if the controls have not been attached.
  8605. */
  8606. attachedElement: Nullable<HTMLElement>;
  8607. /**
  8608. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8609. */
  8610. noPreventDefault: boolean;
  8611. /**
  8612. * Defined the camera the input manager belongs to.
  8613. */
  8614. camera: TCamera;
  8615. /**
  8616. * Update the current camera state depending on the inputs that have been used this frame.
  8617. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8618. */
  8619. checkInputs: () => void;
  8620. /**
  8621. * Instantiate a new Camera Input Manager.
  8622. * @param camera Defines the camera the input manager blongs to
  8623. */
  8624. constructor(camera: TCamera);
  8625. /**
  8626. * Add an input method to a camera
  8627. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8628. * @param input camera input method
  8629. */
  8630. add(input: ICameraInput<TCamera>): void;
  8631. /**
  8632. * Remove a specific input method from a camera
  8633. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8634. * @param inputToRemove camera input method
  8635. */
  8636. remove(inputToRemove: ICameraInput<TCamera>): void;
  8637. /**
  8638. * Remove a specific input type from a camera
  8639. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8640. * @param inputType the type of the input to remove
  8641. */
  8642. removeByType(inputType: string): void;
  8643. private _addCheckInputs;
  8644. /**
  8645. * Attach the input controls to the currently attached dom element to listen the events from.
  8646. * @param input Defines the input to attach
  8647. */
  8648. attachInput(input: ICameraInput<TCamera>): void;
  8649. /**
  8650. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8651. * @param element Defines the dom element to collect the events from
  8652. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8653. */
  8654. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8655. /**
  8656. * Detach the current manager inputs controls from a specific dom element.
  8657. * @param element Defines the dom element to collect the events from
  8658. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8659. */
  8660. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8661. /**
  8662. * Rebuild the dynamic inputCheck function from the current list of
  8663. * defined inputs in the manager.
  8664. */
  8665. rebuildInputCheck(): void;
  8666. /**
  8667. * Remove all attached input methods from a camera
  8668. */
  8669. clear(): void;
  8670. /**
  8671. * Serialize the current input manager attached to a camera.
  8672. * This ensures than once parsed,
  8673. * the input associated to the camera will be identical to the current ones
  8674. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8675. */
  8676. serialize(serializedCamera: any): void;
  8677. /**
  8678. * Parses an input manager serialized JSON to restore the previous list of inputs
  8679. * and states associated to a camera.
  8680. * @param parsedCamera Defines the JSON to parse
  8681. */
  8682. parse(parsedCamera: any): void;
  8683. }
  8684. }
  8685. declare module "babylonjs/Events/keyboardEvents" {
  8686. /**
  8687. * Gather the list of keyboard event types as constants.
  8688. */
  8689. export class KeyboardEventTypes {
  8690. /**
  8691. * The keydown event is fired when a key becomes active (pressed).
  8692. */
  8693. static readonly KEYDOWN: number;
  8694. /**
  8695. * The keyup event is fired when a key has been released.
  8696. */
  8697. static readonly KEYUP: number;
  8698. }
  8699. /**
  8700. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8701. */
  8702. export class KeyboardInfo {
  8703. /**
  8704. * Defines the type of event (KeyboardEventTypes)
  8705. */
  8706. type: number;
  8707. /**
  8708. * Defines the related dom event
  8709. */
  8710. event: KeyboardEvent;
  8711. /**
  8712. * Instantiates a new keyboard info.
  8713. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8714. * @param type Defines the type of event (KeyboardEventTypes)
  8715. * @param event Defines the related dom event
  8716. */
  8717. constructor(
  8718. /**
  8719. * Defines the type of event (KeyboardEventTypes)
  8720. */
  8721. type: number,
  8722. /**
  8723. * Defines the related dom event
  8724. */
  8725. event: KeyboardEvent);
  8726. }
  8727. /**
  8728. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8729. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8730. */
  8731. export class KeyboardInfoPre extends KeyboardInfo {
  8732. /**
  8733. * Defines the type of event (KeyboardEventTypes)
  8734. */
  8735. type: number;
  8736. /**
  8737. * Defines the related dom event
  8738. */
  8739. event: KeyboardEvent;
  8740. /**
  8741. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8742. */
  8743. skipOnPointerObservable: boolean;
  8744. /**
  8745. * Instantiates a new keyboard pre info.
  8746. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8747. * @param type Defines the type of event (KeyboardEventTypes)
  8748. * @param event Defines the related dom event
  8749. */
  8750. constructor(
  8751. /**
  8752. * Defines the type of event (KeyboardEventTypes)
  8753. */
  8754. type: number,
  8755. /**
  8756. * Defines the related dom event
  8757. */
  8758. event: KeyboardEvent);
  8759. }
  8760. }
  8761. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8762. import { Nullable } from "babylonjs/types";
  8763. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8764. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8765. /**
  8766. * Manage the keyboard inputs to control the movement of a free camera.
  8767. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8768. */
  8769. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8770. /**
  8771. * Defines the camera the input is attached to.
  8772. */
  8773. camera: FreeCamera;
  8774. /**
  8775. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8776. */
  8777. keysUp: number[];
  8778. /**
  8779. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8780. */
  8781. keysDown: number[];
  8782. /**
  8783. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8784. */
  8785. keysLeft: number[];
  8786. /**
  8787. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8788. */
  8789. keysRight: number[];
  8790. private _keys;
  8791. private _onCanvasBlurObserver;
  8792. private _onKeyboardObserver;
  8793. private _engine;
  8794. private _scene;
  8795. /**
  8796. * Attach the input controls to a specific dom element to get the input from.
  8797. * @param element Defines the element the controls should be listened from
  8798. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8799. */
  8800. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8801. /**
  8802. * Detach the current controls from the specified dom element.
  8803. * @param element Defines the element to stop listening the inputs from
  8804. */
  8805. detachControl(element: Nullable<HTMLElement>): void;
  8806. /**
  8807. * Update the current camera state depending on the inputs that have been used this frame.
  8808. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8809. */
  8810. checkInputs(): void;
  8811. /**
  8812. * Gets the class name of the current intput.
  8813. * @returns the class name
  8814. */
  8815. getClassName(): string;
  8816. /** @hidden */
  8817. _onLostFocus(): void;
  8818. /**
  8819. * Get the friendly name associated with the input class.
  8820. * @returns the input friendly name
  8821. */
  8822. getSimpleName(): string;
  8823. }
  8824. }
  8825. declare module "babylonjs/Lights/shadowLight" {
  8826. import { Camera } from "babylonjs/Cameras/camera";
  8827. import { Scene } from "babylonjs/scene";
  8828. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8830. import { Light } from "babylonjs/Lights/light";
  8831. /**
  8832. * Interface describing all the common properties and methods a shadow light needs to implement.
  8833. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8834. * as well as binding the different shadow properties to the effects.
  8835. */
  8836. export interface IShadowLight extends Light {
  8837. /**
  8838. * The light id in the scene (used in scene.findLighById for instance)
  8839. */
  8840. id: string;
  8841. /**
  8842. * The position the shdow will be casted from.
  8843. */
  8844. position: Vector3;
  8845. /**
  8846. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8847. */
  8848. direction: Vector3;
  8849. /**
  8850. * The transformed position. Position of the light in world space taking parenting in account.
  8851. */
  8852. transformedPosition: Vector3;
  8853. /**
  8854. * The transformed direction. Direction of the light in world space taking parenting in account.
  8855. */
  8856. transformedDirection: Vector3;
  8857. /**
  8858. * The friendly name of the light in the scene.
  8859. */
  8860. name: string;
  8861. /**
  8862. * Defines the shadow projection clipping minimum z value.
  8863. */
  8864. shadowMinZ: number;
  8865. /**
  8866. * Defines the shadow projection clipping maximum z value.
  8867. */
  8868. shadowMaxZ: number;
  8869. /**
  8870. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8871. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8872. */
  8873. computeTransformedInformation(): boolean;
  8874. /**
  8875. * Gets the scene the light belongs to.
  8876. * @returns The scene
  8877. */
  8878. getScene(): Scene;
  8879. /**
  8880. * Callback defining a custom Projection Matrix Builder.
  8881. * This can be used to override the default projection matrix computation.
  8882. */
  8883. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8884. /**
  8885. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8886. * @param matrix The materix to updated with the projection information
  8887. * @param viewMatrix The transform matrix of the light
  8888. * @param renderList The list of mesh to render in the map
  8889. * @returns The current light
  8890. */
  8891. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8892. /**
  8893. * Gets the current depth scale used in ESM.
  8894. * @returns The scale
  8895. */
  8896. getDepthScale(): number;
  8897. /**
  8898. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8899. * @returns true if a cube texture needs to be use
  8900. */
  8901. needCube(): boolean;
  8902. /**
  8903. * Detects if the projection matrix requires to be recomputed this frame.
  8904. * @returns true if it requires to be recomputed otherwise, false.
  8905. */
  8906. needProjectionMatrixCompute(): boolean;
  8907. /**
  8908. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8909. */
  8910. forceProjectionMatrixCompute(): void;
  8911. /**
  8912. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8913. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8914. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8915. */
  8916. getShadowDirection(faceIndex?: number): Vector3;
  8917. /**
  8918. * Gets the minZ used for shadow according to both the scene and the light.
  8919. * @param activeCamera The camera we are returning the min for
  8920. * @returns the depth min z
  8921. */
  8922. getDepthMinZ(activeCamera: Camera): number;
  8923. /**
  8924. * Gets the maxZ used for shadow according to both the scene and the light.
  8925. * @param activeCamera The camera we are returning the max for
  8926. * @returns the depth max z
  8927. */
  8928. getDepthMaxZ(activeCamera: Camera): number;
  8929. }
  8930. /**
  8931. * Base implementation IShadowLight
  8932. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8933. */
  8934. export abstract class ShadowLight extends Light implements IShadowLight {
  8935. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8936. protected _position: Vector3;
  8937. protected _setPosition(value: Vector3): void;
  8938. /**
  8939. * Sets the position the shadow will be casted from. Also use as the light position for both
  8940. * point and spot lights.
  8941. */
  8942. /**
  8943. * Sets the position the shadow will be casted from. Also use as the light position for both
  8944. * point and spot lights.
  8945. */
  8946. position: Vector3;
  8947. protected _direction: Vector3;
  8948. protected _setDirection(value: Vector3): void;
  8949. /**
  8950. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8951. * Also use as the light direction on spot and directional lights.
  8952. */
  8953. /**
  8954. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8955. * Also use as the light direction on spot and directional lights.
  8956. */
  8957. direction: Vector3;
  8958. private _shadowMinZ;
  8959. /**
  8960. * Gets the shadow projection clipping minimum z value.
  8961. */
  8962. /**
  8963. * Sets the shadow projection clipping minimum z value.
  8964. */
  8965. shadowMinZ: number;
  8966. private _shadowMaxZ;
  8967. /**
  8968. * Sets the shadow projection clipping maximum z value.
  8969. */
  8970. /**
  8971. * Gets the shadow projection clipping maximum z value.
  8972. */
  8973. shadowMaxZ: number;
  8974. /**
  8975. * Callback defining a custom Projection Matrix Builder.
  8976. * This can be used to override the default projection matrix computation.
  8977. */
  8978. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8979. /**
  8980. * The transformed position. Position of the light in world space taking parenting in account.
  8981. */
  8982. transformedPosition: Vector3;
  8983. /**
  8984. * The transformed direction. Direction of the light in world space taking parenting in account.
  8985. */
  8986. transformedDirection: Vector3;
  8987. private _needProjectionMatrixCompute;
  8988. /**
  8989. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8990. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8991. */
  8992. computeTransformedInformation(): boolean;
  8993. /**
  8994. * Return the depth scale used for the shadow map.
  8995. * @returns the depth scale.
  8996. */
  8997. getDepthScale(): number;
  8998. /**
  8999. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9000. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9001. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9002. */
  9003. getShadowDirection(faceIndex?: number): Vector3;
  9004. /**
  9005. * Returns the ShadowLight absolute position in the World.
  9006. * @returns the position vector in world space
  9007. */
  9008. getAbsolutePosition(): Vector3;
  9009. /**
  9010. * Sets the ShadowLight direction toward the passed target.
  9011. * @param target The point to target in local space
  9012. * @returns the updated ShadowLight direction
  9013. */
  9014. setDirectionToTarget(target: Vector3): Vector3;
  9015. /**
  9016. * Returns the light rotation in euler definition.
  9017. * @returns the x y z rotation in local space.
  9018. */
  9019. getRotation(): Vector3;
  9020. /**
  9021. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9022. * @returns true if a cube texture needs to be use
  9023. */
  9024. needCube(): boolean;
  9025. /**
  9026. * Detects if the projection matrix requires to be recomputed this frame.
  9027. * @returns true if it requires to be recomputed otherwise, false.
  9028. */
  9029. needProjectionMatrixCompute(): boolean;
  9030. /**
  9031. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9032. */
  9033. forceProjectionMatrixCompute(): void;
  9034. /** @hidden */
  9035. _initCache(): void;
  9036. /** @hidden */
  9037. _isSynchronized(): boolean;
  9038. /**
  9039. * Computes the world matrix of the node
  9040. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9041. * @returns the world matrix
  9042. */
  9043. computeWorldMatrix(force?: boolean): Matrix;
  9044. /**
  9045. * Gets the minZ used for shadow according to both the scene and the light.
  9046. * @param activeCamera The camera we are returning the min for
  9047. * @returns the depth min z
  9048. */
  9049. getDepthMinZ(activeCamera: Camera): number;
  9050. /**
  9051. * Gets the maxZ used for shadow according to both the scene and the light.
  9052. * @param activeCamera The camera we are returning the max for
  9053. * @returns the depth max z
  9054. */
  9055. getDepthMaxZ(activeCamera: Camera): number;
  9056. /**
  9057. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9058. * @param matrix The materix to updated with the projection information
  9059. * @param viewMatrix The transform matrix of the light
  9060. * @param renderList The list of mesh to render in the map
  9061. * @returns The current light
  9062. */
  9063. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9064. }
  9065. }
  9066. declare module "babylonjs/Materials/materialHelper" {
  9067. import { Nullable } from "babylonjs/types";
  9068. import { Scene } from "babylonjs/scene";
  9069. import { Engine } from "babylonjs/Engines/engine";
  9070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9071. import { Light } from "babylonjs/Lights/light";
  9072. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9073. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9074. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9075. /**
  9076. * "Static Class" containing the most commonly used helper while dealing with material for
  9077. * rendering purpose.
  9078. *
  9079. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9080. *
  9081. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9082. */
  9083. export class MaterialHelper {
  9084. /**
  9085. * Bind the current view position to an effect.
  9086. * @param effect The effect to be bound
  9087. * @param scene The scene the eyes position is used from
  9088. */
  9089. static BindEyePosition(effect: Effect, scene: Scene): void;
  9090. /**
  9091. * Helps preparing the defines values about the UVs in used in the effect.
  9092. * UVs are shared as much as we can accross channels in the shaders.
  9093. * @param texture The texture we are preparing the UVs for
  9094. * @param defines The defines to update
  9095. * @param key The channel key "diffuse", "specular"... used in the shader
  9096. */
  9097. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9098. /**
  9099. * Binds a texture matrix value to its corrsponding uniform
  9100. * @param texture The texture to bind the matrix for
  9101. * @param uniformBuffer The uniform buffer receivin the data
  9102. * @param key The channel key "diffuse", "specular"... used in the shader
  9103. */
  9104. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9105. /**
  9106. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9107. * @param mesh defines the current mesh
  9108. * @param scene defines the current scene
  9109. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9110. * @param pointsCloud defines if point cloud rendering has to be turned on
  9111. * @param fogEnabled defines if fog has to be turned on
  9112. * @param alphaTest defines if alpha testing has to be turned on
  9113. * @param defines defines the current list of defines
  9114. */
  9115. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9116. /**
  9117. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9118. * @param scene defines the current scene
  9119. * @param engine defines the current engine
  9120. * @param defines specifies the list of active defines
  9121. * @param useInstances defines if instances have to be turned on
  9122. * @param useClipPlane defines if clip plane have to be turned on
  9123. */
  9124. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9125. /**
  9126. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9127. * @param mesh The mesh containing the geometry data we will draw
  9128. * @param defines The defines to update
  9129. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9130. * @param useBones Precise whether bones should be used or not (override mesh info)
  9131. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9132. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9133. * @returns false if defines are considered not dirty and have not been checked
  9134. */
  9135. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9136. /**
  9137. * Prepares the defines related to the light information passed in parameter
  9138. * @param scene The scene we are intending to draw
  9139. * @param mesh The mesh the effect is compiling for
  9140. * @param defines The defines to update
  9141. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9142. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9143. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9144. * @returns true if normals will be required for the rest of the effect
  9145. */
  9146. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9147. /**
  9148. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9149. * that won t be acctive due to defines being turned off.
  9150. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9151. * @param samplersList The samplers list
  9152. * @param defines The defines helping in the list generation
  9153. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9154. */
  9155. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9156. /**
  9157. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9158. * @param defines The defines to update while falling back
  9159. * @param fallbacks The authorized effect fallbacks
  9160. * @param maxSimultaneousLights The maximum number of lights allowed
  9161. * @param rank the current rank of the Effect
  9162. * @returns The newly affected rank
  9163. */
  9164. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9165. /**
  9166. * Prepares the list of attributes required for morph targets according to the effect defines.
  9167. * @param attribs The current list of supported attribs
  9168. * @param mesh The mesh to prepare the morph targets attributes for
  9169. * @param defines The current Defines of the effect
  9170. */
  9171. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9172. /**
  9173. * Prepares the list of attributes required for bones according to the effect defines.
  9174. * @param attribs The current list of supported attribs
  9175. * @param mesh The mesh to prepare the bones attributes for
  9176. * @param defines The current Defines of the effect
  9177. * @param fallbacks The current efffect fallback strategy
  9178. */
  9179. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9180. /**
  9181. * Prepares the list of attributes required for instances according to the effect defines.
  9182. * @param attribs The current list of supported attribs
  9183. * @param defines The current Defines of the effect
  9184. */
  9185. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9186. /**
  9187. * Binds the light shadow information to the effect for the given mesh.
  9188. * @param light The light containing the generator
  9189. * @param scene The scene the lights belongs to
  9190. * @param mesh The mesh we are binding the information to render
  9191. * @param lightIndex The light index in the effect used to render the mesh
  9192. * @param effect The effect we are binding the data to
  9193. */
  9194. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9195. /**
  9196. * Binds the light information to the effect.
  9197. * @param light The light containing the generator
  9198. * @param effect The effect we are binding the data to
  9199. * @param lightIndex The light index in the effect used to render
  9200. */
  9201. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9202. /**
  9203. * Binds the lights information from the scene to the effect for the given mesh.
  9204. * @param scene The scene the lights belongs to
  9205. * @param mesh The mesh we are binding the information to render
  9206. * @param effect The effect we are binding the data to
  9207. * @param defines The generated defines for the effect
  9208. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9209. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9210. */
  9211. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9212. private static _tempFogColor;
  9213. /**
  9214. * Binds the fog information from the scene to the effect for the given mesh.
  9215. * @param scene The scene the lights belongs to
  9216. * @param mesh The mesh we are binding the information to render
  9217. * @param effect The effect we are binding the data to
  9218. * @param linearSpace Defines if the fog effect is applied in linear space
  9219. */
  9220. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9221. /**
  9222. * Binds the bones information from the mesh to the effect.
  9223. * @param mesh The mesh we are binding the information to render
  9224. * @param effect The effect we are binding the data to
  9225. */
  9226. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9227. /**
  9228. * Binds the morph targets information from the mesh to the effect.
  9229. * @param abstractMesh The mesh we are binding the information to render
  9230. * @param effect The effect we are binding the data to
  9231. */
  9232. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9233. /**
  9234. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9235. * @param defines The generated defines used in the effect
  9236. * @param effect The effect we are binding the data to
  9237. * @param scene The scene we are willing to render with logarithmic scale for
  9238. */
  9239. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9240. /**
  9241. * Binds the clip plane information from the scene to the effect.
  9242. * @param scene The scene the clip plane information are extracted from
  9243. * @param effect The effect we are binding the data to
  9244. */
  9245. static BindClipPlane(effect: Effect, scene: Scene): void;
  9246. }
  9247. }
  9248. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9249. /** @hidden */
  9250. export var kernelBlurVaryingDeclaration: {
  9251. name: string;
  9252. shader: string;
  9253. };
  9254. }
  9255. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9256. /** @hidden */
  9257. export var kernelBlurFragment: {
  9258. name: string;
  9259. shader: string;
  9260. };
  9261. }
  9262. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9263. /** @hidden */
  9264. export var kernelBlurFragment2: {
  9265. name: string;
  9266. shader: string;
  9267. };
  9268. }
  9269. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9270. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9271. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9272. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9273. /** @hidden */
  9274. export var kernelBlurPixelShader: {
  9275. name: string;
  9276. shader: string;
  9277. };
  9278. }
  9279. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9280. /** @hidden */
  9281. export var kernelBlurVertex: {
  9282. name: string;
  9283. shader: string;
  9284. };
  9285. }
  9286. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9287. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9288. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9289. /** @hidden */
  9290. export var kernelBlurVertexShader: {
  9291. name: string;
  9292. shader: string;
  9293. };
  9294. }
  9295. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9296. import { Vector2 } from "babylonjs/Maths/math";
  9297. import { Nullable } from "babylonjs/types";
  9298. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9299. import { Camera } from "babylonjs/Cameras/camera";
  9300. import { Effect } from "babylonjs/Materials/effect";
  9301. import { Engine } from "babylonjs/Engines/engine";
  9302. import "babylonjs/Shaders/kernelBlur.fragment";
  9303. import "babylonjs/Shaders/kernelBlur.vertex";
  9304. /**
  9305. * The Blur Post Process which blurs an image based on a kernel and direction.
  9306. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9307. */
  9308. export class BlurPostProcess extends PostProcess {
  9309. /** The direction in which to blur the image. */
  9310. direction: Vector2;
  9311. private blockCompilation;
  9312. protected _kernel: number;
  9313. protected _idealKernel: number;
  9314. protected _packedFloat: boolean;
  9315. private _staticDefines;
  9316. /**
  9317. * Sets the length in pixels of the blur sample region
  9318. */
  9319. /**
  9320. * Gets the length in pixels of the blur sample region
  9321. */
  9322. kernel: number;
  9323. /**
  9324. * Sets wether or not the blur needs to unpack/repack floats
  9325. */
  9326. /**
  9327. * Gets wether or not the blur is unpacking/repacking floats
  9328. */
  9329. packedFloat: boolean;
  9330. /**
  9331. * Creates a new instance BlurPostProcess
  9332. * @param name The name of the effect.
  9333. * @param direction The direction in which to blur the image.
  9334. * @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.
  9335. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9336. * @param camera The camera to apply the render pass to.
  9337. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9338. * @param engine The engine which the post process will be applied. (default: current engine)
  9339. * @param reusable If the post process can be reused on the same frame. (default: false)
  9340. * @param textureType Type of textures used when performing the post process. (default: 0)
  9341. * @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)
  9342. */
  9343. constructor(name: string,
  9344. /** The direction in which to blur the image. */
  9345. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9346. /**
  9347. * Updates the effect with the current post process compile time values and recompiles the shader.
  9348. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9349. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9350. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9351. * @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
  9352. * @param onCompiled Called when the shader has been compiled.
  9353. * @param onError Called if there is an error when compiling a shader.
  9354. */
  9355. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9356. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9357. /**
  9358. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9359. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9360. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9361. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9362. * The gaps between physical kernels are compensated for in the weighting of the samples
  9363. * @param idealKernel Ideal blur kernel.
  9364. * @return Nearest best kernel.
  9365. */
  9366. protected _nearestBestKernel(idealKernel: number): number;
  9367. /**
  9368. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9369. * @param x The point on the Gaussian distribution to sample.
  9370. * @return the value of the Gaussian function at x.
  9371. */
  9372. protected _gaussianWeight(x: number): number;
  9373. /**
  9374. * Generates a string that can be used as a floating point number in GLSL.
  9375. * @param x Value to print.
  9376. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9377. * @return GLSL float string.
  9378. */
  9379. protected _glslFloat(x: number, decimalFigures?: number): string;
  9380. }
  9381. }
  9382. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9383. /** @hidden */
  9384. export var shadowMapPixelShader: {
  9385. name: string;
  9386. shader: string;
  9387. };
  9388. }
  9389. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9390. /** @hidden */
  9391. export var bonesDeclaration: {
  9392. name: string;
  9393. shader: string;
  9394. };
  9395. }
  9396. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9397. /** @hidden */
  9398. export var morphTargetsVertexGlobalDeclaration: {
  9399. name: string;
  9400. shader: string;
  9401. };
  9402. }
  9403. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9404. /** @hidden */
  9405. export var morphTargetsVertexDeclaration: {
  9406. name: string;
  9407. shader: string;
  9408. };
  9409. }
  9410. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9411. /** @hidden */
  9412. export var instancesDeclaration: {
  9413. name: string;
  9414. shader: string;
  9415. };
  9416. }
  9417. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9418. /** @hidden */
  9419. export var helperFunctions: {
  9420. name: string;
  9421. shader: string;
  9422. };
  9423. }
  9424. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9425. /** @hidden */
  9426. export var morphTargetsVertex: {
  9427. name: string;
  9428. shader: string;
  9429. };
  9430. }
  9431. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9432. /** @hidden */
  9433. export var instancesVertex: {
  9434. name: string;
  9435. shader: string;
  9436. };
  9437. }
  9438. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9439. /** @hidden */
  9440. export var bonesVertex: {
  9441. name: string;
  9442. shader: string;
  9443. };
  9444. }
  9445. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9446. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9447. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9448. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9449. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9450. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9451. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9452. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9453. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9454. /** @hidden */
  9455. export var shadowMapVertexShader: {
  9456. name: string;
  9457. shader: string;
  9458. };
  9459. }
  9460. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9461. /** @hidden */
  9462. export var depthBoxBlurPixelShader: {
  9463. name: string;
  9464. shader: string;
  9465. };
  9466. }
  9467. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9468. import { Nullable } from "babylonjs/types";
  9469. import { Scene } from "babylonjs/scene";
  9470. import { Matrix } from "babylonjs/Maths/math";
  9471. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9472. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9473. import { Mesh } from "babylonjs/Meshes/mesh";
  9474. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9475. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9476. import { Effect } from "babylonjs/Materials/effect";
  9477. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9478. import "babylonjs/Shaders/shadowMap.fragment";
  9479. import "babylonjs/Shaders/shadowMap.vertex";
  9480. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9481. import { Observable } from "babylonjs/Misc/observable";
  9482. /**
  9483. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9484. */
  9485. export interface ICustomShaderOptions {
  9486. /**
  9487. * Gets or sets the custom shader name to use
  9488. */
  9489. shaderName: string;
  9490. /**
  9491. * The list of attribute names used in the shader
  9492. */
  9493. attributes?: string[];
  9494. /**
  9495. * The list of unifrom names used in the shader
  9496. */
  9497. uniforms?: string[];
  9498. /**
  9499. * The list of sampler names used in the shader
  9500. */
  9501. samplers?: string[];
  9502. /**
  9503. * The list of defines used in the shader
  9504. */
  9505. defines?: string[];
  9506. }
  9507. /**
  9508. * Interface to implement to create a shadow generator compatible with BJS.
  9509. */
  9510. export interface IShadowGenerator {
  9511. /**
  9512. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9513. * @returns The render target texture if present otherwise, null
  9514. */
  9515. getShadowMap(): Nullable<RenderTargetTexture>;
  9516. /**
  9517. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9518. * @returns The render target texture if the shadow map is present otherwise, null
  9519. */
  9520. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9521. /**
  9522. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9523. * @param subMesh The submesh we want to render in the shadow map
  9524. * @param useInstances Defines wether will draw in the map using instances
  9525. * @returns true if ready otherwise, false
  9526. */
  9527. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9528. /**
  9529. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9530. * @param defines Defines of the material we want to update
  9531. * @param lightIndex Index of the light in the enabled light list of the material
  9532. */
  9533. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9534. /**
  9535. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9536. * defined in the generator but impacting the effect).
  9537. * It implies the unifroms available on the materials are the standard BJS ones.
  9538. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9539. * @param effect The effect we are binfing the information for
  9540. */
  9541. bindShadowLight(lightIndex: string, effect: Effect): void;
  9542. /**
  9543. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9544. * (eq to shadow prjection matrix * light transform matrix)
  9545. * @returns The transform matrix used to create the shadow map
  9546. */
  9547. getTransformMatrix(): Matrix;
  9548. /**
  9549. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9550. * Cube and 2D textures for instance.
  9551. */
  9552. recreateShadowMap(): void;
  9553. /**
  9554. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9555. * @param onCompiled Callback triggered at the and of the effects compilation
  9556. * @param options Sets of optional options forcing the compilation with different modes
  9557. */
  9558. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9559. useInstances: boolean;
  9560. }>): void;
  9561. /**
  9562. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9563. * @param options Sets of optional options forcing the compilation with different modes
  9564. * @returns A promise that resolves when the compilation completes
  9565. */
  9566. forceCompilationAsync(options?: Partial<{
  9567. useInstances: boolean;
  9568. }>): Promise<void>;
  9569. /**
  9570. * Serializes the shadow generator setup to a json object.
  9571. * @returns The serialized JSON object
  9572. */
  9573. serialize(): any;
  9574. /**
  9575. * Disposes the Shadow map and related Textures and effects.
  9576. */
  9577. dispose(): void;
  9578. }
  9579. /**
  9580. * Default implementation IShadowGenerator.
  9581. * This is the main object responsible of generating shadows in the framework.
  9582. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9583. */
  9584. export class ShadowGenerator implements IShadowGenerator {
  9585. /**
  9586. * Shadow generator mode None: no filtering applied.
  9587. */
  9588. static readonly FILTER_NONE: number;
  9589. /**
  9590. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9591. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9592. */
  9593. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9594. /**
  9595. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9596. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9597. */
  9598. static readonly FILTER_POISSONSAMPLING: number;
  9599. /**
  9600. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9601. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9602. */
  9603. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9604. /**
  9605. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9606. * edge artifacts on steep falloff.
  9607. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9608. */
  9609. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9610. /**
  9611. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9612. * edge artifacts on steep falloff.
  9613. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9614. */
  9615. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9616. /**
  9617. * Shadow generator mode PCF: Percentage Closer Filtering
  9618. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9619. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9620. */
  9621. static readonly FILTER_PCF: number;
  9622. /**
  9623. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9624. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9625. * Contact Hardening
  9626. */
  9627. static readonly FILTER_PCSS: number;
  9628. /**
  9629. * Reserved for PCF and PCSS
  9630. * Highest Quality.
  9631. *
  9632. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9633. *
  9634. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9635. */
  9636. static readonly QUALITY_HIGH: number;
  9637. /**
  9638. * Reserved for PCF and PCSS
  9639. * Good tradeoff for quality/perf cross devices
  9640. *
  9641. * Execute PCF on a 3*3 kernel.
  9642. *
  9643. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9644. */
  9645. static readonly QUALITY_MEDIUM: number;
  9646. /**
  9647. * Reserved for PCF and PCSS
  9648. * The lowest quality but the fastest.
  9649. *
  9650. * Execute PCF on a 1*1 kernel.
  9651. *
  9652. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9653. */
  9654. static readonly QUALITY_LOW: number;
  9655. /** Gets or sets the custom shader name to use */
  9656. customShaderOptions: ICustomShaderOptions;
  9657. /**
  9658. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9659. */
  9660. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9661. /**
  9662. * Observable triggered before a mesh is rendered in the shadow map.
  9663. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9664. */
  9665. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9666. private _bias;
  9667. /**
  9668. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9669. */
  9670. /**
  9671. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9672. */
  9673. bias: number;
  9674. private _normalBias;
  9675. /**
  9676. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9677. */
  9678. /**
  9679. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9680. */
  9681. normalBias: number;
  9682. private _blurBoxOffset;
  9683. /**
  9684. * Gets the blur box offset: offset applied during the blur pass.
  9685. * Only useful if useKernelBlur = false
  9686. */
  9687. /**
  9688. * Sets the blur box offset: offset applied during the blur pass.
  9689. * Only useful if useKernelBlur = false
  9690. */
  9691. blurBoxOffset: number;
  9692. private _blurScale;
  9693. /**
  9694. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9695. * 2 means half of the size.
  9696. */
  9697. /**
  9698. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9699. * 2 means half of the size.
  9700. */
  9701. blurScale: number;
  9702. private _blurKernel;
  9703. /**
  9704. * Gets the blur kernel: kernel size of the blur pass.
  9705. * Only useful if useKernelBlur = true
  9706. */
  9707. /**
  9708. * Sets the blur kernel: kernel size of the blur pass.
  9709. * Only useful if useKernelBlur = true
  9710. */
  9711. blurKernel: number;
  9712. private _useKernelBlur;
  9713. /**
  9714. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9715. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9716. */
  9717. /**
  9718. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9719. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9720. */
  9721. useKernelBlur: boolean;
  9722. private _depthScale;
  9723. /**
  9724. * Gets the depth scale used in ESM mode.
  9725. */
  9726. /**
  9727. * Sets the depth scale used in ESM mode.
  9728. * This can override the scale stored on the light.
  9729. */
  9730. depthScale: number;
  9731. private _filter;
  9732. /**
  9733. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9734. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9735. */
  9736. /**
  9737. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9738. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9739. */
  9740. filter: number;
  9741. /**
  9742. * Gets if the current filter is set to Poisson Sampling.
  9743. */
  9744. /**
  9745. * Sets the current filter to Poisson Sampling.
  9746. */
  9747. usePoissonSampling: boolean;
  9748. /**
  9749. * Gets if the current filter is set to ESM.
  9750. */
  9751. /**
  9752. * Sets the current filter is to ESM.
  9753. */
  9754. useExponentialShadowMap: boolean;
  9755. /**
  9756. * Gets if the current filter is set to filtered ESM.
  9757. */
  9758. /**
  9759. * Gets if the current filter is set to filtered ESM.
  9760. */
  9761. useBlurExponentialShadowMap: boolean;
  9762. /**
  9763. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9764. * exponential to prevent steep falloff artifacts).
  9765. */
  9766. /**
  9767. * Sets the current filter to "close ESM" (using the inverse of the
  9768. * exponential to prevent steep falloff artifacts).
  9769. */
  9770. useCloseExponentialShadowMap: boolean;
  9771. /**
  9772. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9773. * exponential to prevent steep falloff artifacts).
  9774. */
  9775. /**
  9776. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9777. * exponential to prevent steep falloff artifacts).
  9778. */
  9779. useBlurCloseExponentialShadowMap: boolean;
  9780. /**
  9781. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9782. */
  9783. /**
  9784. * Sets the current filter to "PCF" (percentage closer filtering).
  9785. */
  9786. usePercentageCloserFiltering: boolean;
  9787. private _filteringQuality;
  9788. /**
  9789. * Gets the PCF or PCSS Quality.
  9790. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9791. */
  9792. /**
  9793. * Sets the PCF or PCSS Quality.
  9794. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9795. */
  9796. filteringQuality: number;
  9797. /**
  9798. * Gets if the current filter is set to "PCSS" (contact hardening).
  9799. */
  9800. /**
  9801. * Sets the current filter to "PCSS" (contact hardening).
  9802. */
  9803. useContactHardeningShadow: boolean;
  9804. private _contactHardeningLightSizeUVRatio;
  9805. /**
  9806. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9807. * Using a ratio helps keeping shape stability independently of the map size.
  9808. *
  9809. * It does not account for the light projection as it was having too much
  9810. * instability during the light setup or during light position changes.
  9811. *
  9812. * Only valid if useContactHardeningShadow is true.
  9813. */
  9814. /**
  9815. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9816. * Using a ratio helps keeping shape stability independently of the map size.
  9817. *
  9818. * It does not account for the light projection as it was having too much
  9819. * instability during the light setup or during light position changes.
  9820. *
  9821. * Only valid if useContactHardeningShadow is true.
  9822. */
  9823. contactHardeningLightSizeUVRatio: number;
  9824. private _darkness;
  9825. /**
  9826. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9827. * 0 means strongest and 1 would means no shadow.
  9828. * @returns the darkness.
  9829. */
  9830. getDarkness(): number;
  9831. /**
  9832. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9833. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9834. * @returns the shadow generator allowing fluent coding.
  9835. */
  9836. setDarkness(darkness: number): ShadowGenerator;
  9837. private _transparencyShadow;
  9838. /**
  9839. * Sets the ability to have transparent shadow (boolean).
  9840. * @param transparent True if transparent else False
  9841. * @returns the shadow generator allowing fluent coding
  9842. */
  9843. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9844. private _shadowMap;
  9845. private _shadowMap2;
  9846. /**
  9847. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9848. * @returns The render target texture if present otherwise, null
  9849. */
  9850. getShadowMap(): Nullable<RenderTargetTexture>;
  9851. /**
  9852. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9853. * @returns The render target texture if the shadow map is present otherwise, null
  9854. */
  9855. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9856. /**
  9857. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9858. * @param mesh Mesh to add
  9859. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9860. * @returns the Shadow Generator itself
  9861. */
  9862. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9863. /**
  9864. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9865. * @param mesh Mesh to remove
  9866. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9867. * @returns the Shadow Generator itself
  9868. */
  9869. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9870. /**
  9871. * Controls the extent to which the shadows fade out at the edge of the frustum
  9872. * Used only by directionals and spots
  9873. */
  9874. frustumEdgeFalloff: number;
  9875. private _light;
  9876. /**
  9877. * Returns the associated light object.
  9878. * @returns the light generating the shadow
  9879. */
  9880. getLight(): IShadowLight;
  9881. /**
  9882. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9883. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9884. * It might on the other hand introduce peter panning.
  9885. */
  9886. forceBackFacesOnly: boolean;
  9887. private _scene;
  9888. private _lightDirection;
  9889. private _effect;
  9890. private _viewMatrix;
  9891. private _projectionMatrix;
  9892. private _transformMatrix;
  9893. private _cachedPosition;
  9894. private _cachedDirection;
  9895. private _cachedDefines;
  9896. private _currentRenderID;
  9897. private _boxBlurPostprocess;
  9898. private _kernelBlurXPostprocess;
  9899. private _kernelBlurYPostprocess;
  9900. private _blurPostProcesses;
  9901. private _mapSize;
  9902. private _currentFaceIndex;
  9903. private _currentFaceIndexCache;
  9904. private _textureType;
  9905. private _defaultTextureMatrix;
  9906. /** @hidden */
  9907. static _SceneComponentInitialization: (scene: Scene) => void;
  9908. /**
  9909. * Creates a ShadowGenerator object.
  9910. * A ShadowGenerator is the required tool to use the shadows.
  9911. * Each light casting shadows needs to use its own ShadowGenerator.
  9912. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9913. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9914. * @param light The light object generating the shadows.
  9915. * @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.
  9916. */
  9917. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9918. private _initializeGenerator;
  9919. private _initializeShadowMap;
  9920. private _initializeBlurRTTAndPostProcesses;
  9921. private _renderForShadowMap;
  9922. private _renderSubMeshForShadowMap;
  9923. private _applyFilterValues;
  9924. /**
  9925. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9926. * @param onCompiled Callback triggered at the and of the effects compilation
  9927. * @param options Sets of optional options forcing the compilation with different modes
  9928. */
  9929. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9930. useInstances: boolean;
  9931. }>): void;
  9932. /**
  9933. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9934. * @param options Sets of optional options forcing the compilation with different modes
  9935. * @returns A promise that resolves when the compilation completes
  9936. */
  9937. forceCompilationAsync(options?: Partial<{
  9938. useInstances: boolean;
  9939. }>): Promise<void>;
  9940. /**
  9941. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9942. * @param subMesh The submesh we want to render in the shadow map
  9943. * @param useInstances Defines wether will draw in the map using instances
  9944. * @returns true if ready otherwise, false
  9945. */
  9946. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9947. /**
  9948. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9949. * @param defines Defines of the material we want to update
  9950. * @param lightIndex Index of the light in the enabled light list of the material
  9951. */
  9952. prepareDefines(defines: any, lightIndex: number): void;
  9953. /**
  9954. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9955. * defined in the generator but impacting the effect).
  9956. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9957. * @param effect The effect we are binfing the information for
  9958. */
  9959. bindShadowLight(lightIndex: string, effect: Effect): void;
  9960. /**
  9961. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9962. * (eq to shadow prjection matrix * light transform matrix)
  9963. * @returns The transform matrix used to create the shadow map
  9964. */
  9965. getTransformMatrix(): Matrix;
  9966. /**
  9967. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9968. * Cube and 2D textures for instance.
  9969. */
  9970. recreateShadowMap(): void;
  9971. private _disposeBlurPostProcesses;
  9972. private _disposeRTTandPostProcesses;
  9973. /**
  9974. * Disposes the ShadowGenerator.
  9975. * Returns nothing.
  9976. */
  9977. dispose(): void;
  9978. /**
  9979. * Serializes the shadow generator setup to a json object.
  9980. * @returns The serialized JSON object
  9981. */
  9982. serialize(): any;
  9983. /**
  9984. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9985. * @param parsedShadowGenerator The JSON object to parse
  9986. * @param scene The scene to create the shadow map for
  9987. * @returns The parsed shadow generator
  9988. */
  9989. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9990. }
  9991. }
  9992. declare module "babylonjs/Lights/light" {
  9993. import { Nullable } from "babylonjs/types";
  9994. import { Scene } from "babylonjs/scene";
  9995. import { Vector3, Color3 } from "babylonjs/Maths/math";
  9996. import { Node } from "babylonjs/node";
  9997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9998. import { Effect } from "babylonjs/Materials/effect";
  9999. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10000. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10001. /**
  10002. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10003. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10004. * 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.
  10005. */
  10006. export abstract class Light extends Node {
  10007. /**
  10008. * Falloff Default: light is falling off following the material specification:
  10009. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10010. */
  10011. static readonly FALLOFF_DEFAULT: number;
  10012. /**
  10013. * Falloff Physical: light is falling off following the inverse squared distance law.
  10014. */
  10015. static readonly FALLOFF_PHYSICAL: number;
  10016. /**
  10017. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10018. * to enhance interoperability with other engines.
  10019. */
  10020. static readonly FALLOFF_GLTF: number;
  10021. /**
  10022. * Falloff Standard: light is falling off like in the standard material
  10023. * to enhance interoperability with other materials.
  10024. */
  10025. static readonly FALLOFF_STANDARD: number;
  10026. /**
  10027. * If every light affecting the material is in this lightmapMode,
  10028. * material.lightmapTexture adds or multiplies
  10029. * (depends on material.useLightmapAsShadowmap)
  10030. * after every other light calculations.
  10031. */
  10032. static readonly LIGHTMAP_DEFAULT: number;
  10033. /**
  10034. * material.lightmapTexture as only diffuse lighting from this light
  10035. * adds only specular lighting from this light
  10036. * adds dynamic shadows
  10037. */
  10038. static readonly LIGHTMAP_SPECULAR: number;
  10039. /**
  10040. * material.lightmapTexture as only lighting
  10041. * no light calculation from this light
  10042. * only adds dynamic shadows from this light
  10043. */
  10044. static readonly LIGHTMAP_SHADOWSONLY: number;
  10045. /**
  10046. * Each light type uses the default quantity according to its type:
  10047. * point/spot lights use luminous intensity
  10048. * directional lights use illuminance
  10049. */
  10050. static readonly INTENSITYMODE_AUTOMATIC: number;
  10051. /**
  10052. * lumen (lm)
  10053. */
  10054. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10055. /**
  10056. * candela (lm/sr)
  10057. */
  10058. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10059. /**
  10060. * lux (lm/m^2)
  10061. */
  10062. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10063. /**
  10064. * nit (cd/m^2)
  10065. */
  10066. static readonly INTENSITYMODE_LUMINANCE: number;
  10067. /**
  10068. * Light type const id of the point light.
  10069. */
  10070. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10071. /**
  10072. * Light type const id of the directional light.
  10073. */
  10074. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10075. /**
  10076. * Light type const id of the spot light.
  10077. */
  10078. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10079. /**
  10080. * Light type const id of the hemispheric light.
  10081. */
  10082. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10083. /**
  10084. * Diffuse gives the basic color to an object.
  10085. */
  10086. diffuse: Color3;
  10087. /**
  10088. * Specular produces a highlight color on an object.
  10089. * Note: This is note affecting PBR materials.
  10090. */
  10091. specular: Color3;
  10092. /**
  10093. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10094. * falling off base on range or angle.
  10095. * This can be set to any values in Light.FALLOFF_x.
  10096. *
  10097. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10098. * other types of materials.
  10099. */
  10100. falloffType: number;
  10101. /**
  10102. * Strength of the light.
  10103. * Note: By default it is define in the framework own unit.
  10104. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10105. */
  10106. intensity: number;
  10107. private _range;
  10108. protected _inverseSquaredRange: number;
  10109. /**
  10110. * Defines how far from the source the light is impacting in scene units.
  10111. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10112. */
  10113. /**
  10114. * Defines how far from the source the light is impacting in scene units.
  10115. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10116. */
  10117. range: number;
  10118. /**
  10119. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10120. * of light.
  10121. */
  10122. private _photometricScale;
  10123. private _intensityMode;
  10124. /**
  10125. * Gets the photometric scale used to interpret the intensity.
  10126. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10127. */
  10128. /**
  10129. * Sets the photometric scale used to interpret the intensity.
  10130. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10131. */
  10132. intensityMode: number;
  10133. private _radius;
  10134. /**
  10135. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10136. */
  10137. /**
  10138. * sets the light radius used by PBR Materials to simulate soft area lights.
  10139. */
  10140. radius: number;
  10141. private _renderPriority;
  10142. /**
  10143. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10144. * exceeding the number allowed of the materials.
  10145. */
  10146. renderPriority: number;
  10147. private _shadowEnabled;
  10148. /**
  10149. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10150. * the current shadow generator.
  10151. */
  10152. /**
  10153. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10154. * the current shadow generator.
  10155. */
  10156. shadowEnabled: boolean;
  10157. private _includedOnlyMeshes;
  10158. /**
  10159. * Gets the only meshes impacted by this light.
  10160. */
  10161. /**
  10162. * Sets the only meshes impacted by this light.
  10163. */
  10164. includedOnlyMeshes: AbstractMesh[];
  10165. private _excludedMeshes;
  10166. /**
  10167. * Gets the meshes not impacted by this light.
  10168. */
  10169. /**
  10170. * Sets the meshes not impacted by this light.
  10171. */
  10172. excludedMeshes: AbstractMesh[];
  10173. private _excludeWithLayerMask;
  10174. /**
  10175. * Gets the layer id use to find what meshes are not impacted by the light.
  10176. * Inactive if 0
  10177. */
  10178. /**
  10179. * Sets the layer id use to find what meshes are not impacted by the light.
  10180. * Inactive if 0
  10181. */
  10182. excludeWithLayerMask: number;
  10183. private _includeOnlyWithLayerMask;
  10184. /**
  10185. * Gets the layer id use to find what meshes are impacted by the light.
  10186. * Inactive if 0
  10187. */
  10188. /**
  10189. * Sets the layer id use to find what meshes are impacted by the light.
  10190. * Inactive if 0
  10191. */
  10192. includeOnlyWithLayerMask: number;
  10193. private _lightmapMode;
  10194. /**
  10195. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10196. */
  10197. /**
  10198. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10199. */
  10200. lightmapMode: number;
  10201. /**
  10202. * Shadow generator associted to the light.
  10203. * @hidden Internal use only.
  10204. */
  10205. _shadowGenerator: Nullable<IShadowGenerator>;
  10206. /**
  10207. * @hidden Internal use only.
  10208. */
  10209. _excludedMeshesIds: string[];
  10210. /**
  10211. * @hidden Internal use only.
  10212. */
  10213. _includedOnlyMeshesIds: string[];
  10214. /**
  10215. * The current light unifom buffer.
  10216. * @hidden Internal use only.
  10217. */
  10218. _uniformBuffer: UniformBuffer;
  10219. /**
  10220. * Creates a Light object in the scene.
  10221. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10222. * @param name The firendly name of the light
  10223. * @param scene The scene the light belongs too
  10224. */
  10225. constructor(name: string, scene: Scene);
  10226. protected abstract _buildUniformLayout(): void;
  10227. /**
  10228. * Sets the passed Effect "effect" with the Light information.
  10229. * @param effect The effect to update
  10230. * @param lightIndex The index of the light in the effect to update
  10231. * @returns The light
  10232. */
  10233. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10234. /**
  10235. * Returns the string "Light".
  10236. * @returns the class name
  10237. */
  10238. getClassName(): string;
  10239. /** @hidden */
  10240. readonly _isLight: boolean;
  10241. /**
  10242. * Converts the light information to a readable string for debug purpose.
  10243. * @param fullDetails Supports for multiple levels of logging within scene loading
  10244. * @returns the human readable light info
  10245. */
  10246. toString(fullDetails?: boolean): string;
  10247. /** @hidden */
  10248. protected _syncParentEnabledState(): void;
  10249. /**
  10250. * Set the enabled state of this node.
  10251. * @param value - the new enabled state
  10252. */
  10253. setEnabled(value: boolean): void;
  10254. /**
  10255. * Returns the Light associated shadow generator if any.
  10256. * @return the associated shadow generator.
  10257. */
  10258. getShadowGenerator(): Nullable<IShadowGenerator>;
  10259. /**
  10260. * Returns a Vector3, the absolute light position in the World.
  10261. * @returns the world space position of the light
  10262. */
  10263. getAbsolutePosition(): Vector3;
  10264. /**
  10265. * Specifies if the light will affect the passed mesh.
  10266. * @param mesh The mesh to test against the light
  10267. * @return true the mesh is affected otherwise, false.
  10268. */
  10269. canAffectMesh(mesh: AbstractMesh): boolean;
  10270. /**
  10271. * Sort function to order lights for rendering.
  10272. * @param a First Light object to compare to second.
  10273. * @param b Second Light object to compare first.
  10274. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10275. */
  10276. static CompareLightsPriority(a: Light, b: Light): number;
  10277. /**
  10278. * Releases resources associated with this node.
  10279. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10280. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10281. */
  10282. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10283. /**
  10284. * Returns the light type ID (integer).
  10285. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10286. */
  10287. getTypeID(): number;
  10288. /**
  10289. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10290. * @returns the scaled intensity in intensity mode unit
  10291. */
  10292. getScaledIntensity(): number;
  10293. /**
  10294. * Returns a new Light object, named "name", from the current one.
  10295. * @param name The name of the cloned light
  10296. * @returns the new created light
  10297. */
  10298. clone(name: string): Nullable<Light>;
  10299. /**
  10300. * Serializes the current light into a Serialization object.
  10301. * @returns the serialized object.
  10302. */
  10303. serialize(): any;
  10304. /**
  10305. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10306. * This new light is named "name" and added to the passed scene.
  10307. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10308. * @param name The friendly name of the light
  10309. * @param scene The scene the new light will belong to
  10310. * @returns the constructor function
  10311. */
  10312. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10313. /**
  10314. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10315. * @param parsedLight The JSON representation of the light
  10316. * @param scene The scene to create the parsed light in
  10317. * @returns the created light after parsing
  10318. */
  10319. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10320. private _hookArrayForExcluded;
  10321. private _hookArrayForIncludedOnly;
  10322. private _resyncMeshes;
  10323. /**
  10324. * Forces the meshes to update their light related information in their rendering used effects
  10325. * @hidden Internal Use Only
  10326. */
  10327. _markMeshesAsLightDirty(): void;
  10328. /**
  10329. * Recomputes the cached photometric scale if needed.
  10330. */
  10331. private _computePhotometricScale;
  10332. /**
  10333. * Returns the Photometric Scale according to the light type and intensity mode.
  10334. */
  10335. private _getPhotometricScale;
  10336. /**
  10337. * Reorder the light in the scene according to their defined priority.
  10338. * @hidden Internal Use Only
  10339. */
  10340. _reorderLightsInScene(): void;
  10341. /**
  10342. * Prepares the list of defines specific to the light type.
  10343. * @param defines the list of defines
  10344. * @param lightIndex defines the index of the light for the effect
  10345. */
  10346. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10347. }
  10348. }
  10349. declare module "babylonjs/Actions/action" {
  10350. import { Observable } from "babylonjs/Misc/observable";
  10351. import { Condition } from "babylonjs/Actions/condition";
  10352. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10353. import { ActionManager } from "babylonjs/Actions/actionManager";
  10354. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10355. /**
  10356. * Interface used to define Action
  10357. */
  10358. export interface IAction {
  10359. /**
  10360. * Trigger for the action
  10361. */
  10362. trigger: number;
  10363. /** Options of the trigger */
  10364. triggerOptions: any;
  10365. /**
  10366. * Gets the trigger parameters
  10367. * @returns the trigger parameters
  10368. */
  10369. getTriggerParameter(): any;
  10370. /**
  10371. * Internal only - executes current action event
  10372. * @hidden
  10373. */
  10374. _executeCurrent(evt?: ActionEvent): void;
  10375. /**
  10376. * Serialize placeholder for child classes
  10377. * @param parent of child
  10378. * @returns the serialized object
  10379. */
  10380. serialize(parent: any): any;
  10381. /**
  10382. * Internal only
  10383. * @hidden
  10384. */
  10385. _prepare(): void;
  10386. /**
  10387. * Internal only - manager for action
  10388. * @hidden
  10389. */
  10390. _actionManager: AbstractActionManager;
  10391. }
  10392. /**
  10393. * The action to be carried out following a trigger
  10394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10395. */
  10396. export class Action implements IAction {
  10397. /** the trigger, with or without parameters, for the action */
  10398. triggerOptions: any;
  10399. /**
  10400. * Trigger for the action
  10401. */
  10402. trigger: number;
  10403. /**
  10404. * Internal only - manager for action
  10405. * @hidden
  10406. */
  10407. _actionManager: ActionManager;
  10408. private _nextActiveAction;
  10409. private _child;
  10410. private _condition?;
  10411. private _triggerParameter;
  10412. /**
  10413. * An event triggered prior to action being executed.
  10414. */
  10415. onBeforeExecuteObservable: Observable<Action>;
  10416. /**
  10417. * Creates a new Action
  10418. * @param triggerOptions the trigger, with or without parameters, for the action
  10419. * @param condition an optional determinant of action
  10420. */
  10421. constructor(
  10422. /** the trigger, with or without parameters, for the action */
  10423. triggerOptions: any, condition?: Condition);
  10424. /**
  10425. * Internal only
  10426. * @hidden
  10427. */
  10428. _prepare(): void;
  10429. /**
  10430. * Gets the trigger parameters
  10431. * @returns the trigger parameters
  10432. */
  10433. getTriggerParameter(): any;
  10434. /**
  10435. * Internal only - executes current action event
  10436. * @hidden
  10437. */
  10438. _executeCurrent(evt?: ActionEvent): void;
  10439. /**
  10440. * Execute placeholder for child classes
  10441. * @param evt optional action event
  10442. */
  10443. execute(evt?: ActionEvent): void;
  10444. /**
  10445. * Skips to next active action
  10446. */
  10447. skipToNextActiveAction(): void;
  10448. /**
  10449. * Adds action to chain of actions, may be a DoNothingAction
  10450. * @param action defines the next action to execute
  10451. * @returns The action passed in
  10452. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10453. */
  10454. then(action: Action): Action;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. _getProperty(propertyPath: string): string;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. _getEffectiveTarget(target: any, propertyPath: string): any;
  10465. /**
  10466. * Serialize placeholder for child classes
  10467. * @param parent of child
  10468. * @returns the serialized object
  10469. */
  10470. serialize(parent: any): any;
  10471. /**
  10472. * Internal only called by serialize
  10473. * @hidden
  10474. */
  10475. protected _serialize(serializedAction: any, parent?: any): any;
  10476. /**
  10477. * Internal only
  10478. * @hidden
  10479. */
  10480. static _SerializeValueAsString: (value: any) => string;
  10481. /**
  10482. * Internal only
  10483. * @hidden
  10484. */
  10485. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10486. name: string;
  10487. targetType: string;
  10488. value: string;
  10489. };
  10490. }
  10491. }
  10492. declare module "babylonjs/Actions/condition" {
  10493. import { ActionManager } from "babylonjs/Actions/actionManager";
  10494. /**
  10495. * A Condition applied to an Action
  10496. */
  10497. export class Condition {
  10498. /**
  10499. * Internal only - manager for action
  10500. * @hidden
  10501. */
  10502. _actionManager: ActionManager;
  10503. /**
  10504. * Internal only
  10505. * @hidden
  10506. */
  10507. _evaluationId: number;
  10508. /**
  10509. * Internal only
  10510. * @hidden
  10511. */
  10512. _currentResult: boolean;
  10513. /**
  10514. * Creates a new Condition
  10515. * @param actionManager the manager of the action the condition is applied to
  10516. */
  10517. constructor(actionManager: ActionManager);
  10518. /**
  10519. * Check if the current condition is valid
  10520. * @returns a boolean
  10521. */
  10522. isValid(): boolean;
  10523. /**
  10524. * Internal only
  10525. * @hidden
  10526. */
  10527. _getProperty(propertyPath: string): string;
  10528. /**
  10529. * Internal only
  10530. * @hidden
  10531. */
  10532. _getEffectiveTarget(target: any, propertyPath: string): any;
  10533. /**
  10534. * Serialize placeholder for child classes
  10535. * @returns the serialized object
  10536. */
  10537. serialize(): any;
  10538. /**
  10539. * Internal only
  10540. * @hidden
  10541. */
  10542. protected _serialize(serializedCondition: any): any;
  10543. }
  10544. /**
  10545. * Defines specific conditional operators as extensions of Condition
  10546. */
  10547. export class ValueCondition extends Condition {
  10548. /** path to specify the property of the target the conditional operator uses */
  10549. propertyPath: string;
  10550. /** the value compared by the conditional operator against the current value of the property */
  10551. value: any;
  10552. /** the conditional operator, default ValueCondition.IsEqual */
  10553. operator: number;
  10554. /**
  10555. * Internal only
  10556. * @hidden
  10557. */
  10558. private static _IsEqual;
  10559. /**
  10560. * Internal only
  10561. * @hidden
  10562. */
  10563. private static _IsDifferent;
  10564. /**
  10565. * Internal only
  10566. * @hidden
  10567. */
  10568. private static _IsGreater;
  10569. /**
  10570. * Internal only
  10571. * @hidden
  10572. */
  10573. private static _IsLesser;
  10574. /**
  10575. * returns the number for IsEqual
  10576. */
  10577. static readonly IsEqual: number;
  10578. /**
  10579. * Returns the number for IsDifferent
  10580. */
  10581. static readonly IsDifferent: number;
  10582. /**
  10583. * Returns the number for IsGreater
  10584. */
  10585. static readonly IsGreater: number;
  10586. /**
  10587. * Returns the number for IsLesser
  10588. */
  10589. static readonly IsLesser: number;
  10590. /**
  10591. * Internal only The action manager for the condition
  10592. * @hidden
  10593. */
  10594. _actionManager: ActionManager;
  10595. /**
  10596. * Internal only
  10597. * @hidden
  10598. */
  10599. private _target;
  10600. /**
  10601. * Internal only
  10602. * @hidden
  10603. */
  10604. private _effectiveTarget;
  10605. /**
  10606. * Internal only
  10607. * @hidden
  10608. */
  10609. private _property;
  10610. /**
  10611. * Creates a new ValueCondition
  10612. * @param actionManager manager for the action the condition applies to
  10613. * @param target for the action
  10614. * @param propertyPath path to specify the property of the target the conditional operator uses
  10615. * @param value the value compared by the conditional operator against the current value of the property
  10616. * @param operator the conditional operator, default ValueCondition.IsEqual
  10617. */
  10618. constructor(actionManager: ActionManager, target: any,
  10619. /** path to specify the property of the target the conditional operator uses */
  10620. propertyPath: string,
  10621. /** the value compared by the conditional operator against the current value of the property */
  10622. value: any,
  10623. /** the conditional operator, default ValueCondition.IsEqual */
  10624. operator?: number);
  10625. /**
  10626. * Compares the given value with the property value for the specified conditional operator
  10627. * @returns the result of the comparison
  10628. */
  10629. isValid(): boolean;
  10630. /**
  10631. * Serialize the ValueCondition into a JSON compatible object
  10632. * @returns serialization object
  10633. */
  10634. serialize(): any;
  10635. /**
  10636. * Gets the name of the conditional operator for the ValueCondition
  10637. * @param operator the conditional operator
  10638. * @returns the name
  10639. */
  10640. static GetOperatorName(operator: number): string;
  10641. }
  10642. /**
  10643. * Defines a predicate condition as an extension of Condition
  10644. */
  10645. export class PredicateCondition extends Condition {
  10646. /** defines the predicate function used to validate the condition */
  10647. predicate: () => boolean;
  10648. /**
  10649. * Internal only - manager for action
  10650. * @hidden
  10651. */
  10652. _actionManager: ActionManager;
  10653. /**
  10654. * Creates a new PredicateCondition
  10655. * @param actionManager manager for the action the condition applies to
  10656. * @param predicate defines the predicate function used to validate the condition
  10657. */
  10658. constructor(actionManager: ActionManager,
  10659. /** defines the predicate function used to validate the condition */
  10660. predicate: () => boolean);
  10661. /**
  10662. * @returns the validity of the predicate condition
  10663. */
  10664. isValid(): boolean;
  10665. }
  10666. /**
  10667. * Defines a state condition as an extension of Condition
  10668. */
  10669. export class StateCondition extends Condition {
  10670. /** Value to compare with target state */
  10671. value: string;
  10672. /**
  10673. * Internal only - manager for action
  10674. * @hidden
  10675. */
  10676. _actionManager: ActionManager;
  10677. /**
  10678. * Internal only
  10679. * @hidden
  10680. */
  10681. private _target;
  10682. /**
  10683. * Creates a new StateCondition
  10684. * @param actionManager manager for the action the condition applies to
  10685. * @param target of the condition
  10686. * @param value to compare with target state
  10687. */
  10688. constructor(actionManager: ActionManager, target: any,
  10689. /** Value to compare with target state */
  10690. value: string);
  10691. /**
  10692. * Gets a boolean indicating if the current condition is met
  10693. * @returns the validity of the state
  10694. */
  10695. isValid(): boolean;
  10696. /**
  10697. * Serialize the StateCondition into a JSON compatible object
  10698. * @returns serialization object
  10699. */
  10700. serialize(): any;
  10701. }
  10702. }
  10703. declare module "babylonjs/Actions/directActions" {
  10704. import { Action } from "babylonjs/Actions/action";
  10705. import { Condition } from "babylonjs/Actions/condition";
  10706. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10707. /**
  10708. * This defines an action responsible to toggle a boolean once triggered.
  10709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10710. */
  10711. export class SwitchBooleanAction extends Action {
  10712. /**
  10713. * The path to the boolean property in the target object
  10714. */
  10715. propertyPath: string;
  10716. private _target;
  10717. private _effectiveTarget;
  10718. private _property;
  10719. /**
  10720. * Instantiate the action
  10721. * @param triggerOptions defines the trigger options
  10722. * @param target defines the object containing the boolean
  10723. * @param propertyPath defines the path to the boolean property in the target object
  10724. * @param condition defines the trigger related conditions
  10725. */
  10726. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10727. /** @hidden */
  10728. _prepare(): void;
  10729. /**
  10730. * Execute the action toggle the boolean value.
  10731. */
  10732. execute(): void;
  10733. /**
  10734. * Serializes the actions and its related information.
  10735. * @param parent defines the object to serialize in
  10736. * @returns the serialized object
  10737. */
  10738. serialize(parent: any): any;
  10739. }
  10740. /**
  10741. * This defines an action responsible to set a the state field of the target
  10742. * to a desired value once triggered.
  10743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10744. */
  10745. export class SetStateAction extends Action {
  10746. /**
  10747. * The value to store in the state field.
  10748. */
  10749. value: string;
  10750. private _target;
  10751. /**
  10752. * Instantiate the action
  10753. * @param triggerOptions defines the trigger options
  10754. * @param target defines the object containing the state property
  10755. * @param value defines the value to store in the state field
  10756. * @param condition defines the trigger related conditions
  10757. */
  10758. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10759. /**
  10760. * Execute the action and store the value on the target state property.
  10761. */
  10762. execute(): void;
  10763. /**
  10764. * Serializes the actions and its related information.
  10765. * @param parent defines the object to serialize in
  10766. * @returns the serialized object
  10767. */
  10768. serialize(parent: any): any;
  10769. }
  10770. /**
  10771. * This defines an action responsible to set a property of the target
  10772. * to a desired value once triggered.
  10773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10774. */
  10775. export class SetValueAction extends Action {
  10776. /**
  10777. * The path of the property to set in the target.
  10778. */
  10779. propertyPath: string;
  10780. /**
  10781. * The value to set in the property
  10782. */
  10783. value: any;
  10784. private _target;
  10785. private _effectiveTarget;
  10786. private _property;
  10787. /**
  10788. * Instantiate the action
  10789. * @param triggerOptions defines the trigger options
  10790. * @param target defines the object containing the property
  10791. * @param propertyPath defines the path of the property to set in the target
  10792. * @param value defines the value to set in the property
  10793. * @param condition defines the trigger related conditions
  10794. */
  10795. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10796. /** @hidden */
  10797. _prepare(): void;
  10798. /**
  10799. * Execute the action and set the targetted property to the desired value.
  10800. */
  10801. execute(): void;
  10802. /**
  10803. * Serializes the actions and its related information.
  10804. * @param parent defines the object to serialize in
  10805. * @returns the serialized object
  10806. */
  10807. serialize(parent: any): any;
  10808. }
  10809. /**
  10810. * This defines an action responsible to increment the target value
  10811. * to a desired value once triggered.
  10812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10813. */
  10814. export class IncrementValueAction extends Action {
  10815. /**
  10816. * The path of the property to increment in the target.
  10817. */
  10818. propertyPath: string;
  10819. /**
  10820. * The value we should increment the property by.
  10821. */
  10822. value: any;
  10823. private _target;
  10824. private _effectiveTarget;
  10825. private _property;
  10826. /**
  10827. * Instantiate the action
  10828. * @param triggerOptions defines the trigger options
  10829. * @param target defines the object containing the property
  10830. * @param propertyPath defines the path of the property to increment in the target
  10831. * @param value defines the value value we should increment the property by
  10832. * @param condition defines the trigger related conditions
  10833. */
  10834. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10835. /** @hidden */
  10836. _prepare(): void;
  10837. /**
  10838. * Execute the action and increment the target of the value amount.
  10839. */
  10840. execute(): void;
  10841. /**
  10842. * Serializes the actions and its related information.
  10843. * @param parent defines the object to serialize in
  10844. * @returns the serialized object
  10845. */
  10846. serialize(parent: any): any;
  10847. }
  10848. /**
  10849. * This defines an action responsible to start an animation once triggered.
  10850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10851. */
  10852. export class PlayAnimationAction extends Action {
  10853. /**
  10854. * Where the animation should start (animation frame)
  10855. */
  10856. from: number;
  10857. /**
  10858. * Where the animation should stop (animation frame)
  10859. */
  10860. to: number;
  10861. /**
  10862. * Define if the animation should loop or stop after the first play.
  10863. */
  10864. loop?: boolean;
  10865. private _target;
  10866. /**
  10867. * Instantiate the action
  10868. * @param triggerOptions defines the trigger options
  10869. * @param target defines the target animation or animation name
  10870. * @param from defines from where the animation should start (animation frame)
  10871. * @param end defines where the animation should stop (animation frame)
  10872. * @param loop defines if the animation should loop or stop after the first play
  10873. * @param condition defines the trigger related conditions
  10874. */
  10875. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10876. /** @hidden */
  10877. _prepare(): void;
  10878. /**
  10879. * Execute the action and play the animation.
  10880. */
  10881. execute(): void;
  10882. /**
  10883. * Serializes the actions and its related information.
  10884. * @param parent defines the object to serialize in
  10885. * @returns the serialized object
  10886. */
  10887. serialize(parent: any): any;
  10888. }
  10889. /**
  10890. * This defines an action responsible to stop an animation once triggered.
  10891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10892. */
  10893. export class StopAnimationAction extends Action {
  10894. private _target;
  10895. /**
  10896. * Instantiate the action
  10897. * @param triggerOptions defines the trigger options
  10898. * @param target defines the target animation or animation name
  10899. * @param condition defines the trigger related conditions
  10900. */
  10901. constructor(triggerOptions: any, target: any, condition?: Condition);
  10902. /** @hidden */
  10903. _prepare(): void;
  10904. /**
  10905. * Execute the action and stop the animation.
  10906. */
  10907. execute(): void;
  10908. /**
  10909. * Serializes the actions and its related information.
  10910. * @param parent defines the object to serialize in
  10911. * @returns the serialized object
  10912. */
  10913. serialize(parent: any): any;
  10914. }
  10915. /**
  10916. * This defines an action responsible that does nothing once triggered.
  10917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10918. */
  10919. export class DoNothingAction extends Action {
  10920. /**
  10921. * Instantiate the action
  10922. * @param triggerOptions defines the trigger options
  10923. * @param condition defines the trigger related conditions
  10924. */
  10925. constructor(triggerOptions?: any, condition?: Condition);
  10926. /**
  10927. * Execute the action and do nothing.
  10928. */
  10929. execute(): void;
  10930. /**
  10931. * Serializes the actions and its related information.
  10932. * @param parent defines the object to serialize in
  10933. * @returns the serialized object
  10934. */
  10935. serialize(parent: any): any;
  10936. }
  10937. /**
  10938. * This defines an action responsible to trigger several actions once triggered.
  10939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10940. */
  10941. export class CombineAction extends Action {
  10942. /**
  10943. * The list of aggregated animations to run.
  10944. */
  10945. children: Action[];
  10946. /**
  10947. * Instantiate the action
  10948. * @param triggerOptions defines the trigger options
  10949. * @param children defines the list of aggregated animations to run
  10950. * @param condition defines the trigger related conditions
  10951. */
  10952. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10953. /** @hidden */
  10954. _prepare(): void;
  10955. /**
  10956. * Execute the action and executes all the aggregated actions.
  10957. */
  10958. execute(evt: ActionEvent): void;
  10959. /**
  10960. * Serializes the actions and its related information.
  10961. * @param parent defines the object to serialize in
  10962. * @returns the serialized object
  10963. */
  10964. serialize(parent: any): any;
  10965. }
  10966. /**
  10967. * This defines an action responsible to run code (external event) once triggered.
  10968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10969. */
  10970. export class ExecuteCodeAction extends Action {
  10971. /**
  10972. * The callback function to run.
  10973. */
  10974. func: (evt: ActionEvent) => void;
  10975. /**
  10976. * Instantiate the action
  10977. * @param triggerOptions defines the trigger options
  10978. * @param func defines the callback function to run
  10979. * @param condition defines the trigger related conditions
  10980. */
  10981. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10982. /**
  10983. * Execute the action and run the attached code.
  10984. */
  10985. execute(evt: ActionEvent): void;
  10986. }
  10987. /**
  10988. * This defines an action responsible to set the parent property of the target once triggered.
  10989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10990. */
  10991. export class SetParentAction extends Action {
  10992. private _parent;
  10993. private _target;
  10994. /**
  10995. * Instantiate the action
  10996. * @param triggerOptions defines the trigger options
  10997. * @param target defines the target containing the parent property
  10998. * @param parent defines from where the animation should start (animation frame)
  10999. * @param condition defines the trigger related conditions
  11000. */
  11001. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11002. /** @hidden */
  11003. _prepare(): void;
  11004. /**
  11005. * Execute the action and set the parent property.
  11006. */
  11007. execute(): void;
  11008. /**
  11009. * Serializes the actions and its related information.
  11010. * @param parent defines the object to serialize in
  11011. * @returns the serialized object
  11012. */
  11013. serialize(parent: any): any;
  11014. }
  11015. }
  11016. declare module "babylonjs/Actions/actionManager" {
  11017. import { Nullable } from "babylonjs/types";
  11018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11019. import { Scene } from "babylonjs/scene";
  11020. import { IAction } from "babylonjs/Actions/action";
  11021. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11022. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11023. /**
  11024. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11025. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11027. */
  11028. export class ActionManager extends AbstractActionManager {
  11029. /**
  11030. * Nothing
  11031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11032. */
  11033. static readonly NothingTrigger: number;
  11034. /**
  11035. * On pick
  11036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11037. */
  11038. static readonly OnPickTrigger: number;
  11039. /**
  11040. * On left pick
  11041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11042. */
  11043. static readonly OnLeftPickTrigger: number;
  11044. /**
  11045. * On right pick
  11046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11047. */
  11048. static readonly OnRightPickTrigger: number;
  11049. /**
  11050. * On center pick
  11051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11052. */
  11053. static readonly OnCenterPickTrigger: number;
  11054. /**
  11055. * On pick down
  11056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11057. */
  11058. static readonly OnPickDownTrigger: number;
  11059. /**
  11060. * On double pick
  11061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11062. */
  11063. static readonly OnDoublePickTrigger: number;
  11064. /**
  11065. * On pick up
  11066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11067. */
  11068. static readonly OnPickUpTrigger: number;
  11069. /**
  11070. * On pick out.
  11071. * This trigger will only be raised if you also declared a OnPickDown
  11072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11073. */
  11074. static readonly OnPickOutTrigger: number;
  11075. /**
  11076. * On long press
  11077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11078. */
  11079. static readonly OnLongPressTrigger: number;
  11080. /**
  11081. * On pointer over
  11082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11083. */
  11084. static readonly OnPointerOverTrigger: number;
  11085. /**
  11086. * On pointer out
  11087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11088. */
  11089. static readonly OnPointerOutTrigger: number;
  11090. /**
  11091. * On every frame
  11092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11093. */
  11094. static readonly OnEveryFrameTrigger: number;
  11095. /**
  11096. * On intersection enter
  11097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11098. */
  11099. static readonly OnIntersectionEnterTrigger: number;
  11100. /**
  11101. * On intersection exit
  11102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11103. */
  11104. static readonly OnIntersectionExitTrigger: number;
  11105. /**
  11106. * On key down
  11107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11108. */
  11109. static readonly OnKeyDownTrigger: number;
  11110. /**
  11111. * On key up
  11112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11113. */
  11114. static readonly OnKeyUpTrigger: number;
  11115. private _scene;
  11116. /**
  11117. * Creates a new action manager
  11118. * @param scene defines the hosting scene
  11119. */
  11120. constructor(scene: Scene);
  11121. /**
  11122. * Releases all associated resources
  11123. */
  11124. dispose(): void;
  11125. /**
  11126. * Gets hosting scene
  11127. * @returns the hosting scene
  11128. */
  11129. getScene(): Scene;
  11130. /**
  11131. * Does this action manager handles actions of any of the given triggers
  11132. * @param triggers defines the triggers to be tested
  11133. * @return a boolean indicating whether one (or more) of the triggers is handled
  11134. */
  11135. hasSpecificTriggers(triggers: number[]): boolean;
  11136. /**
  11137. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11138. * speed.
  11139. * @param triggerA defines the trigger to be tested
  11140. * @param triggerB defines the trigger to be tested
  11141. * @return a boolean indicating whether one (or more) of the triggers is handled
  11142. */
  11143. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11144. /**
  11145. * Does this action manager handles actions of a given trigger
  11146. * @param trigger defines the trigger to be tested
  11147. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11148. * @return whether the trigger is handled
  11149. */
  11150. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11151. /**
  11152. * Does this action manager has pointer triggers
  11153. */
  11154. readonly hasPointerTriggers: boolean;
  11155. /**
  11156. * Does this action manager has pick triggers
  11157. */
  11158. readonly hasPickTriggers: boolean;
  11159. /**
  11160. * Registers an action to this action manager
  11161. * @param action defines the action to be registered
  11162. * @return the action amended (prepared) after registration
  11163. */
  11164. registerAction(action: IAction): Nullable<IAction>;
  11165. /**
  11166. * Unregisters an action to this action manager
  11167. * @param action defines the action to be unregistered
  11168. * @return a boolean indicating whether the action has been unregistered
  11169. */
  11170. unregisterAction(action: IAction): Boolean;
  11171. /**
  11172. * Process a specific trigger
  11173. * @param trigger defines the trigger to process
  11174. * @param evt defines the event details to be processed
  11175. */
  11176. processTrigger(trigger: number, evt?: IActionEvent): void;
  11177. /** @hidden */
  11178. _getEffectiveTarget(target: any, propertyPath: string): any;
  11179. /** @hidden */
  11180. _getProperty(propertyPath: string): string;
  11181. /**
  11182. * Serialize this manager to a JSON object
  11183. * @param name defines the property name to store this manager
  11184. * @returns a JSON representation of this manager
  11185. */
  11186. serialize(name: string): any;
  11187. /**
  11188. * Creates a new ActionManager from a JSON data
  11189. * @param parsedActions defines the JSON data to read from
  11190. * @param object defines the hosting mesh
  11191. * @param scene defines the hosting scene
  11192. */
  11193. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11194. /**
  11195. * Get a trigger name by index
  11196. * @param trigger defines the trigger index
  11197. * @returns a trigger name
  11198. */
  11199. static GetTriggerName(trigger: number): string;
  11200. }
  11201. }
  11202. declare module "babylonjs/Culling/ray" {
  11203. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11204. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11205. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11206. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11207. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11208. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11209. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11210. /**
  11211. * Class representing a ray with position and direction
  11212. */
  11213. export class Ray {
  11214. /** origin point */
  11215. origin: Vector3;
  11216. /** direction */
  11217. direction: Vector3;
  11218. /** length of the ray */
  11219. length: number;
  11220. private static readonly TmpVector3;
  11221. private _tmpRay;
  11222. /**
  11223. * Creates a new ray
  11224. * @param origin origin point
  11225. * @param direction direction
  11226. * @param length length of the ray
  11227. */
  11228. constructor(
  11229. /** origin point */
  11230. origin: Vector3,
  11231. /** direction */
  11232. direction: Vector3,
  11233. /** length of the ray */
  11234. length?: number);
  11235. /**
  11236. * Checks if the ray intersects a box
  11237. * @param minimum bound of the box
  11238. * @param maximum bound of the box
  11239. * @param intersectionTreshold extra extend to be added to the box in all direction
  11240. * @returns if the box was hit
  11241. */
  11242. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11243. /**
  11244. * Checks if the ray intersects a box
  11245. * @param box the bounding box to check
  11246. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11247. * @returns if the box was hit
  11248. */
  11249. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11250. /**
  11251. * If the ray hits a sphere
  11252. * @param sphere the bounding sphere to check
  11253. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11254. * @returns true if it hits the sphere
  11255. */
  11256. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11257. /**
  11258. * If the ray hits a triange
  11259. * @param vertex0 triangle vertex
  11260. * @param vertex1 triangle vertex
  11261. * @param vertex2 triangle vertex
  11262. * @returns intersection information if hit
  11263. */
  11264. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11265. /**
  11266. * Checks if ray intersects a plane
  11267. * @param plane the plane to check
  11268. * @returns the distance away it was hit
  11269. */
  11270. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11271. /**
  11272. * Checks if ray intersects a mesh
  11273. * @param mesh the mesh to check
  11274. * @param fastCheck if only the bounding box should checked
  11275. * @returns picking info of the intersecton
  11276. */
  11277. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11278. /**
  11279. * Checks if ray intersects a mesh
  11280. * @param meshes the meshes to check
  11281. * @param fastCheck if only the bounding box should checked
  11282. * @param results array to store result in
  11283. * @returns Array of picking infos
  11284. */
  11285. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11286. private _comparePickingInfo;
  11287. private static smallnum;
  11288. private static rayl;
  11289. /**
  11290. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11291. * @param sega the first point of the segment to test the intersection against
  11292. * @param segb the second point of the segment to test the intersection against
  11293. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11294. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11295. */
  11296. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11297. /**
  11298. * Update the ray from viewport position
  11299. * @param x position
  11300. * @param y y position
  11301. * @param viewportWidth viewport width
  11302. * @param viewportHeight viewport height
  11303. * @param world world matrix
  11304. * @param view view matrix
  11305. * @param projection projection matrix
  11306. * @returns this ray updated
  11307. */
  11308. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11309. /**
  11310. * Creates a ray with origin and direction of 0,0,0
  11311. * @returns the new ray
  11312. */
  11313. static Zero(): Ray;
  11314. /**
  11315. * Creates a new ray from screen space and viewport
  11316. * @param x position
  11317. * @param y y position
  11318. * @param viewportWidth viewport width
  11319. * @param viewportHeight viewport height
  11320. * @param world world matrix
  11321. * @param view view matrix
  11322. * @param projection projection matrix
  11323. * @returns new ray
  11324. */
  11325. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11326. /**
  11327. * 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
  11328. * transformed to the given world matrix.
  11329. * @param origin The origin point
  11330. * @param end The end point
  11331. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11332. * @returns the new ray
  11333. */
  11334. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11335. /**
  11336. * Transforms a ray by a matrix
  11337. * @param ray ray to transform
  11338. * @param matrix matrix to apply
  11339. * @returns the resulting new ray
  11340. */
  11341. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11342. /**
  11343. * Transforms a ray by a matrix
  11344. * @param ray ray to transform
  11345. * @param matrix matrix to apply
  11346. * @param result ray to store result in
  11347. */
  11348. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11349. /**
  11350. * Unproject a ray from screen space to object space
  11351. * @param sourceX defines the screen space x coordinate to use
  11352. * @param sourceY defines the screen space y coordinate to use
  11353. * @param viewportWidth defines the current width of the viewport
  11354. * @param viewportHeight defines the current height of the viewport
  11355. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11356. * @param view defines the view matrix to use
  11357. * @param projection defines the projection matrix to use
  11358. */
  11359. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11360. }
  11361. /**
  11362. * Type used to define predicate used to select faces when a mesh intersection is detected
  11363. */
  11364. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11365. module "babylonjs/scene" {
  11366. interface Scene {
  11367. /** @hidden */
  11368. _tempPickingRay: Nullable<Ray>;
  11369. /** @hidden */
  11370. _cachedRayForTransform: Ray;
  11371. /** @hidden */
  11372. _pickWithRayInverseMatrix: Matrix;
  11373. /** @hidden */
  11374. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11375. /** @hidden */
  11376. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11377. }
  11378. }
  11379. }
  11380. declare module "babylonjs/sceneComponent" {
  11381. import { Scene } from "babylonjs/scene";
  11382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11383. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11384. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11385. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11386. import { Nullable } from "babylonjs/types";
  11387. import { Camera } from "babylonjs/Cameras/camera";
  11388. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11389. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11390. import { AbstractScene } from "babylonjs/abstractScene";
  11391. /**
  11392. * Groups all the scene component constants in one place to ease maintenance.
  11393. * @hidden
  11394. */
  11395. export class SceneComponentConstants {
  11396. static readonly NAME_EFFECTLAYER: string;
  11397. static readonly NAME_LAYER: string;
  11398. static readonly NAME_LENSFLARESYSTEM: string;
  11399. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11400. static readonly NAME_PARTICLESYSTEM: string;
  11401. static readonly NAME_GAMEPAD: string;
  11402. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11403. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11404. static readonly NAME_DEPTHRENDERER: string;
  11405. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11406. static readonly NAME_SPRITE: string;
  11407. static readonly NAME_OUTLINERENDERER: string;
  11408. static readonly NAME_PROCEDURALTEXTURE: string;
  11409. static readonly NAME_SHADOWGENERATOR: string;
  11410. static readonly NAME_OCTREE: string;
  11411. static readonly NAME_PHYSICSENGINE: string;
  11412. static readonly NAME_AUDIO: string;
  11413. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11414. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11415. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11416. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11417. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11418. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11419. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11420. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11421. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11422. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11423. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11424. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11425. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11426. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11427. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11428. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11429. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11430. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11431. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11432. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11433. static readonly STEP_AFTERRENDER_AUDIO: number;
  11434. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11435. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11436. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11437. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11438. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11439. static readonly STEP_POINTERMOVE_SPRITE: number;
  11440. static readonly STEP_POINTERDOWN_SPRITE: number;
  11441. static readonly STEP_POINTERUP_SPRITE: number;
  11442. }
  11443. /**
  11444. * This represents a scene component.
  11445. *
  11446. * This is used to decouple the dependency the scene is having on the different workloads like
  11447. * layers, post processes...
  11448. */
  11449. export interface ISceneComponent {
  11450. /**
  11451. * The name of the component. Each component must have a unique name.
  11452. */
  11453. name: string;
  11454. /**
  11455. * The scene the component belongs to.
  11456. */
  11457. scene: Scene;
  11458. /**
  11459. * Register the component to one instance of a scene.
  11460. */
  11461. register(): void;
  11462. /**
  11463. * Rebuilds the elements related to this component in case of
  11464. * context lost for instance.
  11465. */
  11466. rebuild(): void;
  11467. /**
  11468. * Disposes the component and the associated ressources.
  11469. */
  11470. dispose(): void;
  11471. }
  11472. /**
  11473. * This represents a SERIALIZABLE scene component.
  11474. *
  11475. * This extends Scene Component to add Serialization methods on top.
  11476. */
  11477. export interface ISceneSerializableComponent extends ISceneComponent {
  11478. /**
  11479. * Adds all the element from the container to the scene
  11480. * @param container the container holding the elements
  11481. */
  11482. addFromContainer(container: AbstractScene): void;
  11483. /**
  11484. * Removes all the elements in the container from the scene
  11485. * @param container contains the elements to remove
  11486. */
  11487. removeFromContainer(container: AbstractScene): void;
  11488. /**
  11489. * Serializes the component data to the specified json object
  11490. * @param serializationObject The object to serialize to
  11491. */
  11492. serialize(serializationObject: any): void;
  11493. }
  11494. /**
  11495. * Strong typing of a Mesh related stage step action
  11496. */
  11497. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11498. /**
  11499. * Strong typing of a Evaluate Sub Mesh related stage step action
  11500. */
  11501. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11502. /**
  11503. * Strong typing of a Active Mesh related stage step action
  11504. */
  11505. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11506. /**
  11507. * Strong typing of a Camera related stage step action
  11508. */
  11509. export type CameraStageAction = (camera: Camera) => void;
  11510. /**
  11511. * Strong typing of a Render Target related stage step action
  11512. */
  11513. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11514. /**
  11515. * Strong typing of a RenderingGroup related stage step action
  11516. */
  11517. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11518. /**
  11519. * Strong typing of a Mesh Render related stage step action
  11520. */
  11521. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11522. /**
  11523. * Strong typing of a simple stage step action
  11524. */
  11525. export type SimpleStageAction = () => void;
  11526. /**
  11527. * Strong typing of a render target action.
  11528. */
  11529. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11530. /**
  11531. * Strong typing of a pointer move action.
  11532. */
  11533. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11534. /**
  11535. * Strong typing of a pointer up/down action.
  11536. */
  11537. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11538. /**
  11539. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11540. * @hidden
  11541. */
  11542. export class Stage<T extends Function> extends Array<{
  11543. index: number;
  11544. component: ISceneComponent;
  11545. action: T;
  11546. }> {
  11547. /**
  11548. * Hide ctor from the rest of the world.
  11549. * @param items The items to add.
  11550. */
  11551. private constructor();
  11552. /**
  11553. * Creates a new Stage.
  11554. * @returns A new instance of a Stage
  11555. */
  11556. static Create<T extends Function>(): Stage<T>;
  11557. /**
  11558. * Registers a step in an ordered way in the targeted stage.
  11559. * @param index Defines the position to register the step in
  11560. * @param component Defines the component attached to the step
  11561. * @param action Defines the action to launch during the step
  11562. */
  11563. registerStep(index: number, component: ISceneComponent, action: T): void;
  11564. /**
  11565. * Clears all the steps from the stage.
  11566. */
  11567. clear(): void;
  11568. }
  11569. }
  11570. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11571. import { Nullable } from "babylonjs/types";
  11572. import { Observable } from "babylonjs/Misc/observable";
  11573. import { Scene } from "babylonjs/scene";
  11574. import { Sprite } from "babylonjs/Sprites/sprite";
  11575. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11576. import { Ray } from "babylonjs/Culling/ray";
  11577. import { Camera } from "babylonjs/Cameras/camera";
  11578. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11579. import { ISceneComponent } from "babylonjs/sceneComponent";
  11580. module "babylonjs/scene" {
  11581. interface Scene {
  11582. /** @hidden */
  11583. _pointerOverSprite: Nullable<Sprite>;
  11584. /** @hidden */
  11585. _pickedDownSprite: Nullable<Sprite>;
  11586. /** @hidden */
  11587. _tempSpritePickingRay: Nullable<Ray>;
  11588. /**
  11589. * All of the sprite managers added to this scene
  11590. * @see http://doc.babylonjs.com/babylon101/sprites
  11591. */
  11592. spriteManagers: Array<ISpriteManager>;
  11593. /**
  11594. * An event triggered when sprites rendering is about to start
  11595. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11596. */
  11597. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11598. /**
  11599. * An event triggered when sprites rendering is done
  11600. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11601. */
  11602. onAfterSpritesRenderingObservable: Observable<Scene>;
  11603. /** @hidden */
  11604. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11605. /** Launch a ray to try to pick a sprite in the scene
  11606. * @param x position on screen
  11607. * @param y position on screen
  11608. * @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
  11609. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11610. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11611. * @returns a PickingInfo
  11612. */
  11613. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11614. /** Use the given ray to pick a sprite in the scene
  11615. * @param ray The ray (in world space) to use to pick meshes
  11616. * @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
  11617. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11618. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11619. * @returns a PickingInfo
  11620. */
  11621. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11622. /**
  11623. * Force the sprite under the pointer
  11624. * @param sprite defines the sprite to use
  11625. */
  11626. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11627. /**
  11628. * Gets the sprite under the pointer
  11629. * @returns a Sprite or null if no sprite is under the pointer
  11630. */
  11631. getPointerOverSprite(): Nullable<Sprite>;
  11632. }
  11633. }
  11634. /**
  11635. * Defines the sprite scene component responsible to manage sprites
  11636. * in a given scene.
  11637. */
  11638. export class SpriteSceneComponent implements ISceneComponent {
  11639. /**
  11640. * The component name helpfull to identify the component in the list of scene components.
  11641. */
  11642. readonly name: string;
  11643. /**
  11644. * The scene the component belongs to.
  11645. */
  11646. scene: Scene;
  11647. /** @hidden */
  11648. private _spritePredicate;
  11649. /**
  11650. * Creates a new instance of the component for the given scene
  11651. * @param scene Defines the scene to register the component in
  11652. */
  11653. constructor(scene: Scene);
  11654. /**
  11655. * Registers the component in a given scene
  11656. */
  11657. register(): void;
  11658. /**
  11659. * Rebuilds the elements related to this component in case of
  11660. * context lost for instance.
  11661. */
  11662. rebuild(): void;
  11663. /**
  11664. * Disposes the component and the associated ressources.
  11665. */
  11666. dispose(): void;
  11667. private _pickSpriteButKeepRay;
  11668. private _pointerMove;
  11669. private _pointerDown;
  11670. private _pointerUp;
  11671. }
  11672. }
  11673. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11674. /** @hidden */
  11675. export var fogFragmentDeclaration: {
  11676. name: string;
  11677. shader: string;
  11678. };
  11679. }
  11680. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11681. /** @hidden */
  11682. export var fogFragment: {
  11683. name: string;
  11684. shader: string;
  11685. };
  11686. }
  11687. declare module "babylonjs/Shaders/sprites.fragment" {
  11688. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11689. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11690. /** @hidden */
  11691. export var spritesPixelShader: {
  11692. name: string;
  11693. shader: string;
  11694. };
  11695. }
  11696. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11697. /** @hidden */
  11698. export var fogVertexDeclaration: {
  11699. name: string;
  11700. shader: string;
  11701. };
  11702. }
  11703. declare module "babylonjs/Shaders/sprites.vertex" {
  11704. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11705. /** @hidden */
  11706. export var spritesVertexShader: {
  11707. name: string;
  11708. shader: string;
  11709. };
  11710. }
  11711. declare module "babylonjs/Sprites/spriteManager" {
  11712. import { IDisposable, Scene } from "babylonjs/scene";
  11713. import { Nullable } from "babylonjs/types";
  11714. import { Observable } from "babylonjs/Misc/observable";
  11715. import { Sprite } from "babylonjs/Sprites/sprite";
  11716. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11717. import { Camera } from "babylonjs/Cameras/camera";
  11718. import { Texture } from "babylonjs/Materials/Textures/texture";
  11719. import "babylonjs/Shaders/sprites.fragment";
  11720. import "babylonjs/Shaders/sprites.vertex";
  11721. import { Ray } from "babylonjs/Culling/ray";
  11722. /**
  11723. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11724. */
  11725. export interface ISpriteManager extends IDisposable {
  11726. /**
  11727. * Restricts the camera to viewing objects with the same layerMask.
  11728. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11729. */
  11730. layerMask: number;
  11731. /**
  11732. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11733. */
  11734. isPickable: boolean;
  11735. /**
  11736. * Specifies the rendering group id for this mesh (0 by default)
  11737. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11738. */
  11739. renderingGroupId: number;
  11740. /**
  11741. * Defines the list of sprites managed by the manager.
  11742. */
  11743. sprites: Array<Sprite>;
  11744. /**
  11745. * Tests the intersection of a sprite with a specific ray.
  11746. * @param ray The ray we are sending to test the collision
  11747. * @param camera The camera space we are sending rays in
  11748. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11749. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11750. * @returns picking info or null.
  11751. */
  11752. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11753. /**
  11754. * Renders the list of sprites on screen.
  11755. */
  11756. render(): void;
  11757. }
  11758. /**
  11759. * Class used to manage multiple sprites on the same spritesheet
  11760. * @see http://doc.babylonjs.com/babylon101/sprites
  11761. */
  11762. export class SpriteManager implements ISpriteManager {
  11763. /** defines the manager's name */
  11764. name: string;
  11765. /** Gets the list of sprites */
  11766. sprites: Sprite[];
  11767. /** Gets or sets the rendering group id (0 by default) */
  11768. renderingGroupId: number;
  11769. /** Gets or sets camera layer mask */
  11770. layerMask: number;
  11771. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11772. fogEnabled: boolean;
  11773. /** Gets or sets a boolean indicating if the sprites are pickable */
  11774. isPickable: boolean;
  11775. /** Defines the default width of a cell in the spritesheet */
  11776. cellWidth: number;
  11777. /** Defines the default height of a cell in the spritesheet */
  11778. cellHeight: number;
  11779. /**
  11780. * An event triggered when the manager is disposed.
  11781. */
  11782. onDisposeObservable: Observable<SpriteManager>;
  11783. private _onDisposeObserver;
  11784. /**
  11785. * Callback called when the manager is disposed
  11786. */
  11787. onDispose: () => void;
  11788. private _capacity;
  11789. private _spriteTexture;
  11790. private _epsilon;
  11791. private _scene;
  11792. private _vertexData;
  11793. private _buffer;
  11794. private _vertexBuffers;
  11795. private _indexBuffer;
  11796. private _effectBase;
  11797. private _effectFog;
  11798. /**
  11799. * Gets or sets the spritesheet texture
  11800. */
  11801. texture: Texture;
  11802. /**
  11803. * Creates a new sprite manager
  11804. * @param name defines the manager's name
  11805. * @param imgUrl defines the sprite sheet url
  11806. * @param capacity defines the maximum allowed number of sprites
  11807. * @param cellSize defines the size of a sprite cell
  11808. * @param scene defines the hosting scene
  11809. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11810. * @param samplingMode defines the smapling mode to use with spritesheet
  11811. */
  11812. constructor(
  11813. /** defines the manager's name */
  11814. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11815. private _appendSpriteVertex;
  11816. /**
  11817. * Intersects the sprites with a ray
  11818. * @param ray defines the ray to intersect with
  11819. * @param camera defines the current active camera
  11820. * @param predicate defines a predicate used to select candidate sprites
  11821. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11822. * @returns null if no hit or a PickingInfo
  11823. */
  11824. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11825. /**
  11826. * Render all child sprites
  11827. */
  11828. render(): void;
  11829. /**
  11830. * Release associated resources
  11831. */
  11832. dispose(): void;
  11833. }
  11834. }
  11835. declare module "babylonjs/Sprites/sprite" {
  11836. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11837. import { Nullable } from "babylonjs/types";
  11838. import { ActionManager } from "babylonjs/Actions/actionManager";
  11839. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11840. /**
  11841. * Class used to represent a sprite
  11842. * @see http://doc.babylonjs.com/babylon101/sprites
  11843. */
  11844. export class Sprite {
  11845. /** defines the name */
  11846. name: string;
  11847. /** Gets or sets the current world position */
  11848. position: Vector3;
  11849. /** Gets or sets the main color */
  11850. color: Color4;
  11851. /** Gets or sets the width */
  11852. width: number;
  11853. /** Gets or sets the height */
  11854. height: number;
  11855. /** Gets or sets rotation angle */
  11856. angle: number;
  11857. /** Gets or sets the cell index in the sprite sheet */
  11858. cellIndex: number;
  11859. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11860. invertU: number;
  11861. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11862. invertV: number;
  11863. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11864. disposeWhenFinishedAnimating: boolean;
  11865. /** Gets the list of attached animations */
  11866. animations: Animation[];
  11867. /** Gets or sets a boolean indicating if the sprite can be picked */
  11868. isPickable: boolean;
  11869. /**
  11870. * Gets or sets the associated action manager
  11871. */
  11872. actionManager: Nullable<ActionManager>;
  11873. private _animationStarted;
  11874. private _loopAnimation;
  11875. private _fromIndex;
  11876. private _toIndex;
  11877. private _delay;
  11878. private _direction;
  11879. private _manager;
  11880. private _time;
  11881. private _onAnimationEnd;
  11882. /**
  11883. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11884. */
  11885. isVisible: boolean;
  11886. /**
  11887. * Gets or sets the sprite size
  11888. */
  11889. size: number;
  11890. /**
  11891. * Creates a new Sprite
  11892. * @param name defines the name
  11893. * @param manager defines the manager
  11894. */
  11895. constructor(
  11896. /** defines the name */
  11897. name: string, manager: ISpriteManager);
  11898. /**
  11899. * Starts an animation
  11900. * @param from defines the initial key
  11901. * @param to defines the end key
  11902. * @param loop defines if the animation must loop
  11903. * @param delay defines the start delay (in ms)
  11904. * @param onAnimationEnd defines a callback to call when animation ends
  11905. */
  11906. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11907. /** Stops current animation (if any) */
  11908. stopAnimation(): void;
  11909. /** @hidden */
  11910. _animate(deltaTime: number): void;
  11911. /** Release associated resources */
  11912. dispose(): void;
  11913. }
  11914. }
  11915. declare module "babylonjs/Collisions/pickingInfo" {
  11916. import { Nullable } from "babylonjs/types";
  11917. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  11918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11919. import { Sprite } from "babylonjs/Sprites/sprite";
  11920. import { Ray } from "babylonjs/Culling/ray";
  11921. /**
  11922. * Information about the result of picking within a scene
  11923. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11924. */
  11925. export class PickingInfo {
  11926. /** @hidden */
  11927. _pickingUnavailable: boolean;
  11928. /**
  11929. * If the pick collided with an object
  11930. */
  11931. hit: boolean;
  11932. /**
  11933. * Distance away where the pick collided
  11934. */
  11935. distance: number;
  11936. /**
  11937. * The location of pick collision
  11938. */
  11939. pickedPoint: Nullable<Vector3>;
  11940. /**
  11941. * The mesh corresponding the the pick collision
  11942. */
  11943. pickedMesh: Nullable<AbstractMesh>;
  11944. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11945. bu: number;
  11946. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11947. bv: number;
  11948. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11949. faceId: number;
  11950. /** Id of the the submesh that was picked */
  11951. subMeshId: number;
  11952. /** If a sprite was picked, this will be the sprite the pick collided with */
  11953. pickedSprite: Nullable<Sprite>;
  11954. /**
  11955. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11956. */
  11957. originMesh: Nullable<AbstractMesh>;
  11958. /**
  11959. * The ray that was used to perform the picking.
  11960. */
  11961. ray: Nullable<Ray>;
  11962. /**
  11963. * Gets the normal correspodning to the face the pick collided with
  11964. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11965. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11966. * @returns The normal correspodning to the face the pick collided with
  11967. */
  11968. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11969. /**
  11970. * Gets the texture coordinates of where the pick occured
  11971. * @returns the vector containing the coordnates of the texture
  11972. */
  11973. getTextureCoordinates(): Nullable<Vector2>;
  11974. }
  11975. }
  11976. declare module "babylonjs/Events/pointerEvents" {
  11977. import { Nullable } from "babylonjs/types";
  11978. import { Vector2 } from "babylonjs/Maths/math";
  11979. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11980. import { Ray } from "babylonjs/Culling/ray";
  11981. /**
  11982. * Gather the list of pointer event types as constants.
  11983. */
  11984. export class PointerEventTypes {
  11985. /**
  11986. * 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.
  11987. */
  11988. static readonly POINTERDOWN: number;
  11989. /**
  11990. * The pointerup event is fired when a pointer is no longer active.
  11991. */
  11992. static readonly POINTERUP: number;
  11993. /**
  11994. * The pointermove event is fired when a pointer changes coordinates.
  11995. */
  11996. static readonly POINTERMOVE: number;
  11997. /**
  11998. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11999. */
  12000. static readonly POINTERWHEEL: number;
  12001. /**
  12002. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12003. */
  12004. static readonly POINTERPICK: number;
  12005. /**
  12006. * The pointertap event is fired when a the object has been touched and released without drag.
  12007. */
  12008. static readonly POINTERTAP: number;
  12009. /**
  12010. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12011. */
  12012. static readonly POINTERDOUBLETAP: number;
  12013. }
  12014. /**
  12015. * Base class of pointer info types.
  12016. */
  12017. export class PointerInfoBase {
  12018. /**
  12019. * Defines the type of event (PointerEventTypes)
  12020. */
  12021. type: number;
  12022. /**
  12023. * Defines the related dom event
  12024. */
  12025. event: PointerEvent | MouseWheelEvent;
  12026. /**
  12027. * Instantiates the base class of pointers info.
  12028. * @param type Defines the type of event (PointerEventTypes)
  12029. * @param event Defines the related dom event
  12030. */
  12031. constructor(
  12032. /**
  12033. * Defines the type of event (PointerEventTypes)
  12034. */
  12035. type: number,
  12036. /**
  12037. * Defines the related dom event
  12038. */
  12039. event: PointerEvent | MouseWheelEvent);
  12040. }
  12041. /**
  12042. * This class is used to store pointer related info for the onPrePointerObservable event.
  12043. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12044. */
  12045. export class PointerInfoPre extends PointerInfoBase {
  12046. /**
  12047. * Ray from a pointer if availible (eg. 6dof controller)
  12048. */
  12049. ray: Nullable<Ray>;
  12050. /**
  12051. * Defines the local position of the pointer on the canvas.
  12052. */
  12053. localPosition: Vector2;
  12054. /**
  12055. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12056. */
  12057. skipOnPointerObservable: boolean;
  12058. /**
  12059. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12060. * @param type Defines the type of event (PointerEventTypes)
  12061. * @param event Defines the related dom event
  12062. * @param localX Defines the local x coordinates of the pointer when the event occured
  12063. * @param localY Defines the local y coordinates of the pointer when the event occured
  12064. */
  12065. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12066. }
  12067. /**
  12068. * This type contains all the data related to a pointer event in Babylon.js.
  12069. * 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.
  12070. */
  12071. export class PointerInfo extends PointerInfoBase {
  12072. /**
  12073. * Defines the picking info associated to the info (if any)\
  12074. */
  12075. pickInfo: Nullable<PickingInfo>;
  12076. /**
  12077. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12078. * @param type Defines the type of event (PointerEventTypes)
  12079. * @param event Defines the related dom event
  12080. * @param pickInfo Defines the picking info associated to the info (if any)\
  12081. */
  12082. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12083. /**
  12084. * Defines the picking info associated to the info (if any)\
  12085. */
  12086. pickInfo: Nullable<PickingInfo>);
  12087. }
  12088. /**
  12089. * Data relating to a touch event on the screen.
  12090. */
  12091. export interface PointerTouch {
  12092. /**
  12093. * X coordinate of touch.
  12094. */
  12095. x: number;
  12096. /**
  12097. * Y coordinate of touch.
  12098. */
  12099. y: number;
  12100. /**
  12101. * Id of touch. Unique for each finger.
  12102. */
  12103. pointerId: number;
  12104. /**
  12105. * Event type passed from DOM.
  12106. */
  12107. type: any;
  12108. }
  12109. }
  12110. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12111. import { Nullable } from "babylonjs/types";
  12112. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12113. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12114. /**
  12115. * Manage the mouse inputs to control the movement of a free camera.
  12116. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12117. */
  12118. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12119. /**
  12120. * Define if touch is enabled in the mouse input
  12121. */
  12122. touchEnabled: boolean;
  12123. /**
  12124. * Defines the camera the input is attached to.
  12125. */
  12126. camera: FreeCamera;
  12127. /**
  12128. * Defines the buttons associated with the input to handle camera move.
  12129. */
  12130. buttons: number[];
  12131. /**
  12132. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12133. */
  12134. angularSensibility: number;
  12135. private _pointerInput;
  12136. private _onMouseMove;
  12137. private _observer;
  12138. private previousPosition;
  12139. /**
  12140. * Manage the mouse inputs to control the movement of a free camera.
  12141. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12142. * @param touchEnabled Defines if touch is enabled or not
  12143. */
  12144. constructor(
  12145. /**
  12146. * Define if touch is enabled in the mouse input
  12147. */
  12148. touchEnabled?: boolean);
  12149. /**
  12150. * Attach the input controls to a specific dom element to get the input from.
  12151. * @param element Defines the element the controls should be listened from
  12152. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12153. */
  12154. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12155. /**
  12156. * Called on JS contextmenu event.
  12157. * Override this method to provide functionality.
  12158. */
  12159. protected onContextMenu(evt: PointerEvent): void;
  12160. /**
  12161. * Detach the current controls from the specified dom element.
  12162. * @param element Defines the element to stop listening the inputs from
  12163. */
  12164. detachControl(element: Nullable<HTMLElement>): void;
  12165. /**
  12166. * Gets the class name of the current intput.
  12167. * @returns the class name
  12168. */
  12169. getClassName(): string;
  12170. /**
  12171. * Get the friendly name associated with the input class.
  12172. * @returns the input friendly name
  12173. */
  12174. getSimpleName(): string;
  12175. }
  12176. }
  12177. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12178. import { Nullable } from "babylonjs/types";
  12179. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12180. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12181. /**
  12182. * Manage the touch inputs to control the movement of a free camera.
  12183. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12184. */
  12185. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12186. /**
  12187. * Defines the camera the input is attached to.
  12188. */
  12189. camera: FreeCamera;
  12190. /**
  12191. * Defines the touch sensibility for rotation.
  12192. * The higher the faster.
  12193. */
  12194. touchAngularSensibility: number;
  12195. /**
  12196. * Defines the touch sensibility for move.
  12197. * The higher the faster.
  12198. */
  12199. touchMoveSensibility: number;
  12200. private _offsetX;
  12201. private _offsetY;
  12202. private _pointerPressed;
  12203. private _pointerInput;
  12204. private _observer;
  12205. private _onLostFocus;
  12206. /**
  12207. * Attach the input controls to a specific dom element to get the input from.
  12208. * @param element Defines the element the controls should be listened from
  12209. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12210. */
  12211. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12212. /**
  12213. * Detach the current controls from the specified dom element.
  12214. * @param element Defines the element to stop listening the inputs from
  12215. */
  12216. detachControl(element: Nullable<HTMLElement>): void;
  12217. /**
  12218. * Update the current camera state depending on the inputs that have been used this frame.
  12219. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12220. */
  12221. checkInputs(): void;
  12222. /**
  12223. * Gets the class name of the current intput.
  12224. * @returns the class name
  12225. */
  12226. getClassName(): string;
  12227. /**
  12228. * Get the friendly name associated with the input class.
  12229. * @returns the input friendly name
  12230. */
  12231. getSimpleName(): string;
  12232. }
  12233. }
  12234. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12235. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12236. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12237. /**
  12238. * Default Inputs manager for the FreeCamera.
  12239. * It groups all the default supported inputs for ease of use.
  12240. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12241. */
  12242. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12243. /**
  12244. * Instantiates a new FreeCameraInputsManager.
  12245. * @param camera Defines the camera the inputs belong to
  12246. */
  12247. constructor(camera: FreeCamera);
  12248. /**
  12249. * Add keyboard input support to the input manager.
  12250. * @returns the current input manager
  12251. */
  12252. addKeyboard(): FreeCameraInputsManager;
  12253. /**
  12254. * Add mouse input support to the input manager.
  12255. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12256. * @returns the current input manager
  12257. */
  12258. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12259. /**
  12260. * Add touch input support to the input manager.
  12261. * @returns the current input manager
  12262. */
  12263. addTouch(): FreeCameraInputsManager;
  12264. }
  12265. }
  12266. declare module "babylonjs/Cameras/freeCamera" {
  12267. import { Vector3 } from "babylonjs/Maths/math";
  12268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12269. import { Scene } from "babylonjs/scene";
  12270. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12271. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12272. /**
  12273. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12274. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12275. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12276. */
  12277. export class FreeCamera extends TargetCamera {
  12278. /**
  12279. * Define the collision ellipsoid of the camera.
  12280. * This is helpful to simulate a camera body like the player body around the camera
  12281. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12282. */
  12283. ellipsoid: Vector3;
  12284. /**
  12285. * Define an offset for the position of the ellipsoid around the camera.
  12286. * This can be helpful to determine the center of the body near the gravity center of the body
  12287. * instead of its head.
  12288. */
  12289. ellipsoidOffset: Vector3;
  12290. /**
  12291. * Enable or disable collisions of the camera with the rest of the scene objects.
  12292. */
  12293. checkCollisions: boolean;
  12294. /**
  12295. * Enable or disable gravity on the camera.
  12296. */
  12297. applyGravity: boolean;
  12298. /**
  12299. * Define the input manager associated to the camera.
  12300. */
  12301. inputs: FreeCameraInputsManager;
  12302. /**
  12303. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12304. * Higher values reduce sensitivity.
  12305. */
  12306. /**
  12307. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12308. * Higher values reduce sensitivity.
  12309. */
  12310. angularSensibility: number;
  12311. /**
  12312. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12313. */
  12314. keysUp: number[];
  12315. /**
  12316. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12317. */
  12318. keysDown: number[];
  12319. /**
  12320. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12321. */
  12322. keysLeft: number[];
  12323. /**
  12324. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12325. */
  12326. keysRight: number[];
  12327. /**
  12328. * Event raised when the camera collide with a mesh in the scene.
  12329. */
  12330. onCollide: (collidedMesh: AbstractMesh) => void;
  12331. private _collider;
  12332. private _needMoveForGravity;
  12333. private _oldPosition;
  12334. private _diffPosition;
  12335. private _newPosition;
  12336. /** @hidden */
  12337. _localDirection: Vector3;
  12338. /** @hidden */
  12339. _transformedDirection: Vector3;
  12340. /**
  12341. * Instantiates a Free Camera.
  12342. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12343. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12344. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12345. * @param name Define the name of the camera in the scene
  12346. * @param position Define the start position of the camera in the scene
  12347. * @param scene Define the scene the camera belongs to
  12348. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12349. */
  12350. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12351. /**
  12352. * Attached controls to the current camera.
  12353. * @param element Defines the element the controls should be listened from
  12354. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12355. */
  12356. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12357. /**
  12358. * Detach the current controls from the camera.
  12359. * The camera will stop reacting to inputs.
  12360. * @param element Defines the element to stop listening the inputs from
  12361. */
  12362. detachControl(element: HTMLElement): void;
  12363. private _collisionMask;
  12364. /**
  12365. * Define a collision mask to limit the list of object the camera can collide with
  12366. */
  12367. collisionMask: number;
  12368. /** @hidden */
  12369. _collideWithWorld(displacement: Vector3): void;
  12370. private _onCollisionPositionChange;
  12371. /** @hidden */
  12372. _checkInputs(): void;
  12373. /** @hidden */
  12374. _decideIfNeedsToMove(): boolean;
  12375. /** @hidden */
  12376. _updatePosition(): void;
  12377. /**
  12378. * Destroy the camera and release the current resources hold by it.
  12379. */
  12380. dispose(): void;
  12381. /**
  12382. * Gets the current object class name.
  12383. * @return the class name
  12384. */
  12385. getClassName(): string;
  12386. }
  12387. }
  12388. declare module "babylonjs/Gamepads/gamepad" {
  12389. import { Observable } from "babylonjs/Misc/observable";
  12390. /**
  12391. * Represents a gamepad control stick position
  12392. */
  12393. export class StickValues {
  12394. /**
  12395. * The x component of the control stick
  12396. */
  12397. x: number;
  12398. /**
  12399. * The y component of the control stick
  12400. */
  12401. y: number;
  12402. /**
  12403. * Initializes the gamepad x and y control stick values
  12404. * @param x The x component of the gamepad control stick value
  12405. * @param y The y component of the gamepad control stick value
  12406. */
  12407. constructor(
  12408. /**
  12409. * The x component of the control stick
  12410. */
  12411. x: number,
  12412. /**
  12413. * The y component of the control stick
  12414. */
  12415. y: number);
  12416. }
  12417. /**
  12418. * An interface which manages callbacks for gamepad button changes
  12419. */
  12420. export interface GamepadButtonChanges {
  12421. /**
  12422. * Called when a gamepad has been changed
  12423. */
  12424. changed: boolean;
  12425. /**
  12426. * Called when a gamepad press event has been triggered
  12427. */
  12428. pressChanged: boolean;
  12429. /**
  12430. * Called when a touch event has been triggered
  12431. */
  12432. touchChanged: boolean;
  12433. /**
  12434. * Called when a value has changed
  12435. */
  12436. valueChanged: boolean;
  12437. }
  12438. /**
  12439. * Represents a gamepad
  12440. */
  12441. export class Gamepad {
  12442. /**
  12443. * The id of the gamepad
  12444. */
  12445. id: string;
  12446. /**
  12447. * The index of the gamepad
  12448. */
  12449. index: number;
  12450. /**
  12451. * The browser gamepad
  12452. */
  12453. browserGamepad: any;
  12454. /**
  12455. * Specifies what type of gamepad this represents
  12456. */
  12457. type: number;
  12458. private _leftStick;
  12459. private _rightStick;
  12460. /** @hidden */
  12461. _isConnected: boolean;
  12462. private _leftStickAxisX;
  12463. private _leftStickAxisY;
  12464. private _rightStickAxisX;
  12465. private _rightStickAxisY;
  12466. /**
  12467. * Triggered when the left control stick has been changed
  12468. */
  12469. private _onleftstickchanged;
  12470. /**
  12471. * Triggered when the right control stick has been changed
  12472. */
  12473. private _onrightstickchanged;
  12474. /**
  12475. * Represents a gamepad controller
  12476. */
  12477. static GAMEPAD: number;
  12478. /**
  12479. * Represents a generic controller
  12480. */
  12481. static GENERIC: number;
  12482. /**
  12483. * Represents an XBox controller
  12484. */
  12485. static XBOX: number;
  12486. /**
  12487. * Represents a pose-enabled controller
  12488. */
  12489. static POSE_ENABLED: number;
  12490. /**
  12491. * Specifies whether the left control stick should be Y-inverted
  12492. */
  12493. protected _invertLeftStickY: boolean;
  12494. /**
  12495. * Specifies if the gamepad has been connected
  12496. */
  12497. readonly isConnected: boolean;
  12498. /**
  12499. * Initializes the gamepad
  12500. * @param id The id of the gamepad
  12501. * @param index The index of the gamepad
  12502. * @param browserGamepad The browser gamepad
  12503. * @param leftStickX The x component of the left joystick
  12504. * @param leftStickY The y component of the left joystick
  12505. * @param rightStickX The x component of the right joystick
  12506. * @param rightStickY The y component of the right joystick
  12507. */
  12508. constructor(
  12509. /**
  12510. * The id of the gamepad
  12511. */
  12512. id: string,
  12513. /**
  12514. * The index of the gamepad
  12515. */
  12516. index: number,
  12517. /**
  12518. * The browser gamepad
  12519. */
  12520. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12521. /**
  12522. * Callback triggered when the left joystick has changed
  12523. * @param callback
  12524. */
  12525. onleftstickchanged(callback: (values: StickValues) => void): void;
  12526. /**
  12527. * Callback triggered when the right joystick has changed
  12528. * @param callback
  12529. */
  12530. onrightstickchanged(callback: (values: StickValues) => void): void;
  12531. /**
  12532. * Gets the left joystick
  12533. */
  12534. /**
  12535. * Sets the left joystick values
  12536. */
  12537. leftStick: StickValues;
  12538. /**
  12539. * Gets the right joystick
  12540. */
  12541. /**
  12542. * Sets the right joystick value
  12543. */
  12544. rightStick: StickValues;
  12545. /**
  12546. * Updates the gamepad joystick positions
  12547. */
  12548. update(): void;
  12549. /**
  12550. * Disposes the gamepad
  12551. */
  12552. dispose(): void;
  12553. }
  12554. /**
  12555. * Represents a generic gamepad
  12556. */
  12557. export class GenericPad extends Gamepad {
  12558. private _buttons;
  12559. private _onbuttondown;
  12560. private _onbuttonup;
  12561. /**
  12562. * Observable triggered when a button has been pressed
  12563. */
  12564. onButtonDownObservable: Observable<number>;
  12565. /**
  12566. * Observable triggered when a button has been released
  12567. */
  12568. onButtonUpObservable: Observable<number>;
  12569. /**
  12570. * Callback triggered when a button has been pressed
  12571. * @param callback Called when a button has been pressed
  12572. */
  12573. onbuttondown(callback: (buttonPressed: number) => void): void;
  12574. /**
  12575. * Callback triggered when a button has been released
  12576. * @param callback Called when a button has been released
  12577. */
  12578. onbuttonup(callback: (buttonReleased: number) => void): void;
  12579. /**
  12580. * Initializes the generic gamepad
  12581. * @param id The id of the generic gamepad
  12582. * @param index The index of the generic gamepad
  12583. * @param browserGamepad The browser gamepad
  12584. */
  12585. constructor(id: string, index: number, browserGamepad: any);
  12586. private _setButtonValue;
  12587. /**
  12588. * Updates the generic gamepad
  12589. */
  12590. update(): void;
  12591. /**
  12592. * Disposes the generic gamepad
  12593. */
  12594. dispose(): void;
  12595. }
  12596. }
  12597. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12598. import { Observable } from "babylonjs/Misc/observable";
  12599. import { Nullable } from "babylonjs/types";
  12600. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12601. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12603. import { Ray } from "babylonjs/Culling/ray";
  12604. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12605. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12606. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12607. /**
  12608. * Defines the types of pose enabled controllers that are supported
  12609. */
  12610. export enum PoseEnabledControllerType {
  12611. /**
  12612. * HTC Vive
  12613. */
  12614. VIVE = 0,
  12615. /**
  12616. * Oculus Rift
  12617. */
  12618. OCULUS = 1,
  12619. /**
  12620. * Windows mixed reality
  12621. */
  12622. WINDOWS = 2,
  12623. /**
  12624. * Samsung gear VR
  12625. */
  12626. GEAR_VR = 3,
  12627. /**
  12628. * Google Daydream
  12629. */
  12630. DAYDREAM = 4,
  12631. /**
  12632. * Generic
  12633. */
  12634. GENERIC = 5
  12635. }
  12636. /**
  12637. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12638. */
  12639. export interface MutableGamepadButton {
  12640. /**
  12641. * Value of the button/trigger
  12642. */
  12643. value: number;
  12644. /**
  12645. * If the button/trigger is currently touched
  12646. */
  12647. touched: boolean;
  12648. /**
  12649. * If the button/trigger is currently pressed
  12650. */
  12651. pressed: boolean;
  12652. }
  12653. /**
  12654. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12655. * @hidden
  12656. */
  12657. export interface ExtendedGamepadButton extends GamepadButton {
  12658. /**
  12659. * If the button/trigger is currently pressed
  12660. */
  12661. readonly pressed: boolean;
  12662. /**
  12663. * If the button/trigger is currently touched
  12664. */
  12665. readonly touched: boolean;
  12666. /**
  12667. * Value of the button/trigger
  12668. */
  12669. readonly value: number;
  12670. }
  12671. /** @hidden */
  12672. export interface _GamePadFactory {
  12673. /**
  12674. * Returns wether or not the current gamepad can be created for this type of controller.
  12675. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12676. * @returns true if it can be created, otherwise false
  12677. */
  12678. canCreate(gamepadInfo: any): boolean;
  12679. /**
  12680. * Creates a new instance of the Gamepad.
  12681. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12682. * @returns the new gamepad instance
  12683. */
  12684. create(gamepadInfo: any): Gamepad;
  12685. }
  12686. /**
  12687. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12688. */
  12689. export class PoseEnabledControllerHelper {
  12690. /** @hidden */
  12691. static _ControllerFactories: _GamePadFactory[];
  12692. /** @hidden */
  12693. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12694. /**
  12695. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12696. * @param vrGamepad the gamepad to initialized
  12697. * @returns a vr controller of the type the gamepad identified as
  12698. */
  12699. static InitiateController(vrGamepad: any): Gamepad;
  12700. }
  12701. /**
  12702. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12703. */
  12704. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12705. private _deviceRoomPosition;
  12706. private _deviceRoomRotationQuaternion;
  12707. /**
  12708. * The device position in babylon space
  12709. */
  12710. devicePosition: Vector3;
  12711. /**
  12712. * The device rotation in babylon space
  12713. */
  12714. deviceRotationQuaternion: Quaternion;
  12715. /**
  12716. * The scale factor of the device in babylon space
  12717. */
  12718. deviceScaleFactor: number;
  12719. /**
  12720. * (Likely devicePosition should be used instead) The device position in its room space
  12721. */
  12722. position: Vector3;
  12723. /**
  12724. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12725. */
  12726. rotationQuaternion: Quaternion;
  12727. /**
  12728. * The type of controller (Eg. Windows mixed reality)
  12729. */
  12730. controllerType: PoseEnabledControllerType;
  12731. protected _calculatedPosition: Vector3;
  12732. private _calculatedRotation;
  12733. /**
  12734. * The raw pose from the device
  12735. */
  12736. rawPose: DevicePose;
  12737. private _trackPosition;
  12738. private _maxRotationDistFromHeadset;
  12739. private _draggedRoomRotation;
  12740. /**
  12741. * @hidden
  12742. */
  12743. _disableTrackPosition(fixedPosition: Vector3): void;
  12744. /**
  12745. * Internal, the mesh attached to the controller
  12746. * @hidden
  12747. */
  12748. _mesh: Nullable<AbstractMesh>;
  12749. private _poseControlledCamera;
  12750. private _leftHandSystemQuaternion;
  12751. /**
  12752. * Internal, matrix used to convert room space to babylon space
  12753. * @hidden
  12754. */
  12755. _deviceToWorld: Matrix;
  12756. /**
  12757. * Node to be used when casting a ray from the controller
  12758. * @hidden
  12759. */
  12760. _pointingPoseNode: Nullable<TransformNode>;
  12761. /**
  12762. * Name of the child mesh that can be used to cast a ray from the controller
  12763. */
  12764. static readonly POINTING_POSE: string;
  12765. /**
  12766. * Creates a new PoseEnabledController from a gamepad
  12767. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12768. */
  12769. constructor(browserGamepad: any);
  12770. private _workingMatrix;
  12771. /**
  12772. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12773. */
  12774. update(): void;
  12775. /**
  12776. * Updates only the pose device and mesh without doing any button event checking
  12777. */
  12778. protected _updatePoseAndMesh(): void;
  12779. /**
  12780. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12781. * @param poseData raw pose fromthe device
  12782. */
  12783. updateFromDevice(poseData: DevicePose): void;
  12784. /**
  12785. * @hidden
  12786. */
  12787. _meshAttachedObservable: Observable<AbstractMesh>;
  12788. /**
  12789. * Attaches a mesh to the controller
  12790. * @param mesh the mesh to be attached
  12791. */
  12792. attachToMesh(mesh: AbstractMesh): void;
  12793. /**
  12794. * Attaches the controllers mesh to a camera
  12795. * @param camera the camera the mesh should be attached to
  12796. */
  12797. attachToPoseControlledCamera(camera: TargetCamera): void;
  12798. /**
  12799. * Disposes of the controller
  12800. */
  12801. dispose(): void;
  12802. /**
  12803. * The mesh that is attached to the controller
  12804. */
  12805. readonly mesh: Nullable<AbstractMesh>;
  12806. /**
  12807. * Gets the ray of the controller in the direction the controller is pointing
  12808. * @param length the length the resulting ray should be
  12809. * @returns a ray in the direction the controller is pointing
  12810. */
  12811. getForwardRay(length?: number): Ray;
  12812. }
  12813. }
  12814. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12815. import { Observable } from "babylonjs/Misc/observable";
  12816. import { Scene } from "babylonjs/scene";
  12817. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12818. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12819. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12820. /**
  12821. * Defines the WebVRController object that represents controllers tracked in 3D space
  12822. */
  12823. export abstract class WebVRController extends PoseEnabledController {
  12824. /**
  12825. * Internal, the default controller model for the controller
  12826. */
  12827. protected _defaultModel: AbstractMesh;
  12828. /**
  12829. * Fired when the trigger state has changed
  12830. */
  12831. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12832. /**
  12833. * Fired when the main button state has changed
  12834. */
  12835. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12836. /**
  12837. * Fired when the secondary button state has changed
  12838. */
  12839. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12840. /**
  12841. * Fired when the pad state has changed
  12842. */
  12843. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12844. /**
  12845. * Fired when controllers stick values have changed
  12846. */
  12847. onPadValuesChangedObservable: Observable<StickValues>;
  12848. /**
  12849. * Array of button availible on the controller
  12850. */
  12851. protected _buttons: Array<MutableGamepadButton>;
  12852. private _onButtonStateChange;
  12853. /**
  12854. * Fired when a controller button's state has changed
  12855. * @param callback the callback containing the button that was modified
  12856. */
  12857. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12858. /**
  12859. * X and Y axis corrisponding to the controllers joystick
  12860. */
  12861. pad: StickValues;
  12862. /**
  12863. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12864. */
  12865. hand: string;
  12866. /**
  12867. * The default controller model for the controller
  12868. */
  12869. readonly defaultModel: AbstractMesh;
  12870. /**
  12871. * Creates a new WebVRController from a gamepad
  12872. * @param vrGamepad the gamepad that the WebVRController should be created from
  12873. */
  12874. constructor(vrGamepad: any);
  12875. /**
  12876. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12877. */
  12878. update(): void;
  12879. /**
  12880. * Function to be called when a button is modified
  12881. */
  12882. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12883. /**
  12884. * Loads a mesh and attaches it to the controller
  12885. * @param scene the scene the mesh should be added to
  12886. * @param meshLoaded callback for when the mesh has been loaded
  12887. */
  12888. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12889. private _setButtonValue;
  12890. private _changes;
  12891. private _checkChanges;
  12892. /**
  12893. * Disposes of th webVRCOntroller
  12894. */
  12895. dispose(): void;
  12896. }
  12897. }
  12898. declare module "babylonjs/Lights/hemisphericLight" {
  12899. import { Nullable } from "babylonjs/types";
  12900. import { Scene } from "babylonjs/scene";
  12901. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  12902. import { Effect } from "babylonjs/Materials/effect";
  12903. import { Light } from "babylonjs/Lights/light";
  12904. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  12905. /**
  12906. * The HemisphericLight simulates the ambient environment light,
  12907. * so the passed direction is the light reflection direction, not the incoming direction.
  12908. */
  12909. export class HemisphericLight extends Light {
  12910. /**
  12911. * The groundColor is the light in the opposite direction to the one specified during creation.
  12912. * 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.
  12913. */
  12914. groundColor: Color3;
  12915. /**
  12916. * The light reflection direction, not the incoming direction.
  12917. */
  12918. direction: Vector3;
  12919. /**
  12920. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12921. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12922. * The HemisphericLight can't cast shadows.
  12923. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12924. * @param name The friendly name of the light
  12925. * @param direction The direction of the light reflection
  12926. * @param scene The scene the light belongs to
  12927. */
  12928. constructor(name: string, direction: Vector3, scene: Scene);
  12929. protected _buildUniformLayout(): void;
  12930. /**
  12931. * Returns the string "HemisphericLight".
  12932. * @return The class name
  12933. */
  12934. getClassName(): string;
  12935. /**
  12936. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12937. * Returns the updated direction.
  12938. * @param target The target the direction should point to
  12939. * @return The computed direction
  12940. */
  12941. setDirectionToTarget(target: Vector3): Vector3;
  12942. /**
  12943. * Returns the shadow generator associated to the light.
  12944. * @returns Always null for hemispheric lights because it does not support shadows.
  12945. */
  12946. getShadowGenerator(): Nullable<IShadowGenerator>;
  12947. /**
  12948. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12949. * @param effect The effect to update
  12950. * @param lightIndex The index of the light in the effect to update
  12951. * @returns The hemispheric light
  12952. */
  12953. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12954. /**
  12955. * Computes the world matrix of the node
  12956. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12957. * @param useWasUpdatedFlag defines a reserved property
  12958. * @returns the world matrix
  12959. */
  12960. computeWorldMatrix(): Matrix;
  12961. /**
  12962. * Returns the integer 3.
  12963. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12964. */
  12965. getTypeID(): number;
  12966. /**
  12967. * Prepares the list of defines specific to the light type.
  12968. * @param defines the list of defines
  12969. * @param lightIndex defines the index of the light for the effect
  12970. */
  12971. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12972. }
  12973. }
  12974. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  12975. declare module "babylonjs/Cameras/VR/webVRCamera" {
  12976. import { Nullable } from "babylonjs/types";
  12977. import { Observable } from "babylonjs/Misc/observable";
  12978. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12979. import { Scene } from "babylonjs/scene";
  12980. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12981. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  12982. import { Node } from "babylonjs/node";
  12983. import { Ray } from "babylonjs/Culling/ray";
  12984. import "babylonjs/Cameras/RigModes/webVRRigMode";
  12985. /**
  12986. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  12987. * IMPORTANT!! The data is right-hand data.
  12988. * @export
  12989. * @interface DevicePose
  12990. */
  12991. export interface DevicePose {
  12992. /**
  12993. * The position of the device, values in array are [x,y,z].
  12994. */
  12995. readonly position: Nullable<Float32Array>;
  12996. /**
  12997. * The linearVelocity of the device, values in array are [x,y,z].
  12998. */
  12999. readonly linearVelocity: Nullable<Float32Array>;
  13000. /**
  13001. * The linearAcceleration of the device, values in array are [x,y,z].
  13002. */
  13003. readonly linearAcceleration: Nullable<Float32Array>;
  13004. /**
  13005. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13006. */
  13007. readonly orientation: Nullable<Float32Array>;
  13008. /**
  13009. * The angularVelocity of the device, values in array are [x,y,z].
  13010. */
  13011. readonly angularVelocity: Nullable<Float32Array>;
  13012. /**
  13013. * The angularAcceleration of the device, values in array are [x,y,z].
  13014. */
  13015. readonly angularAcceleration: Nullable<Float32Array>;
  13016. }
  13017. /**
  13018. * Interface representing a pose controlled object in Babylon.
  13019. * A pose controlled object has both regular pose values as well as pose values
  13020. * from an external device such as a VR head mounted display
  13021. */
  13022. export interface PoseControlled {
  13023. /**
  13024. * The position of the object in babylon space.
  13025. */
  13026. position: Vector3;
  13027. /**
  13028. * The rotation quaternion of the object in babylon space.
  13029. */
  13030. rotationQuaternion: Quaternion;
  13031. /**
  13032. * The position of the device in babylon space.
  13033. */
  13034. devicePosition?: Vector3;
  13035. /**
  13036. * The rotation quaternion of the device in babylon space.
  13037. */
  13038. deviceRotationQuaternion: Quaternion;
  13039. /**
  13040. * The raw pose coming from the device.
  13041. */
  13042. rawPose: Nullable<DevicePose>;
  13043. /**
  13044. * The scale of the device to be used when translating from device space to babylon space.
  13045. */
  13046. deviceScaleFactor: number;
  13047. /**
  13048. * Updates the poseControlled values based on the input device pose.
  13049. * @param poseData the pose data to update the object with
  13050. */
  13051. updateFromDevice(poseData: DevicePose): void;
  13052. }
  13053. /**
  13054. * Set of options to customize the webVRCamera
  13055. */
  13056. export interface WebVROptions {
  13057. /**
  13058. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13059. */
  13060. trackPosition?: boolean;
  13061. /**
  13062. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13063. */
  13064. positionScale?: number;
  13065. /**
  13066. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13067. */
  13068. displayName?: string;
  13069. /**
  13070. * Should the native controller meshes be initialized. (default: true)
  13071. */
  13072. controllerMeshes?: boolean;
  13073. /**
  13074. * Creating a default HemiLight only on controllers. (default: true)
  13075. */
  13076. defaultLightingOnControllers?: boolean;
  13077. /**
  13078. * If you don't want to use the default VR button of the helper. (default: false)
  13079. */
  13080. useCustomVRButton?: boolean;
  13081. /**
  13082. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13083. */
  13084. customVRButton?: HTMLButtonElement;
  13085. /**
  13086. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13087. */
  13088. rayLength?: number;
  13089. /**
  13090. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13091. */
  13092. defaultHeight?: number;
  13093. }
  13094. /**
  13095. * This represents a WebVR camera.
  13096. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13097. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13098. */
  13099. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13100. private webVROptions;
  13101. /**
  13102. * @hidden
  13103. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13104. */
  13105. _vrDevice: any;
  13106. /**
  13107. * The rawPose of the vrDevice.
  13108. */
  13109. rawPose: Nullable<DevicePose>;
  13110. private _onVREnabled;
  13111. private _specsVersion;
  13112. private _attached;
  13113. private _frameData;
  13114. protected _descendants: Array<Node>;
  13115. private _deviceRoomPosition;
  13116. /** @hidden */
  13117. _deviceRoomRotationQuaternion: Quaternion;
  13118. private _standingMatrix;
  13119. /**
  13120. * Represents device position in babylon space.
  13121. */
  13122. devicePosition: Vector3;
  13123. /**
  13124. * Represents device rotation in babylon space.
  13125. */
  13126. deviceRotationQuaternion: Quaternion;
  13127. /**
  13128. * The scale of the device to be used when translating from device space to babylon space.
  13129. */
  13130. deviceScaleFactor: number;
  13131. private _deviceToWorld;
  13132. private _worldToDevice;
  13133. /**
  13134. * References to the webVR controllers for the vrDevice.
  13135. */
  13136. controllers: Array<WebVRController>;
  13137. /**
  13138. * Emits an event when a controller is attached.
  13139. */
  13140. onControllersAttachedObservable: Observable<WebVRController[]>;
  13141. /**
  13142. * Emits an event when a controller's mesh has been loaded;
  13143. */
  13144. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13145. /**
  13146. * Emits an event when the HMD's pose has been updated.
  13147. */
  13148. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13149. private _poseSet;
  13150. /**
  13151. * If the rig cameras be used as parent instead of this camera.
  13152. */
  13153. rigParenting: boolean;
  13154. private _lightOnControllers;
  13155. private _defaultHeight?;
  13156. /**
  13157. * Instantiates a WebVRFreeCamera.
  13158. * @param name The name of the WebVRFreeCamera
  13159. * @param position The starting anchor position for the camera
  13160. * @param scene The scene the camera belongs to
  13161. * @param webVROptions a set of customizable options for the webVRCamera
  13162. */
  13163. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13164. /**
  13165. * Gets the device distance from the ground in meters.
  13166. * @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.
  13167. */
  13168. deviceDistanceToRoomGround(): number;
  13169. /**
  13170. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13171. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13172. */
  13173. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13174. /**
  13175. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13176. * @returns A promise with a boolean set to if the standing matrix is supported.
  13177. */
  13178. useStandingMatrixAsync(): Promise<boolean>;
  13179. /**
  13180. * Disposes the camera
  13181. */
  13182. dispose(): void;
  13183. /**
  13184. * Gets a vrController by name.
  13185. * @param name The name of the controller to retreive
  13186. * @returns the controller matching the name specified or null if not found
  13187. */
  13188. getControllerByName(name: string): Nullable<WebVRController>;
  13189. private _leftController;
  13190. /**
  13191. * The controller corrisponding to the users left hand.
  13192. */
  13193. readonly leftController: Nullable<WebVRController>;
  13194. private _rightController;
  13195. /**
  13196. * The controller corrisponding to the users right hand.
  13197. */
  13198. readonly rightController: Nullable<WebVRController>;
  13199. /**
  13200. * Casts a ray forward from the vrCamera's gaze.
  13201. * @param length Length of the ray (default: 100)
  13202. * @returns the ray corrisponding to the gaze
  13203. */
  13204. getForwardRay(length?: number): Ray;
  13205. /**
  13206. * @hidden
  13207. * Updates the camera based on device's frame data
  13208. */
  13209. _checkInputs(): void;
  13210. /**
  13211. * Updates the poseControlled values based on the input device pose.
  13212. * @param poseData Pose coming from the device
  13213. */
  13214. updateFromDevice(poseData: DevicePose): void;
  13215. private _htmlElementAttached;
  13216. private _detachIfAttached;
  13217. /**
  13218. * WebVR's attach control will start broadcasting frames to the device.
  13219. * Note that in certain browsers (chrome for example) this function must be called
  13220. * within a user-interaction callback. Example:
  13221. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13222. *
  13223. * @param element html element to attach the vrDevice to
  13224. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13225. */
  13226. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13227. /**
  13228. * Detaches the camera from the html element and disables VR
  13229. *
  13230. * @param element html element to detach from
  13231. */
  13232. detachControl(element: HTMLElement): void;
  13233. /**
  13234. * @returns the name of this class
  13235. */
  13236. getClassName(): string;
  13237. /**
  13238. * Calls resetPose on the vrDisplay
  13239. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13240. */
  13241. resetToCurrentRotation(): void;
  13242. /**
  13243. * @hidden
  13244. * Updates the rig cameras (left and right eye)
  13245. */
  13246. _updateRigCameras(): void;
  13247. private _workingVector;
  13248. private _oneVector;
  13249. private _workingMatrix;
  13250. private updateCacheCalled;
  13251. private _correctPositionIfNotTrackPosition;
  13252. /**
  13253. * @hidden
  13254. * Updates the cached values of the camera
  13255. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13256. */
  13257. _updateCache(ignoreParentClass?: boolean): void;
  13258. /**
  13259. * @hidden
  13260. * Get current device position in babylon world
  13261. */
  13262. _computeDevicePosition(): void;
  13263. /**
  13264. * Updates the current device position and rotation in the babylon world
  13265. */
  13266. update(): void;
  13267. /**
  13268. * @hidden
  13269. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13270. * @returns an identity matrix
  13271. */
  13272. _getViewMatrix(): Matrix;
  13273. private _tmpMatrix;
  13274. /**
  13275. * This function is called by the two RIG cameras.
  13276. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13277. * @hidden
  13278. */
  13279. _getWebVRViewMatrix(): Matrix;
  13280. /** @hidden */
  13281. _getWebVRProjectionMatrix(): Matrix;
  13282. private _onGamepadConnectedObserver;
  13283. private _onGamepadDisconnectedObserver;
  13284. private _updateCacheWhenTrackingDisabledObserver;
  13285. /**
  13286. * Initializes the controllers and their meshes
  13287. */
  13288. initControllers(): void;
  13289. }
  13290. }
  13291. declare module "babylonjs/PostProcesses/postProcess" {
  13292. import { Nullable } from "babylonjs/types";
  13293. import { SmartArray } from "babylonjs/Misc/smartArray";
  13294. import { Observable } from "babylonjs/Misc/observable";
  13295. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13296. import { Camera } from "babylonjs/Cameras/camera";
  13297. import { Effect } from "babylonjs/Materials/effect";
  13298. import "babylonjs/Shaders/postprocess.vertex";
  13299. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13300. import { Engine } from "babylonjs/Engines/engine";
  13301. /**
  13302. * Size options for a post process
  13303. */
  13304. export type PostProcessOptions = {
  13305. width: number;
  13306. height: number;
  13307. };
  13308. /**
  13309. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13310. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13311. */
  13312. export class PostProcess {
  13313. /** Name of the PostProcess. */
  13314. name: string;
  13315. /**
  13316. * Gets or sets the unique id of the post process
  13317. */
  13318. uniqueId: number;
  13319. /**
  13320. * Width of the texture to apply the post process on
  13321. */
  13322. width: number;
  13323. /**
  13324. * Height of the texture to apply the post process on
  13325. */
  13326. height: number;
  13327. /**
  13328. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13329. * @hidden
  13330. */
  13331. _outputTexture: Nullable<InternalTexture>;
  13332. /**
  13333. * Sampling mode used by the shader
  13334. * See https://doc.babylonjs.com/classes/3.1/texture
  13335. */
  13336. renderTargetSamplingMode: number;
  13337. /**
  13338. * Clear color to use when screen clearing
  13339. */
  13340. clearColor: Color4;
  13341. /**
  13342. * If the buffer needs to be cleared before applying the post process. (default: true)
  13343. * Should be set to false if shader will overwrite all previous pixels.
  13344. */
  13345. autoClear: boolean;
  13346. /**
  13347. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13348. */
  13349. alphaMode: number;
  13350. /**
  13351. * Sets the setAlphaBlendConstants of the babylon engine
  13352. */
  13353. alphaConstants: Color4;
  13354. /**
  13355. * Animations to be used for the post processing
  13356. */
  13357. animations: import("babylonjs/Animations/animation").Animation[];
  13358. /**
  13359. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13360. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13361. */
  13362. enablePixelPerfectMode: boolean;
  13363. /**
  13364. * Force the postprocess to be applied without taking in account viewport
  13365. */
  13366. forceFullscreenViewport: boolean;
  13367. /**
  13368. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13369. *
  13370. * | Value | Type | Description |
  13371. * | ----- | ----------------------------------- | ----------- |
  13372. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13373. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13374. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13375. *
  13376. */
  13377. scaleMode: number;
  13378. /**
  13379. * Force textures to be a power of two (default: false)
  13380. */
  13381. alwaysForcePOT: boolean;
  13382. private _samples;
  13383. /**
  13384. * Number of sample textures (default: 1)
  13385. */
  13386. samples: number;
  13387. /**
  13388. * Modify the scale of the post process to be the same as the viewport (default: false)
  13389. */
  13390. adaptScaleToCurrentViewport: boolean;
  13391. private _camera;
  13392. private _scene;
  13393. private _engine;
  13394. private _options;
  13395. private _reusable;
  13396. private _textureType;
  13397. /**
  13398. * Smart array of input and output textures for the post process.
  13399. * @hidden
  13400. */
  13401. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13402. /**
  13403. * The index in _textures that corresponds to the output texture.
  13404. * @hidden
  13405. */
  13406. _currentRenderTextureInd: number;
  13407. private _effect;
  13408. private _samplers;
  13409. private _fragmentUrl;
  13410. private _vertexUrl;
  13411. private _parameters;
  13412. private _scaleRatio;
  13413. protected _indexParameters: any;
  13414. private _shareOutputWithPostProcess;
  13415. private _texelSize;
  13416. private _forcedOutputTexture;
  13417. /**
  13418. * Returns the fragment url or shader name used in the post process.
  13419. * @returns the fragment url or name in the shader store.
  13420. */
  13421. getEffectName(): string;
  13422. /**
  13423. * An event triggered when the postprocess is activated.
  13424. */
  13425. onActivateObservable: Observable<Camera>;
  13426. private _onActivateObserver;
  13427. /**
  13428. * A function that is added to the onActivateObservable
  13429. */
  13430. onActivate: Nullable<(camera: Camera) => void>;
  13431. /**
  13432. * An event triggered when the postprocess changes its size.
  13433. */
  13434. onSizeChangedObservable: Observable<PostProcess>;
  13435. private _onSizeChangedObserver;
  13436. /**
  13437. * A function that is added to the onSizeChangedObservable
  13438. */
  13439. onSizeChanged: (postProcess: PostProcess) => void;
  13440. /**
  13441. * An event triggered when the postprocess applies its effect.
  13442. */
  13443. onApplyObservable: Observable<Effect>;
  13444. private _onApplyObserver;
  13445. /**
  13446. * A function that is added to the onApplyObservable
  13447. */
  13448. onApply: (effect: Effect) => void;
  13449. /**
  13450. * An event triggered before rendering the postprocess
  13451. */
  13452. onBeforeRenderObservable: Observable<Effect>;
  13453. private _onBeforeRenderObserver;
  13454. /**
  13455. * A function that is added to the onBeforeRenderObservable
  13456. */
  13457. onBeforeRender: (effect: Effect) => void;
  13458. /**
  13459. * An event triggered after rendering the postprocess
  13460. */
  13461. onAfterRenderObservable: Observable<Effect>;
  13462. private _onAfterRenderObserver;
  13463. /**
  13464. * A function that is added to the onAfterRenderObservable
  13465. */
  13466. onAfterRender: (efect: Effect) => void;
  13467. /**
  13468. * 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
  13469. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13470. */
  13471. inputTexture: InternalTexture;
  13472. /**
  13473. * Gets the camera which post process is applied to.
  13474. * @returns The camera the post process is applied to.
  13475. */
  13476. getCamera(): Camera;
  13477. /**
  13478. * Gets the texel size of the postprocess.
  13479. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13480. */
  13481. readonly texelSize: Vector2;
  13482. /**
  13483. * Creates a new instance PostProcess
  13484. * @param name The name of the PostProcess.
  13485. * @param fragmentUrl The url of the fragment shader to be used.
  13486. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13487. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13488. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13489. * @param camera The camera to apply the render pass to.
  13490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13491. * @param engine The engine which the post process will be applied. (default: current engine)
  13492. * @param reusable If the post process can be reused on the same frame. (default: false)
  13493. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13494. * @param textureType Type of textures used when performing the post process. (default: 0)
  13495. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13496. * @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
  13497. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13498. */
  13499. constructor(
  13500. /** Name of the PostProcess. */
  13501. 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);
  13502. /**
  13503. * Gets a string idenfifying the name of the class
  13504. * @returns "PostProcess" string
  13505. */
  13506. getClassName(): string;
  13507. /**
  13508. * Gets the engine which this post process belongs to.
  13509. * @returns The engine the post process was enabled with.
  13510. */
  13511. getEngine(): Engine;
  13512. /**
  13513. * The effect that is created when initializing the post process.
  13514. * @returns The created effect corrisponding the the postprocess.
  13515. */
  13516. getEffect(): Effect;
  13517. /**
  13518. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13519. * @param postProcess The post process to share the output with.
  13520. * @returns This post process.
  13521. */
  13522. shareOutputWith(postProcess: PostProcess): PostProcess;
  13523. /**
  13524. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13525. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13526. */
  13527. useOwnOutput(): void;
  13528. /**
  13529. * Updates the effect with the current post process compile time values and recompiles the shader.
  13530. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13531. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13532. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13533. * @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
  13534. * @param onCompiled Called when the shader has been compiled.
  13535. * @param onError Called if there is an error when compiling a shader.
  13536. */
  13537. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13538. /**
  13539. * The post process is reusable if it can be used multiple times within one frame.
  13540. * @returns If the post process is reusable
  13541. */
  13542. isReusable(): boolean;
  13543. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13544. markTextureDirty(): void;
  13545. /**
  13546. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13547. * 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.
  13548. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13549. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13550. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13551. * @returns The target texture that was bound to be written to.
  13552. */
  13553. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13554. /**
  13555. * If the post process is supported.
  13556. */
  13557. readonly isSupported: boolean;
  13558. /**
  13559. * The aspect ratio of the output texture.
  13560. */
  13561. readonly aspectRatio: number;
  13562. /**
  13563. * Get a value indicating if the post-process is ready to be used
  13564. * @returns true if the post-process is ready (shader is compiled)
  13565. */
  13566. isReady(): boolean;
  13567. /**
  13568. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13569. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13570. */
  13571. apply(): Nullable<Effect>;
  13572. private _disposeTextures;
  13573. /**
  13574. * Disposes the post process.
  13575. * @param camera The camera to dispose the post process on.
  13576. */
  13577. dispose(camera?: Camera): void;
  13578. }
  13579. }
  13580. declare module "babylonjs/PostProcesses/postProcessManager" {
  13581. import { Nullable } from "babylonjs/types";
  13582. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13583. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13584. import { Scene } from "babylonjs/scene";
  13585. /**
  13586. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13587. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13588. */
  13589. export class PostProcessManager {
  13590. private _scene;
  13591. private _indexBuffer;
  13592. private _vertexBuffers;
  13593. /**
  13594. * Creates a new instance PostProcess
  13595. * @param scene The scene that the post process is associated with.
  13596. */
  13597. constructor(scene: Scene);
  13598. private _prepareBuffers;
  13599. private _buildIndexBuffer;
  13600. /**
  13601. * Rebuilds the vertex buffers of the manager.
  13602. * @hidden
  13603. */
  13604. _rebuild(): void;
  13605. /**
  13606. * Prepares a frame to be run through a post process.
  13607. * @param sourceTexture The input texture to the post procesess. (default: null)
  13608. * @param postProcesses An array of post processes to be run. (default: null)
  13609. * @returns True if the post processes were able to be run.
  13610. * @hidden
  13611. */
  13612. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13613. /**
  13614. * Manually render a set of post processes to a texture.
  13615. * @param postProcesses An array of post processes to be run.
  13616. * @param targetTexture The target texture to render to.
  13617. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13618. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13619. * @param lodLevel defines which lod of the texture to render to
  13620. */
  13621. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13622. /**
  13623. * Finalize the result of the output of the postprocesses.
  13624. * @param doNotPresent If true the result will not be displayed to the screen.
  13625. * @param targetTexture The target texture to render to.
  13626. * @param faceIndex The index of the face to bind the target texture to.
  13627. * @param postProcesses The array of post processes to render.
  13628. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13629. * @hidden
  13630. */
  13631. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13632. /**
  13633. * Disposes of the post process manager.
  13634. */
  13635. dispose(): void;
  13636. }
  13637. }
  13638. declare module "babylonjs/Layers/layerSceneComponent" {
  13639. import { Scene } from "babylonjs/scene";
  13640. import { ISceneComponent } from "babylonjs/sceneComponent";
  13641. import { Layer } from "babylonjs/Layers/layer";
  13642. module "babylonjs/abstractScene" {
  13643. interface AbstractScene {
  13644. /**
  13645. * The list of layers (background and foreground) of the scene
  13646. */
  13647. layers: Array<Layer>;
  13648. }
  13649. }
  13650. /**
  13651. * Defines the layer scene component responsible to manage any layers
  13652. * in a given scene.
  13653. */
  13654. export class LayerSceneComponent implements ISceneComponent {
  13655. /**
  13656. * The component name helpfull to identify the component in the list of scene components.
  13657. */
  13658. readonly name: string;
  13659. /**
  13660. * The scene the component belongs to.
  13661. */
  13662. scene: Scene;
  13663. private _engine;
  13664. /**
  13665. * Creates a new instance of the component for the given scene
  13666. * @param scene Defines the scene to register the component in
  13667. */
  13668. constructor(scene: Scene);
  13669. /**
  13670. * Registers the component in a given scene
  13671. */
  13672. register(): void;
  13673. /**
  13674. * Rebuilds the elements related to this component in case of
  13675. * context lost for instance.
  13676. */
  13677. rebuild(): void;
  13678. /**
  13679. * Disposes the component and the associated ressources.
  13680. */
  13681. dispose(): void;
  13682. private _draw;
  13683. private _drawCameraPredicate;
  13684. private _drawCameraBackground;
  13685. private _drawCameraForeground;
  13686. private _drawRenderTargetPredicate;
  13687. private _drawRenderTargetBackground;
  13688. private _drawRenderTargetForeground;
  13689. }
  13690. }
  13691. declare module "babylonjs/Shaders/layer.fragment" {
  13692. /** @hidden */
  13693. export var layerPixelShader: {
  13694. name: string;
  13695. shader: string;
  13696. };
  13697. }
  13698. declare module "babylonjs/Shaders/layer.vertex" {
  13699. /** @hidden */
  13700. export var layerVertexShader: {
  13701. name: string;
  13702. shader: string;
  13703. };
  13704. }
  13705. declare module "babylonjs/Layers/layer" {
  13706. import { Observable } from "babylonjs/Misc/observable";
  13707. import { Nullable } from "babylonjs/types";
  13708. import { Scene } from "babylonjs/scene";
  13709. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13710. import { Texture } from "babylonjs/Materials/Textures/texture";
  13711. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13712. import "babylonjs/Shaders/layer.fragment";
  13713. import "babylonjs/Shaders/layer.vertex";
  13714. /**
  13715. * This represents a full screen 2d layer.
  13716. * This can be useful to display a picture in the background of your scene for instance.
  13717. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13718. */
  13719. export class Layer {
  13720. /**
  13721. * Define the name of the layer.
  13722. */
  13723. name: string;
  13724. /**
  13725. * Define the texture the layer should display.
  13726. */
  13727. texture: Nullable<Texture>;
  13728. /**
  13729. * Is the layer in background or foreground.
  13730. */
  13731. isBackground: boolean;
  13732. /**
  13733. * Define the color of the layer (instead of texture).
  13734. */
  13735. color: Color4;
  13736. /**
  13737. * Define the scale of the layer in order to zoom in out of the texture.
  13738. */
  13739. scale: Vector2;
  13740. /**
  13741. * Define an offset for the layer in order to shift the texture.
  13742. */
  13743. offset: Vector2;
  13744. /**
  13745. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13746. */
  13747. alphaBlendingMode: number;
  13748. /**
  13749. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13750. * Alpha test will not mix with the background color in case of transparency.
  13751. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13752. */
  13753. alphaTest: boolean;
  13754. /**
  13755. * Define a mask to restrict the layer to only some of the scene cameras.
  13756. */
  13757. layerMask: number;
  13758. /**
  13759. * Define the list of render target the layer is visible into.
  13760. */
  13761. renderTargetTextures: RenderTargetTexture[];
  13762. /**
  13763. * Define if the layer is only used in renderTarget or if it also
  13764. * renders in the main frame buffer of the canvas.
  13765. */
  13766. renderOnlyInRenderTargetTextures: boolean;
  13767. private _scene;
  13768. private _vertexBuffers;
  13769. private _indexBuffer;
  13770. private _effect;
  13771. private _alphaTestEffect;
  13772. /**
  13773. * An event triggered when the layer is disposed.
  13774. */
  13775. onDisposeObservable: Observable<Layer>;
  13776. private _onDisposeObserver;
  13777. /**
  13778. * Back compatibility with callback before the onDisposeObservable existed.
  13779. * The set callback will be triggered when the layer has been disposed.
  13780. */
  13781. onDispose: () => void;
  13782. /**
  13783. * An event triggered before rendering the scene
  13784. */
  13785. onBeforeRenderObservable: Observable<Layer>;
  13786. private _onBeforeRenderObserver;
  13787. /**
  13788. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13789. * The set callback will be triggered just before rendering the layer.
  13790. */
  13791. onBeforeRender: () => void;
  13792. /**
  13793. * An event triggered after rendering the scene
  13794. */
  13795. onAfterRenderObservable: Observable<Layer>;
  13796. private _onAfterRenderObserver;
  13797. /**
  13798. * Back compatibility with callback before the onAfterRenderObservable existed.
  13799. * The set callback will be triggered just after rendering the layer.
  13800. */
  13801. onAfterRender: () => void;
  13802. /**
  13803. * Instantiates a new layer.
  13804. * This represents a full screen 2d layer.
  13805. * This can be useful to display a picture in the background of your scene for instance.
  13806. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13807. * @param name Define the name of the layer in the scene
  13808. * @param imgUrl Define the url of the texture to display in the layer
  13809. * @param scene Define the scene the layer belongs to
  13810. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13811. * @param color Defines a color for the layer
  13812. */
  13813. constructor(
  13814. /**
  13815. * Define the name of the layer.
  13816. */
  13817. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13818. private _createIndexBuffer;
  13819. /** @hidden */
  13820. _rebuild(): void;
  13821. /**
  13822. * Renders the layer in the scene.
  13823. */
  13824. render(): void;
  13825. /**
  13826. * Disposes and releases the associated ressources.
  13827. */
  13828. dispose(): void;
  13829. }
  13830. }
  13831. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13832. import { Scene } from "babylonjs/scene";
  13833. import { ISceneComponent } from "babylonjs/sceneComponent";
  13834. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13835. module "babylonjs/abstractScene" {
  13836. interface AbstractScene {
  13837. /**
  13838. * The list of procedural textures added to the scene
  13839. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13840. */
  13841. proceduralTextures: Array<ProceduralTexture>;
  13842. }
  13843. }
  13844. /**
  13845. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13846. * in a given scene.
  13847. */
  13848. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13849. /**
  13850. * The component name helpfull to identify the component in the list of scene components.
  13851. */
  13852. readonly name: string;
  13853. /**
  13854. * The scene the component belongs to.
  13855. */
  13856. scene: Scene;
  13857. /**
  13858. * Creates a new instance of the component for the given scene
  13859. * @param scene Defines the scene to register the component in
  13860. */
  13861. constructor(scene: Scene);
  13862. /**
  13863. * Registers the component in a given scene
  13864. */
  13865. register(): void;
  13866. /**
  13867. * Rebuilds the elements related to this component in case of
  13868. * context lost for instance.
  13869. */
  13870. rebuild(): void;
  13871. /**
  13872. * Disposes the component and the associated ressources.
  13873. */
  13874. dispose(): void;
  13875. private _beforeClear;
  13876. }
  13877. }
  13878. declare module "babylonjs/Shaders/procedural.vertex" {
  13879. /** @hidden */
  13880. export var proceduralVertexShader: {
  13881. name: string;
  13882. shader: string;
  13883. };
  13884. }
  13885. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  13886. import { Observable } from "babylonjs/Misc/observable";
  13887. import { Nullable } from "babylonjs/types";
  13888. import { Scene } from "babylonjs/scene";
  13889. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  13890. import { Effect } from "babylonjs/Materials/effect";
  13891. import { Texture } from "babylonjs/Materials/Textures/texture";
  13892. import "babylonjs/Shaders/procedural.vertex";
  13893. /**
  13894. * 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.
  13895. * This is the base class of any Procedural texture and contains most of the shareable code.
  13896. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13897. */
  13898. export class ProceduralTexture extends Texture {
  13899. isCube: boolean;
  13900. /**
  13901. * Define if the texture is enabled or not (disabled texture will not render)
  13902. */
  13903. isEnabled: boolean;
  13904. /**
  13905. * Define if the texture must be cleared before rendering (default is true)
  13906. */
  13907. autoClear: boolean;
  13908. /**
  13909. * Callback called when the texture is generated
  13910. */
  13911. onGenerated: () => void;
  13912. /**
  13913. * Event raised when the texture is generated
  13914. */
  13915. onGeneratedObservable: Observable<ProceduralTexture>;
  13916. /** @hidden */
  13917. _generateMipMaps: boolean;
  13918. /** @hidden **/
  13919. _effect: Effect;
  13920. /** @hidden */
  13921. _textures: {
  13922. [key: string]: Texture;
  13923. };
  13924. private _size;
  13925. private _currentRefreshId;
  13926. private _refreshRate;
  13927. private _vertexBuffers;
  13928. private _indexBuffer;
  13929. private _uniforms;
  13930. private _samplers;
  13931. private _fragment;
  13932. private _floats;
  13933. private _ints;
  13934. private _floatsArrays;
  13935. private _colors3;
  13936. private _colors4;
  13937. private _vectors2;
  13938. private _vectors3;
  13939. private _matrices;
  13940. private _fallbackTexture;
  13941. private _fallbackTextureUsed;
  13942. private _engine;
  13943. private _cachedDefines;
  13944. private _contentUpdateId;
  13945. private _contentData;
  13946. /**
  13947. * Instantiates a new procedural texture.
  13948. * 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.
  13949. * This is the base class of any Procedural texture and contains most of the shareable code.
  13950. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13951. * @param name Define the name of the texture
  13952. * @param size Define the size of the texture to create
  13953. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13954. * @param scene Define the scene the texture belongs to
  13955. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13956. * @param generateMipMaps Define if the texture should creates mip maps or not
  13957. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13958. */
  13959. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13960. /**
  13961. * The effect that is created when initializing the post process.
  13962. * @returns The created effect corrisponding the the postprocess.
  13963. */
  13964. getEffect(): Effect;
  13965. /**
  13966. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13967. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13968. */
  13969. getContent(): Nullable<ArrayBufferView>;
  13970. private _createIndexBuffer;
  13971. /** @hidden */
  13972. _rebuild(): void;
  13973. /**
  13974. * Resets the texture in order to recreate its associated resources.
  13975. * This can be called in case of context loss
  13976. */
  13977. reset(): void;
  13978. protected _getDefines(): string;
  13979. /**
  13980. * Is the texture ready to be used ? (rendered at least once)
  13981. * @returns true if ready, otherwise, false.
  13982. */
  13983. isReady(): boolean;
  13984. /**
  13985. * Resets the refresh counter of the texture and start bak from scratch.
  13986. * Could be useful to regenerate the texture if it is setup to render only once.
  13987. */
  13988. resetRefreshCounter(): void;
  13989. /**
  13990. * Set the fragment shader to use in order to render the texture.
  13991. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13992. */
  13993. setFragment(fragment: any): void;
  13994. /**
  13995. * Define the refresh rate of the texture or the rendering frequency.
  13996. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13997. */
  13998. refreshRate: number;
  13999. /** @hidden */
  14000. _shouldRender(): boolean;
  14001. /**
  14002. * Get the size the texture is rendering at.
  14003. * @returns the size (texture is always squared)
  14004. */
  14005. getRenderSize(): number;
  14006. /**
  14007. * Resize the texture to new value.
  14008. * @param size Define the new size the texture should have
  14009. * @param generateMipMaps Define whether the new texture should create mip maps
  14010. */
  14011. resize(size: number, generateMipMaps: boolean): void;
  14012. private _checkUniform;
  14013. /**
  14014. * Set a texture in the shader program used to render.
  14015. * @param name Define the name of the uniform samplers as defined in the shader
  14016. * @param texture Define the texture to bind to this sampler
  14017. * @return the texture itself allowing "fluent" like uniform updates
  14018. */
  14019. setTexture(name: string, texture: Texture): ProceduralTexture;
  14020. /**
  14021. * Set a float in the shader.
  14022. * @param name Define the name of the uniform as defined in the shader
  14023. * @param value Define the value to give to the uniform
  14024. * @return the texture itself allowing "fluent" like uniform updates
  14025. */
  14026. setFloat(name: string, value: number): ProceduralTexture;
  14027. /**
  14028. * Set a int in the shader.
  14029. * @param name Define the name of the uniform as defined in the shader
  14030. * @param value Define the value to give to the uniform
  14031. * @return the texture itself allowing "fluent" like uniform updates
  14032. */
  14033. setInt(name: string, value: number): ProceduralTexture;
  14034. /**
  14035. * Set an array of floats in the shader.
  14036. * @param name Define the name of the uniform as defined in the shader
  14037. * @param value Define the value to give to the uniform
  14038. * @return the texture itself allowing "fluent" like uniform updates
  14039. */
  14040. setFloats(name: string, value: number[]): ProceduralTexture;
  14041. /**
  14042. * Set a vec3 in the shader from a Color3.
  14043. * @param name Define the name of the uniform as defined in the shader
  14044. * @param value Define the value to give to the uniform
  14045. * @return the texture itself allowing "fluent" like uniform updates
  14046. */
  14047. setColor3(name: string, value: Color3): ProceduralTexture;
  14048. /**
  14049. * Set a vec4 in the shader from a Color4.
  14050. * @param name Define the name of the uniform as defined in the shader
  14051. * @param value Define the value to give to the uniform
  14052. * @return the texture itself allowing "fluent" like uniform updates
  14053. */
  14054. setColor4(name: string, value: Color4): ProceduralTexture;
  14055. /**
  14056. * Set a vec2 in the shader from a Vector2.
  14057. * @param name Define the name of the uniform as defined in the shader
  14058. * @param value Define the value to give to the uniform
  14059. * @return the texture itself allowing "fluent" like uniform updates
  14060. */
  14061. setVector2(name: string, value: Vector2): ProceduralTexture;
  14062. /**
  14063. * Set a vec3 in the shader from a Vector3.
  14064. * @param name Define the name of the uniform as defined in the shader
  14065. * @param value Define the value to give to the uniform
  14066. * @return the texture itself allowing "fluent" like uniform updates
  14067. */
  14068. setVector3(name: string, value: Vector3): ProceduralTexture;
  14069. /**
  14070. * Set a mat4 in the shader from a MAtrix.
  14071. * @param name Define the name of the uniform as defined in the shader
  14072. * @param value Define the value to give to the uniform
  14073. * @return the texture itself allowing "fluent" like uniform updates
  14074. */
  14075. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14076. /**
  14077. * Render the texture to its associated render target.
  14078. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14079. */
  14080. render(useCameraPostProcess?: boolean): void;
  14081. /**
  14082. * Clone the texture.
  14083. * @returns the cloned texture
  14084. */
  14085. clone(): ProceduralTexture;
  14086. /**
  14087. * Dispose the texture and release its asoociated resources.
  14088. */
  14089. dispose(): void;
  14090. }
  14091. }
  14092. declare module "babylonjs/Particles/baseParticleSystem" {
  14093. import { Nullable } from "babylonjs/types";
  14094. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14096. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14097. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14098. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14099. import { Scene } from "babylonjs/scene";
  14100. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14101. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14102. import { Texture } from "babylonjs/Materials/Textures/texture";
  14103. import { Animation } from "babylonjs/Animations/animation";
  14104. /**
  14105. * This represents the base class for particle system in Babylon.
  14106. * 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.
  14107. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14108. * @example https://doc.babylonjs.com/babylon101/particles
  14109. */
  14110. export class BaseParticleSystem {
  14111. /**
  14112. * Source color is added to the destination color without alpha affecting the result
  14113. */
  14114. static BLENDMODE_ONEONE: number;
  14115. /**
  14116. * Blend current color and particle color using particle’s alpha
  14117. */
  14118. static BLENDMODE_STANDARD: number;
  14119. /**
  14120. * Add current color and particle color multiplied by particle’s alpha
  14121. */
  14122. static BLENDMODE_ADD: number;
  14123. /**
  14124. * Multiply current color with particle color
  14125. */
  14126. static BLENDMODE_MULTIPLY: number;
  14127. /**
  14128. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14129. */
  14130. static BLENDMODE_MULTIPLYADD: number;
  14131. /**
  14132. * List of animations used by the particle system.
  14133. */
  14134. animations: Animation[];
  14135. /**
  14136. * The id of the Particle system.
  14137. */
  14138. id: string;
  14139. /**
  14140. * The friendly name of the Particle system.
  14141. */
  14142. name: string;
  14143. /**
  14144. * The rendering group used by the Particle system to chose when to render.
  14145. */
  14146. renderingGroupId: number;
  14147. /**
  14148. * The emitter represents the Mesh or position we are attaching the particle system to.
  14149. */
  14150. emitter: Nullable<AbstractMesh | Vector3>;
  14151. /**
  14152. * The maximum number of particles to emit per frame
  14153. */
  14154. emitRate: number;
  14155. /**
  14156. * If you want to launch only a few particles at once, that can be done, as well.
  14157. */
  14158. manualEmitCount: number;
  14159. /**
  14160. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14161. */
  14162. updateSpeed: number;
  14163. /**
  14164. * The amount of time the particle system is running (depends of the overall update speed).
  14165. */
  14166. targetStopDuration: number;
  14167. /**
  14168. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14169. */
  14170. disposeOnStop: boolean;
  14171. /**
  14172. * Minimum power of emitting particles.
  14173. */
  14174. minEmitPower: number;
  14175. /**
  14176. * Maximum power of emitting particles.
  14177. */
  14178. maxEmitPower: number;
  14179. /**
  14180. * Minimum life time of emitting particles.
  14181. */
  14182. minLifeTime: number;
  14183. /**
  14184. * Maximum life time of emitting particles.
  14185. */
  14186. maxLifeTime: number;
  14187. /**
  14188. * Minimum Size of emitting particles.
  14189. */
  14190. minSize: number;
  14191. /**
  14192. * Maximum Size of emitting particles.
  14193. */
  14194. maxSize: number;
  14195. /**
  14196. * Minimum scale of emitting particles on X axis.
  14197. */
  14198. minScaleX: number;
  14199. /**
  14200. * Maximum scale of emitting particles on X axis.
  14201. */
  14202. maxScaleX: number;
  14203. /**
  14204. * Minimum scale of emitting particles on Y axis.
  14205. */
  14206. minScaleY: number;
  14207. /**
  14208. * Maximum scale of emitting particles on Y axis.
  14209. */
  14210. maxScaleY: number;
  14211. /**
  14212. * Gets or sets the minimal initial rotation in radians.
  14213. */
  14214. minInitialRotation: number;
  14215. /**
  14216. * Gets or sets the maximal initial rotation in radians.
  14217. */
  14218. maxInitialRotation: number;
  14219. /**
  14220. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14221. */
  14222. minAngularSpeed: number;
  14223. /**
  14224. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14225. */
  14226. maxAngularSpeed: number;
  14227. /**
  14228. * The texture used to render each particle. (this can be a spritesheet)
  14229. */
  14230. particleTexture: Nullable<Texture>;
  14231. /**
  14232. * The layer mask we are rendering the particles through.
  14233. */
  14234. layerMask: number;
  14235. /**
  14236. * This can help using your own shader to render the particle system.
  14237. * The according effect will be created
  14238. */
  14239. customShader: any;
  14240. /**
  14241. * By default particle system starts as soon as they are created. This prevents the
  14242. * automatic start to happen and let you decide when to start emitting particles.
  14243. */
  14244. preventAutoStart: boolean;
  14245. private _noiseTexture;
  14246. /**
  14247. * Gets or sets a texture used to add random noise to particle positions
  14248. */
  14249. noiseTexture: Nullable<ProceduralTexture>;
  14250. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14251. noiseStrength: Vector3;
  14252. /**
  14253. * Callback triggered when the particle animation is ending.
  14254. */
  14255. onAnimationEnd: Nullable<() => void>;
  14256. /**
  14257. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14258. */
  14259. blendMode: number;
  14260. /**
  14261. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14262. * to override the particles.
  14263. */
  14264. forceDepthWrite: boolean;
  14265. /** 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 */
  14266. preWarmCycles: number;
  14267. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14268. preWarmStepOffset: number;
  14269. /**
  14270. * 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)
  14271. */
  14272. spriteCellChangeSpeed: number;
  14273. /**
  14274. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14275. */
  14276. startSpriteCellID: number;
  14277. /**
  14278. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14279. */
  14280. endSpriteCellID: number;
  14281. /**
  14282. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14283. */
  14284. spriteCellWidth: number;
  14285. /**
  14286. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14287. */
  14288. spriteCellHeight: number;
  14289. /**
  14290. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14291. */
  14292. spriteRandomStartCell: boolean;
  14293. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14294. translationPivot: Vector2;
  14295. /** @hidden */
  14296. protected _isAnimationSheetEnabled: boolean;
  14297. /**
  14298. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14299. */
  14300. beginAnimationOnStart: boolean;
  14301. /**
  14302. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14303. */
  14304. beginAnimationFrom: number;
  14305. /**
  14306. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14307. */
  14308. beginAnimationTo: number;
  14309. /**
  14310. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14311. */
  14312. beginAnimationLoop: boolean;
  14313. /**
  14314. * Gets or sets a world offset applied to all particles
  14315. */
  14316. worldOffset: Vector3;
  14317. /**
  14318. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14319. */
  14320. isAnimationSheetEnabled: boolean;
  14321. /**
  14322. * Get hosting scene
  14323. * @returns the scene
  14324. */
  14325. getScene(): Scene;
  14326. /**
  14327. * You can use gravity if you want to give an orientation to your particles.
  14328. */
  14329. gravity: Vector3;
  14330. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14331. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14332. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14333. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14334. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14335. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14336. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14337. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14338. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14339. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14340. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14341. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14342. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14343. /**
  14344. * Defines the delay in milliseconds before starting the system (0 by default)
  14345. */
  14346. startDelay: number;
  14347. /**
  14348. * Gets the current list of drag gradients.
  14349. * You must use addDragGradient and removeDragGradient to udpate this list
  14350. * @returns the list of drag gradients
  14351. */
  14352. getDragGradients(): Nullable<Array<FactorGradient>>;
  14353. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14354. limitVelocityDamping: number;
  14355. /**
  14356. * Gets the current list of limit velocity gradients.
  14357. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14358. * @returns the list of limit velocity gradients
  14359. */
  14360. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14361. /**
  14362. * Gets the current list of color gradients.
  14363. * You must use addColorGradient and removeColorGradient to udpate this list
  14364. * @returns the list of color gradients
  14365. */
  14366. getColorGradients(): Nullable<Array<ColorGradient>>;
  14367. /**
  14368. * Gets the current list of size gradients.
  14369. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14370. * @returns the list of size gradients
  14371. */
  14372. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14373. /**
  14374. * Gets the current list of color remap gradients.
  14375. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14376. * @returns the list of color remap gradients
  14377. */
  14378. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14379. /**
  14380. * Gets the current list of alpha remap gradients.
  14381. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14382. * @returns the list of alpha remap gradients
  14383. */
  14384. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14385. /**
  14386. * Gets the current list of life time gradients.
  14387. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14388. * @returns the list of life time gradients
  14389. */
  14390. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14391. /**
  14392. * Gets the current list of angular speed gradients.
  14393. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14394. * @returns the list of angular speed gradients
  14395. */
  14396. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14397. /**
  14398. * Gets the current list of velocity gradients.
  14399. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14400. * @returns the list of velocity gradients
  14401. */
  14402. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14403. /**
  14404. * Gets the current list of start size gradients.
  14405. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14406. * @returns the list of start size gradients
  14407. */
  14408. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14409. /**
  14410. * Gets the current list of emit rate gradients.
  14411. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14412. * @returns the list of emit rate gradients
  14413. */
  14414. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14415. /**
  14416. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14417. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14418. */
  14419. direction1: Vector3;
  14420. /**
  14421. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14422. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14423. */
  14424. direction2: Vector3;
  14425. /**
  14426. * 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.
  14427. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14428. */
  14429. minEmitBox: Vector3;
  14430. /**
  14431. * 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.
  14432. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14433. */
  14434. maxEmitBox: Vector3;
  14435. /**
  14436. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14437. */
  14438. color1: Color4;
  14439. /**
  14440. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14441. */
  14442. color2: Color4;
  14443. /**
  14444. * Color the particle will have at the end of its lifetime
  14445. */
  14446. colorDead: Color4;
  14447. /**
  14448. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14449. */
  14450. textureMask: Color4;
  14451. /**
  14452. * The particle emitter type defines the emitter used by the particle system.
  14453. * It can be for example box, sphere, or cone...
  14454. */
  14455. particleEmitterType: IParticleEmitterType;
  14456. /** @hidden */
  14457. _isSubEmitter: boolean;
  14458. /**
  14459. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14460. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14461. */
  14462. billboardMode: number;
  14463. protected _isBillboardBased: boolean;
  14464. /**
  14465. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14466. */
  14467. isBillboardBased: boolean;
  14468. /**
  14469. * The scene the particle system belongs to.
  14470. */
  14471. protected _scene: Scene;
  14472. /**
  14473. * Local cache of defines for image processing.
  14474. */
  14475. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14476. /**
  14477. * Default configuration related to image processing available in the standard Material.
  14478. */
  14479. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14480. /**
  14481. * Gets the image processing configuration used either in this material.
  14482. */
  14483. /**
  14484. * Sets the Default image processing configuration used either in the this material.
  14485. *
  14486. * If sets to null, the scene one is in use.
  14487. */
  14488. imageProcessingConfiguration: ImageProcessingConfiguration;
  14489. /**
  14490. * Attaches a new image processing configuration to the Standard Material.
  14491. * @param configuration
  14492. */
  14493. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14494. /** @hidden */
  14495. protected _reset(): void;
  14496. /** @hidden */
  14497. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14498. /**
  14499. * Instantiates a particle system.
  14500. * 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.
  14501. * @param name The name of the particle system
  14502. */
  14503. constructor(name: string);
  14504. /**
  14505. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14506. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14507. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14508. * @returns the emitter
  14509. */
  14510. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14511. /**
  14512. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14513. * @param radius The radius of the hemisphere to emit from
  14514. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14515. * @returns the emitter
  14516. */
  14517. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14518. /**
  14519. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14520. * @param radius The radius of the sphere to emit from
  14521. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14522. * @returns the emitter
  14523. */
  14524. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14525. /**
  14526. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14527. * @param radius The radius of the sphere to emit from
  14528. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14529. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14530. * @returns the emitter
  14531. */
  14532. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14533. /**
  14534. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14535. * @param radius The radius of the emission cylinder
  14536. * @param height The height of the emission cylinder
  14537. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14538. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14539. * @returns the emitter
  14540. */
  14541. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14542. /**
  14543. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14544. * @param radius The radius of the cylinder to emit from
  14545. * @param height The height of the emission cylinder
  14546. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14547. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14548. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14549. * @returns the emitter
  14550. */
  14551. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14552. /**
  14553. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14554. * @param radius The radius of the cone to emit from
  14555. * @param angle The base angle of the cone
  14556. * @returns the emitter
  14557. */
  14558. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14559. /**
  14560. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14561. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14562. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14563. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14564. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14565. * @returns the emitter
  14566. */
  14567. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14568. }
  14569. }
  14570. declare module "babylonjs/Particles/subEmitter" {
  14571. import { Scene } from "babylonjs/scene";
  14572. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14573. /**
  14574. * Type of sub emitter
  14575. */
  14576. export enum SubEmitterType {
  14577. /**
  14578. * Attached to the particle over it's lifetime
  14579. */
  14580. ATTACHED = 0,
  14581. /**
  14582. * Created when the particle dies
  14583. */
  14584. END = 1
  14585. }
  14586. /**
  14587. * Sub emitter class used to emit particles from an existing particle
  14588. */
  14589. export class SubEmitter {
  14590. /**
  14591. * the particle system to be used by the sub emitter
  14592. */
  14593. particleSystem: ParticleSystem;
  14594. /**
  14595. * Type of the submitter (Default: END)
  14596. */
  14597. type: SubEmitterType;
  14598. /**
  14599. * 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)
  14600. * Note: This only is supported when using an emitter of type Mesh
  14601. */
  14602. inheritDirection: boolean;
  14603. /**
  14604. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14605. */
  14606. inheritedVelocityAmount: number;
  14607. /**
  14608. * Creates a sub emitter
  14609. * @param particleSystem the particle system to be used by the sub emitter
  14610. */
  14611. constructor(
  14612. /**
  14613. * the particle system to be used by the sub emitter
  14614. */
  14615. particleSystem: ParticleSystem);
  14616. /**
  14617. * Clones the sub emitter
  14618. * @returns the cloned sub emitter
  14619. */
  14620. clone(): SubEmitter;
  14621. /**
  14622. * Serialize current object to a JSON object
  14623. * @returns the serialized object
  14624. */
  14625. serialize(): any;
  14626. /** @hidden */
  14627. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14628. /**
  14629. * Creates a new SubEmitter from a serialized JSON version
  14630. * @param serializationObject defines the JSON object to read from
  14631. * @param scene defines the hosting scene
  14632. * @param rootUrl defines the rootUrl for data loading
  14633. * @returns a new SubEmitter
  14634. */
  14635. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14636. /** Release associated resources */
  14637. dispose(): void;
  14638. }
  14639. }
  14640. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14641. /** @hidden */
  14642. export var clipPlaneFragmentDeclaration: {
  14643. name: string;
  14644. shader: string;
  14645. };
  14646. }
  14647. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14648. /** @hidden */
  14649. export var imageProcessingDeclaration: {
  14650. name: string;
  14651. shader: string;
  14652. };
  14653. }
  14654. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14655. /** @hidden */
  14656. export var imageProcessingFunctions: {
  14657. name: string;
  14658. shader: string;
  14659. };
  14660. }
  14661. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14662. /** @hidden */
  14663. export var clipPlaneFragment: {
  14664. name: string;
  14665. shader: string;
  14666. };
  14667. }
  14668. declare module "babylonjs/Shaders/particles.fragment" {
  14669. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14670. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14671. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14672. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14673. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14674. /** @hidden */
  14675. export var particlesPixelShader: {
  14676. name: string;
  14677. shader: string;
  14678. };
  14679. }
  14680. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14681. /** @hidden */
  14682. export var clipPlaneVertexDeclaration: {
  14683. name: string;
  14684. shader: string;
  14685. };
  14686. }
  14687. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14688. /** @hidden */
  14689. export var clipPlaneVertex: {
  14690. name: string;
  14691. shader: string;
  14692. };
  14693. }
  14694. declare module "babylonjs/Shaders/particles.vertex" {
  14695. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14696. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14697. /** @hidden */
  14698. export var particlesVertexShader: {
  14699. name: string;
  14700. shader: string;
  14701. };
  14702. }
  14703. declare module "babylonjs/Particles/particleSystem" {
  14704. import { Nullable } from "babylonjs/types";
  14705. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14706. import { Observable } from "babylonjs/Misc/observable";
  14707. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14708. import { Effect } from "babylonjs/Materials/effect";
  14709. import { Scene, IDisposable } from "babylonjs/scene";
  14710. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14711. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14712. import { Particle } from "babylonjs/Particles/particle";
  14713. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14714. import "babylonjs/Shaders/particles.fragment";
  14715. import "babylonjs/Shaders/particles.vertex";
  14716. /**
  14717. * This represents a particle system in Babylon.
  14718. * 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.
  14719. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14720. * @example https://doc.babylonjs.com/babylon101/particles
  14721. */
  14722. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14723. /**
  14724. * Billboard mode will only apply to Y axis
  14725. */
  14726. static readonly BILLBOARDMODE_Y: number;
  14727. /**
  14728. * Billboard mode will apply to all axes
  14729. */
  14730. static readonly BILLBOARDMODE_ALL: number;
  14731. /**
  14732. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14733. */
  14734. static readonly BILLBOARDMODE_STRETCHED: number;
  14735. /**
  14736. * This function can be defined to provide custom update for active particles.
  14737. * This function will be called instead of regular update (age, position, color, etc.).
  14738. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14739. */
  14740. updateFunction: (particles: Particle[]) => void;
  14741. private _emitterWorldMatrix;
  14742. /**
  14743. * This function can be defined to specify initial direction for every new particle.
  14744. * It by default use the emitterType defined function
  14745. */
  14746. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14747. /**
  14748. * This function can be defined to specify initial position for every new particle.
  14749. * It by default use the emitterType defined function
  14750. */
  14751. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14752. /**
  14753. * @hidden
  14754. */
  14755. _inheritedVelocityOffset: Vector3;
  14756. /**
  14757. * An event triggered when the system is disposed
  14758. */
  14759. onDisposeObservable: Observable<ParticleSystem>;
  14760. private _onDisposeObserver;
  14761. /**
  14762. * Sets a callback that will be triggered when the system is disposed
  14763. */
  14764. onDispose: () => void;
  14765. private _particles;
  14766. private _epsilon;
  14767. private _capacity;
  14768. private _stockParticles;
  14769. private _newPartsExcess;
  14770. private _vertexData;
  14771. private _vertexBuffer;
  14772. private _vertexBuffers;
  14773. private _spriteBuffer;
  14774. private _indexBuffer;
  14775. private _effect;
  14776. private _customEffect;
  14777. private _cachedDefines;
  14778. private _scaledColorStep;
  14779. private _colorDiff;
  14780. private _scaledDirection;
  14781. private _scaledGravity;
  14782. private _currentRenderId;
  14783. private _alive;
  14784. private _useInstancing;
  14785. private _started;
  14786. private _stopped;
  14787. private _actualFrame;
  14788. private _scaledUpdateSpeed;
  14789. private _vertexBufferSize;
  14790. /** @hidden */
  14791. _currentEmitRateGradient: Nullable<FactorGradient>;
  14792. /** @hidden */
  14793. _currentEmitRate1: number;
  14794. /** @hidden */
  14795. _currentEmitRate2: number;
  14796. /** @hidden */
  14797. _currentStartSizeGradient: Nullable<FactorGradient>;
  14798. /** @hidden */
  14799. _currentStartSize1: number;
  14800. /** @hidden */
  14801. _currentStartSize2: number;
  14802. private readonly _rawTextureWidth;
  14803. private _rampGradientsTexture;
  14804. private _useRampGradients;
  14805. /** Gets or sets a boolean indicating that ramp gradients must be used
  14806. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14807. */
  14808. useRampGradients: boolean;
  14809. /**
  14810. * 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.
  14811. * 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: [])
  14812. */
  14813. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14814. private _subEmitters;
  14815. /**
  14816. * @hidden
  14817. * If the particle systems emitter should be disposed when the particle system is disposed
  14818. */
  14819. _disposeEmitterOnDispose: boolean;
  14820. /**
  14821. * The current active Sub-systems, this property is used by the root particle system only.
  14822. */
  14823. activeSubSystems: Array<ParticleSystem>;
  14824. private _rootParticleSystem;
  14825. /**
  14826. * Gets the current list of active particles
  14827. */
  14828. readonly particles: Particle[];
  14829. /**
  14830. * Returns the string "ParticleSystem"
  14831. * @returns a string containing the class name
  14832. */
  14833. getClassName(): string;
  14834. /**
  14835. * Instantiates a particle system.
  14836. * 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.
  14837. * @param name The name of the particle system
  14838. * @param capacity The max number of particles alive at the same time
  14839. * @param scene The scene the particle system belongs to
  14840. * @param customEffect a custom effect used to change the way particles are rendered by default
  14841. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14842. * @param epsilon Offset used to render the particles
  14843. */
  14844. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14845. private _addFactorGradient;
  14846. private _removeFactorGradient;
  14847. /**
  14848. * Adds a new life time gradient
  14849. * @param gradient defines the gradient to use (between 0 and 1)
  14850. * @param factor defines the life time factor to affect to the specified gradient
  14851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14852. * @returns the current particle system
  14853. */
  14854. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14855. /**
  14856. * Remove a specific life time gradient
  14857. * @param gradient defines the gradient to remove
  14858. * @returns the current particle system
  14859. */
  14860. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14861. /**
  14862. * Adds a new size gradient
  14863. * @param gradient defines the gradient to use (between 0 and 1)
  14864. * @param factor defines the size factor to affect to the specified gradient
  14865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14866. * @returns the current particle system
  14867. */
  14868. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14869. /**
  14870. * Remove a specific size gradient
  14871. * @param gradient defines the gradient to remove
  14872. * @returns the current particle system
  14873. */
  14874. removeSizeGradient(gradient: number): IParticleSystem;
  14875. /**
  14876. * Adds a new color remap gradient
  14877. * @param gradient defines the gradient to use (between 0 and 1)
  14878. * @param min defines the color remap minimal range
  14879. * @param max defines the color remap maximal range
  14880. * @returns the current particle system
  14881. */
  14882. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14883. /**
  14884. * Remove a specific color remap gradient
  14885. * @param gradient defines the gradient to remove
  14886. * @returns the current particle system
  14887. */
  14888. removeColorRemapGradient(gradient: number): IParticleSystem;
  14889. /**
  14890. * Adds a new alpha remap gradient
  14891. * @param gradient defines the gradient to use (between 0 and 1)
  14892. * @param min defines the alpha remap minimal range
  14893. * @param max defines the alpha remap maximal range
  14894. * @returns the current particle system
  14895. */
  14896. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14897. /**
  14898. * Remove a specific alpha remap gradient
  14899. * @param gradient defines the gradient to remove
  14900. * @returns the current particle system
  14901. */
  14902. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14903. /**
  14904. * Adds a new angular speed gradient
  14905. * @param gradient defines the gradient to use (between 0 and 1)
  14906. * @param factor defines the angular speed to affect to the specified gradient
  14907. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14908. * @returns the current particle system
  14909. */
  14910. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14911. /**
  14912. * Remove a specific angular speed gradient
  14913. * @param gradient defines the gradient to remove
  14914. * @returns the current particle system
  14915. */
  14916. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14917. /**
  14918. * Adds a new velocity gradient
  14919. * @param gradient defines the gradient to use (between 0 and 1)
  14920. * @param factor defines the velocity to affect to the specified gradient
  14921. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14922. * @returns the current particle system
  14923. */
  14924. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14925. /**
  14926. * Remove a specific velocity gradient
  14927. * @param gradient defines the gradient to remove
  14928. * @returns the current particle system
  14929. */
  14930. removeVelocityGradient(gradient: number): IParticleSystem;
  14931. /**
  14932. * Adds a new limit velocity gradient
  14933. * @param gradient defines the gradient to use (between 0 and 1)
  14934. * @param factor defines the limit velocity value to affect to the specified gradient
  14935. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14936. * @returns the current particle system
  14937. */
  14938. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14939. /**
  14940. * Remove a specific limit velocity gradient
  14941. * @param gradient defines the gradient to remove
  14942. * @returns the current particle system
  14943. */
  14944. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14945. /**
  14946. * Adds a new drag gradient
  14947. * @param gradient defines the gradient to use (between 0 and 1)
  14948. * @param factor defines the drag value to affect to the specified gradient
  14949. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14950. * @returns the current particle system
  14951. */
  14952. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14953. /**
  14954. * Remove a specific drag gradient
  14955. * @param gradient defines the gradient to remove
  14956. * @returns the current particle system
  14957. */
  14958. removeDragGradient(gradient: number): IParticleSystem;
  14959. /**
  14960. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14961. * @param gradient defines the gradient to use (between 0 and 1)
  14962. * @param factor defines the emit rate value to affect to the specified gradient
  14963. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14964. * @returns the current particle system
  14965. */
  14966. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14967. /**
  14968. * Remove a specific emit rate gradient
  14969. * @param gradient defines the gradient to remove
  14970. * @returns the current particle system
  14971. */
  14972. removeEmitRateGradient(gradient: number): IParticleSystem;
  14973. /**
  14974. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14975. * @param gradient defines the gradient to use (between 0 and 1)
  14976. * @param factor defines the start size value to affect to the specified gradient
  14977. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14978. * @returns the current particle system
  14979. */
  14980. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14981. /**
  14982. * Remove a specific start size gradient
  14983. * @param gradient defines the gradient to remove
  14984. * @returns the current particle system
  14985. */
  14986. removeStartSizeGradient(gradient: number): IParticleSystem;
  14987. private _createRampGradientTexture;
  14988. /**
  14989. * Gets the current list of ramp gradients.
  14990. * You must use addRampGradient and removeRampGradient to udpate this list
  14991. * @returns the list of ramp gradients
  14992. */
  14993. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14994. /**
  14995. * Adds a new ramp gradient used to remap particle colors
  14996. * @param gradient defines the gradient to use (between 0 and 1)
  14997. * @param color defines the color to affect to the specified gradient
  14998. * @returns the current particle system
  14999. */
  15000. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15001. /**
  15002. * Remove a specific ramp gradient
  15003. * @param gradient defines the gradient to remove
  15004. * @returns the current particle system
  15005. */
  15006. removeRampGradient(gradient: number): ParticleSystem;
  15007. /**
  15008. * Adds a new color gradient
  15009. * @param gradient defines the gradient to use (between 0 and 1)
  15010. * @param color1 defines the color to affect to the specified gradient
  15011. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15012. * @returns this particle system
  15013. */
  15014. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15015. /**
  15016. * Remove a specific color gradient
  15017. * @param gradient defines the gradient to remove
  15018. * @returns this particle system
  15019. */
  15020. removeColorGradient(gradient: number): IParticleSystem;
  15021. private _fetchR;
  15022. protected _reset(): void;
  15023. private _resetEffect;
  15024. private _createVertexBuffers;
  15025. private _createIndexBuffer;
  15026. /**
  15027. * Gets the maximum number of particles active at the same time.
  15028. * @returns The max number of active particles.
  15029. */
  15030. getCapacity(): number;
  15031. /**
  15032. * Gets whether there are still active particles in the system.
  15033. * @returns True if it is alive, otherwise false.
  15034. */
  15035. isAlive(): boolean;
  15036. /**
  15037. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15038. * @returns True if it has been started, otherwise false.
  15039. */
  15040. isStarted(): boolean;
  15041. private _prepareSubEmitterInternalArray;
  15042. /**
  15043. * Starts the particle system and begins to emit
  15044. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15045. */
  15046. start(delay?: number): void;
  15047. /**
  15048. * Stops the particle system.
  15049. * @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.
  15050. */
  15051. stop(stopSubEmitters?: boolean): void;
  15052. /**
  15053. * Remove all active particles
  15054. */
  15055. reset(): void;
  15056. /**
  15057. * @hidden (for internal use only)
  15058. */
  15059. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15060. /**
  15061. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15062. * Its lifetime will start back at 0.
  15063. */
  15064. recycleParticle: (particle: Particle) => void;
  15065. private _stopSubEmitters;
  15066. private _createParticle;
  15067. private _removeFromRoot;
  15068. private _emitFromParticle;
  15069. private _update;
  15070. /** @hidden */
  15071. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15072. /** @hidden */
  15073. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15074. /** @hidden */
  15075. private _getEffect;
  15076. /**
  15077. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15078. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15079. */
  15080. animate(preWarmOnly?: boolean): void;
  15081. private _appendParticleVertices;
  15082. /**
  15083. * Rebuilds the particle system.
  15084. */
  15085. rebuild(): void;
  15086. /**
  15087. * Is this system ready to be used/rendered
  15088. * @return true if the system is ready
  15089. */
  15090. isReady(): boolean;
  15091. private _render;
  15092. /**
  15093. * Renders the particle system in its current state.
  15094. * @returns the current number of particles
  15095. */
  15096. render(): number;
  15097. /**
  15098. * Disposes the particle system and free the associated resources
  15099. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15100. */
  15101. dispose(disposeTexture?: boolean): void;
  15102. /**
  15103. * Clones the particle system.
  15104. * @param name The name of the cloned object
  15105. * @param newEmitter The new emitter to use
  15106. * @returns the cloned particle system
  15107. */
  15108. clone(name: string, newEmitter: any): ParticleSystem;
  15109. /**
  15110. * Serializes the particle system to a JSON object.
  15111. * @returns the JSON object
  15112. */
  15113. serialize(): any;
  15114. /** @hidden */
  15115. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15116. /** @hidden */
  15117. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15118. /**
  15119. * Parses a JSON object to create a particle system.
  15120. * @param parsedParticleSystem The JSON object to parse
  15121. * @param scene The scene to create the particle system in
  15122. * @param rootUrl The root url to use to load external dependencies like texture
  15123. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15124. * @returns the Parsed particle system
  15125. */
  15126. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15127. }
  15128. }
  15129. declare module "babylonjs/Particles/particle" {
  15130. import { Nullable } from "babylonjs/types";
  15131. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15132. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15133. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15134. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15135. /**
  15136. * A particle represents one of the element emitted by a particle system.
  15137. * This is mainly define by its coordinates, direction, velocity and age.
  15138. */
  15139. export class Particle {
  15140. /**
  15141. * The particle system the particle belongs to.
  15142. */
  15143. particleSystem: ParticleSystem;
  15144. private static _Count;
  15145. /**
  15146. * Unique ID of the particle
  15147. */
  15148. id: number;
  15149. /**
  15150. * The world position of the particle in the scene.
  15151. */
  15152. position: Vector3;
  15153. /**
  15154. * The world direction of the particle in the scene.
  15155. */
  15156. direction: Vector3;
  15157. /**
  15158. * The color of the particle.
  15159. */
  15160. color: Color4;
  15161. /**
  15162. * The color change of the particle per step.
  15163. */
  15164. colorStep: Color4;
  15165. /**
  15166. * Defines how long will the life of the particle be.
  15167. */
  15168. lifeTime: number;
  15169. /**
  15170. * The current age of the particle.
  15171. */
  15172. age: number;
  15173. /**
  15174. * The current size of the particle.
  15175. */
  15176. size: number;
  15177. /**
  15178. * The current scale of the particle.
  15179. */
  15180. scale: Vector2;
  15181. /**
  15182. * The current angle of the particle.
  15183. */
  15184. angle: number;
  15185. /**
  15186. * Defines how fast is the angle changing.
  15187. */
  15188. angularSpeed: number;
  15189. /**
  15190. * Defines the cell index used by the particle to be rendered from a sprite.
  15191. */
  15192. cellIndex: number;
  15193. /**
  15194. * The information required to support color remapping
  15195. */
  15196. remapData: Vector4;
  15197. /** @hidden */
  15198. _randomCellOffset?: number;
  15199. /** @hidden */
  15200. _initialDirection: Nullable<Vector3>;
  15201. /** @hidden */
  15202. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15203. /** @hidden */
  15204. _initialStartSpriteCellID: number;
  15205. /** @hidden */
  15206. _initialEndSpriteCellID: number;
  15207. /** @hidden */
  15208. _currentColorGradient: Nullable<ColorGradient>;
  15209. /** @hidden */
  15210. _currentColor1: Color4;
  15211. /** @hidden */
  15212. _currentColor2: Color4;
  15213. /** @hidden */
  15214. _currentSizeGradient: Nullable<FactorGradient>;
  15215. /** @hidden */
  15216. _currentSize1: number;
  15217. /** @hidden */
  15218. _currentSize2: number;
  15219. /** @hidden */
  15220. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15221. /** @hidden */
  15222. _currentAngularSpeed1: number;
  15223. /** @hidden */
  15224. _currentAngularSpeed2: number;
  15225. /** @hidden */
  15226. _currentVelocityGradient: Nullable<FactorGradient>;
  15227. /** @hidden */
  15228. _currentVelocity1: number;
  15229. /** @hidden */
  15230. _currentVelocity2: number;
  15231. /** @hidden */
  15232. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15233. /** @hidden */
  15234. _currentLimitVelocity1: number;
  15235. /** @hidden */
  15236. _currentLimitVelocity2: number;
  15237. /** @hidden */
  15238. _currentDragGradient: Nullable<FactorGradient>;
  15239. /** @hidden */
  15240. _currentDrag1: number;
  15241. /** @hidden */
  15242. _currentDrag2: number;
  15243. /** @hidden */
  15244. _randomNoiseCoordinates1: Vector3;
  15245. /** @hidden */
  15246. _randomNoiseCoordinates2: Vector3;
  15247. /**
  15248. * Creates a new instance Particle
  15249. * @param particleSystem the particle system the particle belongs to
  15250. */
  15251. constructor(
  15252. /**
  15253. * The particle system the particle belongs to.
  15254. */
  15255. particleSystem: ParticleSystem);
  15256. private updateCellInfoFromSystem;
  15257. /**
  15258. * Defines how the sprite cell index is updated for the particle
  15259. */
  15260. updateCellIndex(): void;
  15261. /** @hidden */
  15262. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15263. /** @hidden */
  15264. _inheritParticleInfoToSubEmitters(): void;
  15265. /** @hidden */
  15266. _reset(): void;
  15267. /**
  15268. * Copy the properties of particle to another one.
  15269. * @param other the particle to copy the information to.
  15270. */
  15271. copyTo(other: Particle): void;
  15272. }
  15273. }
  15274. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15275. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15276. import { Effect } from "babylonjs/Materials/effect";
  15277. import { Particle } from "babylonjs/Particles/particle";
  15278. /**
  15279. * Particle emitter represents a volume emitting particles.
  15280. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15281. */
  15282. export interface IParticleEmitterType {
  15283. /**
  15284. * Called by the particle System when the direction is computed for the created particle.
  15285. * @param worldMatrix is the world matrix of the particle system
  15286. * @param directionToUpdate is the direction vector to update with the result
  15287. * @param particle is the particle we are computed the direction for
  15288. */
  15289. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15290. /**
  15291. * Called by the particle System when the position is computed for the created particle.
  15292. * @param worldMatrix is the world matrix of the particle system
  15293. * @param positionToUpdate is the position vector to update with the result
  15294. * @param particle is the particle we are computed the position for
  15295. */
  15296. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15297. /**
  15298. * Clones the current emitter and returns a copy of it
  15299. * @returns the new emitter
  15300. */
  15301. clone(): IParticleEmitterType;
  15302. /**
  15303. * Called by the GPUParticleSystem to setup the update shader
  15304. * @param effect defines the update shader
  15305. */
  15306. applyToShader(effect: Effect): void;
  15307. /**
  15308. * Returns a string to use to update the GPU particles update shader
  15309. * @returns the effect defines string
  15310. */
  15311. getEffectDefines(): string;
  15312. /**
  15313. * Returns a string representing the class name
  15314. * @returns a string containing the class name
  15315. */
  15316. getClassName(): string;
  15317. /**
  15318. * Serializes the particle system to a JSON object.
  15319. * @returns the JSON object
  15320. */
  15321. serialize(): any;
  15322. /**
  15323. * Parse properties from a JSON object
  15324. * @param serializationObject defines the JSON object
  15325. */
  15326. parse(serializationObject: any): void;
  15327. }
  15328. }
  15329. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15330. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15331. import { Effect } from "babylonjs/Materials/effect";
  15332. import { Particle } from "babylonjs/Particles/particle";
  15333. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15334. /**
  15335. * Particle emitter emitting particles from the inside of a box.
  15336. * It emits the particles randomly between 2 given directions.
  15337. */
  15338. export class BoxParticleEmitter implements IParticleEmitterType {
  15339. /**
  15340. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15341. */
  15342. direction1: Vector3;
  15343. /**
  15344. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15345. */
  15346. direction2: Vector3;
  15347. /**
  15348. * 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.
  15349. */
  15350. minEmitBox: Vector3;
  15351. /**
  15352. * 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.
  15353. */
  15354. maxEmitBox: Vector3;
  15355. /**
  15356. * Creates a new instance BoxParticleEmitter
  15357. */
  15358. constructor();
  15359. /**
  15360. * Called by the particle System when the direction is computed for the created particle.
  15361. * @param worldMatrix is the world matrix of the particle system
  15362. * @param directionToUpdate is the direction vector to update with the result
  15363. * @param particle is the particle we are computed the direction for
  15364. */
  15365. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15366. /**
  15367. * Called by the particle System when the position is computed for the created particle.
  15368. * @param worldMatrix is the world matrix of the particle system
  15369. * @param positionToUpdate is the position vector to update with the result
  15370. * @param particle is the particle we are computed the position for
  15371. */
  15372. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15373. /**
  15374. * Clones the current emitter and returns a copy of it
  15375. * @returns the new emitter
  15376. */
  15377. clone(): BoxParticleEmitter;
  15378. /**
  15379. * Called by the GPUParticleSystem to setup the update shader
  15380. * @param effect defines the update shader
  15381. */
  15382. applyToShader(effect: Effect): void;
  15383. /**
  15384. * Returns a string to use to update the GPU particles update shader
  15385. * @returns a string containng the defines string
  15386. */
  15387. getEffectDefines(): string;
  15388. /**
  15389. * Returns the string "BoxParticleEmitter"
  15390. * @returns a string containing the class name
  15391. */
  15392. getClassName(): string;
  15393. /**
  15394. * Serializes the particle system to a JSON object.
  15395. * @returns the JSON object
  15396. */
  15397. serialize(): any;
  15398. /**
  15399. * Parse properties from a JSON object
  15400. * @param serializationObject defines the JSON object
  15401. */
  15402. parse(serializationObject: any): void;
  15403. }
  15404. }
  15405. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15406. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15407. import { Effect } from "babylonjs/Materials/effect";
  15408. import { Particle } from "babylonjs/Particles/particle";
  15409. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15410. /**
  15411. * Particle emitter emitting particles from the inside of a cone.
  15412. * It emits the particles alongside the cone volume from the base to the particle.
  15413. * The emission direction might be randomized.
  15414. */
  15415. export class ConeParticleEmitter implements IParticleEmitterType {
  15416. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15417. directionRandomizer: number;
  15418. private _radius;
  15419. private _angle;
  15420. private _height;
  15421. /**
  15422. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15423. */
  15424. radiusRange: number;
  15425. /**
  15426. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15427. */
  15428. heightRange: number;
  15429. /**
  15430. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15431. */
  15432. emitFromSpawnPointOnly: boolean;
  15433. /**
  15434. * Gets or sets the radius of the emission cone
  15435. */
  15436. radius: number;
  15437. /**
  15438. * Gets or sets the angle of the emission cone
  15439. */
  15440. angle: number;
  15441. private _buildHeight;
  15442. /**
  15443. * Creates a new instance ConeParticleEmitter
  15444. * @param radius the radius of the emission cone (1 by default)
  15445. * @param angle the cone base angle (PI by default)
  15446. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15447. */
  15448. constructor(radius?: number, angle?: number,
  15449. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15450. directionRandomizer?: number);
  15451. /**
  15452. * Called by the particle System when the direction is computed for the created particle.
  15453. * @param worldMatrix is the world matrix of the particle system
  15454. * @param directionToUpdate is the direction vector to update with the result
  15455. * @param particle is the particle we are computed the direction for
  15456. */
  15457. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15458. /**
  15459. * Called by the particle System when the position is computed for the created particle.
  15460. * @param worldMatrix is the world matrix of the particle system
  15461. * @param positionToUpdate is the position vector to update with the result
  15462. * @param particle is the particle we are computed the position for
  15463. */
  15464. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15465. /**
  15466. * Clones the current emitter and returns a copy of it
  15467. * @returns the new emitter
  15468. */
  15469. clone(): ConeParticleEmitter;
  15470. /**
  15471. * Called by the GPUParticleSystem to setup the update shader
  15472. * @param effect defines the update shader
  15473. */
  15474. applyToShader(effect: Effect): void;
  15475. /**
  15476. * Returns a string to use to update the GPU particles update shader
  15477. * @returns a string containng the defines string
  15478. */
  15479. getEffectDefines(): string;
  15480. /**
  15481. * Returns the string "ConeParticleEmitter"
  15482. * @returns a string containing the class name
  15483. */
  15484. getClassName(): string;
  15485. /**
  15486. * Serializes the particle system to a JSON object.
  15487. * @returns the JSON object
  15488. */
  15489. serialize(): any;
  15490. /**
  15491. * Parse properties from a JSON object
  15492. * @param serializationObject defines the JSON object
  15493. */
  15494. parse(serializationObject: any): void;
  15495. }
  15496. }
  15497. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15498. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15499. import { Effect } from "babylonjs/Materials/effect";
  15500. import { Particle } from "babylonjs/Particles/particle";
  15501. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15502. /**
  15503. * Particle emitter emitting particles from the inside of a cylinder.
  15504. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15505. */
  15506. export class CylinderParticleEmitter implements IParticleEmitterType {
  15507. /**
  15508. * The radius of the emission cylinder.
  15509. */
  15510. radius: number;
  15511. /**
  15512. * The height of the emission cylinder.
  15513. */
  15514. height: number;
  15515. /**
  15516. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15517. */
  15518. radiusRange: number;
  15519. /**
  15520. * How much to randomize the particle direction [0-1].
  15521. */
  15522. directionRandomizer: number;
  15523. /**
  15524. * Creates a new instance CylinderParticleEmitter
  15525. * @param radius the radius of the emission cylinder (1 by default)
  15526. * @param height the height of the emission cylinder (1 by default)
  15527. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15528. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15529. */
  15530. constructor(
  15531. /**
  15532. * The radius of the emission cylinder.
  15533. */
  15534. radius?: number,
  15535. /**
  15536. * The height of the emission cylinder.
  15537. */
  15538. height?: number,
  15539. /**
  15540. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15541. */
  15542. radiusRange?: number,
  15543. /**
  15544. * How much to randomize the particle direction [0-1].
  15545. */
  15546. directionRandomizer?: number);
  15547. /**
  15548. * Called by the particle System when the direction is computed for the created particle.
  15549. * @param worldMatrix is the world matrix of the particle system
  15550. * @param directionToUpdate is the direction vector to update with the result
  15551. * @param particle is the particle we are computed the direction for
  15552. */
  15553. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15554. /**
  15555. * Called by the particle System when the position is computed for the created particle.
  15556. * @param worldMatrix is the world matrix of the particle system
  15557. * @param positionToUpdate is the position vector to update with the result
  15558. * @param particle is the particle we are computed the position for
  15559. */
  15560. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15561. /**
  15562. * Clones the current emitter and returns a copy of it
  15563. * @returns the new emitter
  15564. */
  15565. clone(): CylinderParticleEmitter;
  15566. /**
  15567. * Called by the GPUParticleSystem to setup the update shader
  15568. * @param effect defines the update shader
  15569. */
  15570. applyToShader(effect: Effect): void;
  15571. /**
  15572. * Returns a string to use to update the GPU particles update shader
  15573. * @returns a string containng the defines string
  15574. */
  15575. getEffectDefines(): string;
  15576. /**
  15577. * Returns the string "CylinderParticleEmitter"
  15578. * @returns a string containing the class name
  15579. */
  15580. getClassName(): string;
  15581. /**
  15582. * Serializes the particle system to a JSON object.
  15583. * @returns the JSON object
  15584. */
  15585. serialize(): any;
  15586. /**
  15587. * Parse properties from a JSON object
  15588. * @param serializationObject defines the JSON object
  15589. */
  15590. parse(serializationObject: any): void;
  15591. }
  15592. /**
  15593. * Particle emitter emitting particles from the inside of a cylinder.
  15594. * It emits the particles randomly between two vectors.
  15595. */
  15596. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15597. /**
  15598. * The min limit of the emission direction.
  15599. */
  15600. direction1: Vector3;
  15601. /**
  15602. * The max limit of the emission direction.
  15603. */
  15604. direction2: Vector3;
  15605. /**
  15606. * Creates a new instance CylinderDirectedParticleEmitter
  15607. * @param radius the radius of the emission cylinder (1 by default)
  15608. * @param height the height of the emission cylinder (1 by default)
  15609. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15610. * @param direction1 the min limit of the emission direction (up vector by default)
  15611. * @param direction2 the max limit of the emission direction (up vector by default)
  15612. */
  15613. constructor(radius?: number, height?: number, radiusRange?: number,
  15614. /**
  15615. * The min limit of the emission direction.
  15616. */
  15617. direction1?: Vector3,
  15618. /**
  15619. * The max limit of the emission direction.
  15620. */
  15621. direction2?: Vector3);
  15622. /**
  15623. * Called by the particle System when the direction is computed for the created particle.
  15624. * @param worldMatrix is the world matrix of the particle system
  15625. * @param directionToUpdate is the direction vector to update with the result
  15626. * @param particle is the particle we are computed the direction for
  15627. */
  15628. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15629. /**
  15630. * Clones the current emitter and returns a copy of it
  15631. * @returns the new emitter
  15632. */
  15633. clone(): CylinderDirectedParticleEmitter;
  15634. /**
  15635. * Called by the GPUParticleSystem to setup the update shader
  15636. * @param effect defines the update shader
  15637. */
  15638. applyToShader(effect: Effect): void;
  15639. /**
  15640. * Returns a string to use to update the GPU particles update shader
  15641. * @returns a string containng the defines string
  15642. */
  15643. getEffectDefines(): string;
  15644. /**
  15645. * Returns the string "CylinderDirectedParticleEmitter"
  15646. * @returns a string containing the class name
  15647. */
  15648. getClassName(): string;
  15649. /**
  15650. * Serializes the particle system to a JSON object.
  15651. * @returns the JSON object
  15652. */
  15653. serialize(): any;
  15654. /**
  15655. * Parse properties from a JSON object
  15656. * @param serializationObject defines the JSON object
  15657. */
  15658. parse(serializationObject: any): void;
  15659. }
  15660. }
  15661. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15662. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15663. import { Effect } from "babylonjs/Materials/effect";
  15664. import { Particle } from "babylonjs/Particles/particle";
  15665. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15666. /**
  15667. * Particle emitter emitting particles from the inside of a hemisphere.
  15668. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15669. */
  15670. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15671. /**
  15672. * The radius of the emission hemisphere.
  15673. */
  15674. radius: number;
  15675. /**
  15676. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15677. */
  15678. radiusRange: number;
  15679. /**
  15680. * How much to randomize the particle direction [0-1].
  15681. */
  15682. directionRandomizer: number;
  15683. /**
  15684. * Creates a new instance HemisphericParticleEmitter
  15685. * @param radius the radius of the emission hemisphere (1 by default)
  15686. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15687. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15688. */
  15689. constructor(
  15690. /**
  15691. * The radius of the emission hemisphere.
  15692. */
  15693. radius?: number,
  15694. /**
  15695. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15696. */
  15697. radiusRange?: number,
  15698. /**
  15699. * How much to randomize the particle direction [0-1].
  15700. */
  15701. directionRandomizer?: number);
  15702. /**
  15703. * Called by the particle System when the direction is computed for the created particle.
  15704. * @param worldMatrix is the world matrix of the particle system
  15705. * @param directionToUpdate is the direction vector to update with the result
  15706. * @param particle is the particle we are computed the direction for
  15707. */
  15708. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15709. /**
  15710. * Called by the particle System when the position is computed for the created particle.
  15711. * @param worldMatrix is the world matrix of the particle system
  15712. * @param positionToUpdate is the position vector to update with the result
  15713. * @param particle is the particle we are computed the position for
  15714. */
  15715. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15716. /**
  15717. * Clones the current emitter and returns a copy of it
  15718. * @returns the new emitter
  15719. */
  15720. clone(): HemisphericParticleEmitter;
  15721. /**
  15722. * Called by the GPUParticleSystem to setup the update shader
  15723. * @param effect defines the update shader
  15724. */
  15725. applyToShader(effect: Effect): void;
  15726. /**
  15727. * Returns a string to use to update the GPU particles update shader
  15728. * @returns a string containng the defines string
  15729. */
  15730. getEffectDefines(): string;
  15731. /**
  15732. * Returns the string "HemisphericParticleEmitter"
  15733. * @returns a string containing the class name
  15734. */
  15735. getClassName(): string;
  15736. /**
  15737. * Serializes the particle system to a JSON object.
  15738. * @returns the JSON object
  15739. */
  15740. serialize(): any;
  15741. /**
  15742. * Parse properties from a JSON object
  15743. * @param serializationObject defines the JSON object
  15744. */
  15745. parse(serializationObject: any): void;
  15746. }
  15747. }
  15748. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  15749. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15750. import { Effect } from "babylonjs/Materials/effect";
  15751. import { Particle } from "babylonjs/Particles/particle";
  15752. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15753. /**
  15754. * Particle emitter emitting particles from a point.
  15755. * It emits the particles randomly between 2 given directions.
  15756. */
  15757. export class PointParticleEmitter implements IParticleEmitterType {
  15758. /**
  15759. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15760. */
  15761. direction1: Vector3;
  15762. /**
  15763. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15764. */
  15765. direction2: Vector3;
  15766. /**
  15767. * Creates a new instance PointParticleEmitter
  15768. */
  15769. constructor();
  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(): PointParticleEmitter;
  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 a string containng the defines string
  15797. */
  15798. getEffectDefines(): string;
  15799. /**
  15800. * Returns the string "PointParticleEmitter"
  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/sphereParticleEmitter" {
  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 sphere.
  15823. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15824. */
  15825. export class SphereParticleEmitter implements IParticleEmitterType {
  15826. /**
  15827. * The radius of the emission sphere.
  15828. */
  15829. radius: number;
  15830. /**
  15831. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15832. */
  15833. radiusRange: number;
  15834. /**
  15835. * How much to randomize the particle direction [0-1].
  15836. */
  15837. directionRandomizer: number;
  15838. /**
  15839. * Creates a new instance SphereParticleEmitter
  15840. * @param radius the radius of the emission sphere (1 by default)
  15841. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15842. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15843. */
  15844. constructor(
  15845. /**
  15846. * The radius of the emission sphere.
  15847. */
  15848. radius?: number,
  15849. /**
  15850. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15851. */
  15852. radiusRange?: number,
  15853. /**
  15854. * How much to randomize the particle direction [0-1].
  15855. */
  15856. directionRandomizer?: number);
  15857. /**
  15858. * Called by the particle System when the direction is computed for the created particle.
  15859. * @param worldMatrix is the world matrix of the particle system
  15860. * @param directionToUpdate is the direction vector to update with the result
  15861. * @param particle is the particle we are computed the direction for
  15862. */
  15863. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15864. /**
  15865. * Called by the particle System when the position is computed for the created particle.
  15866. * @param worldMatrix is the world matrix of the particle system
  15867. * @param positionToUpdate is the position vector to update with the result
  15868. * @param particle is the particle we are computed the position for
  15869. */
  15870. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15871. /**
  15872. * Clones the current emitter and returns a copy of it
  15873. * @returns the new emitter
  15874. */
  15875. clone(): SphereParticleEmitter;
  15876. /**
  15877. * Called by the GPUParticleSystem to setup the update shader
  15878. * @param effect defines the update shader
  15879. */
  15880. applyToShader(effect: Effect): void;
  15881. /**
  15882. * Returns a string to use to update the GPU particles update shader
  15883. * @returns a string containng the defines string
  15884. */
  15885. getEffectDefines(): string;
  15886. /**
  15887. * Returns the string "SphereParticleEmitter"
  15888. * @returns a string containing the class name
  15889. */
  15890. getClassName(): string;
  15891. /**
  15892. * Serializes the particle system to a JSON object.
  15893. * @returns the JSON object
  15894. */
  15895. serialize(): any;
  15896. /**
  15897. * Parse properties from a JSON object
  15898. * @param serializationObject defines the JSON object
  15899. */
  15900. parse(serializationObject: any): void;
  15901. }
  15902. /**
  15903. * Particle emitter emitting particles from the inside of a sphere.
  15904. * It emits the particles randomly between two vectors.
  15905. */
  15906. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15907. /**
  15908. * The min limit of the emission direction.
  15909. */
  15910. direction1: Vector3;
  15911. /**
  15912. * The max limit of the emission direction.
  15913. */
  15914. direction2: Vector3;
  15915. /**
  15916. * Creates a new instance SphereDirectedParticleEmitter
  15917. * @param radius the radius of the emission sphere (1 by default)
  15918. * @param direction1 the min limit of the emission direction (up vector by default)
  15919. * @param direction2 the max limit of the emission direction (up vector by default)
  15920. */
  15921. constructor(radius?: number,
  15922. /**
  15923. * The min limit of the emission direction.
  15924. */
  15925. direction1?: Vector3,
  15926. /**
  15927. * The max limit of the emission direction.
  15928. */
  15929. direction2?: Vector3);
  15930. /**
  15931. * Called by the particle System when the direction is computed for the created particle.
  15932. * @param worldMatrix is the world matrix of the particle system
  15933. * @param directionToUpdate is the direction vector to update with the result
  15934. * @param particle is the particle we are computed the direction for
  15935. */
  15936. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15937. /**
  15938. * Clones the current emitter and returns a copy of it
  15939. * @returns the new emitter
  15940. */
  15941. clone(): SphereDirectedParticleEmitter;
  15942. /**
  15943. * Called by the GPUParticleSystem to setup the update shader
  15944. * @param effect defines the update shader
  15945. */
  15946. applyToShader(effect: Effect): void;
  15947. /**
  15948. * Returns a string to use to update the GPU particles update shader
  15949. * @returns a string containng the defines string
  15950. */
  15951. getEffectDefines(): string;
  15952. /**
  15953. * Returns the string "SphereDirectedParticleEmitter"
  15954. * @returns a string containing the class name
  15955. */
  15956. getClassName(): string;
  15957. /**
  15958. * Serializes the particle system to a JSON object.
  15959. * @returns the JSON object
  15960. */
  15961. serialize(): any;
  15962. /**
  15963. * Parse properties from a JSON object
  15964. * @param serializationObject defines the JSON object
  15965. */
  15966. parse(serializationObject: any): void;
  15967. }
  15968. }
  15969. declare module "babylonjs/Particles/EmitterTypes/index" {
  15970. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  15971. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  15972. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  15973. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  15974. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15975. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  15976. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  15977. }
  15978. declare module "babylonjs/Particles/IParticleSystem" {
  15979. import { Nullable } from "babylonjs/types";
  15980. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  15981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15982. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15983. import { Texture } from "babylonjs/Materials/Textures/texture";
  15984. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  15985. import { Scene } from "babylonjs/scene";
  15986. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15987. import { Animation } from "babylonjs/Animations/animation";
  15988. /**
  15989. * Interface representing a particle system in Babylon.js.
  15990. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15991. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15992. */
  15993. export interface IParticleSystem {
  15994. /**
  15995. * List of animations used by the particle system.
  15996. */
  15997. animations: Animation[];
  15998. /**
  15999. * The id of the Particle system.
  16000. */
  16001. id: string;
  16002. /**
  16003. * The name of the Particle system.
  16004. */
  16005. name: string;
  16006. /**
  16007. * The emitter represents the Mesh or position we are attaching the particle system to.
  16008. */
  16009. emitter: Nullable<AbstractMesh | Vector3>;
  16010. /**
  16011. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16012. */
  16013. isBillboardBased: boolean;
  16014. /**
  16015. * The rendering group used by the Particle system to chose when to render.
  16016. */
  16017. renderingGroupId: number;
  16018. /**
  16019. * The layer mask we are rendering the particles through.
  16020. */
  16021. layerMask: number;
  16022. /**
  16023. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16024. */
  16025. updateSpeed: number;
  16026. /**
  16027. * The amount of time the particle system is running (depends of the overall update speed).
  16028. */
  16029. targetStopDuration: number;
  16030. /**
  16031. * The texture used to render each particle. (this can be a spritesheet)
  16032. */
  16033. particleTexture: Nullable<Texture>;
  16034. /**
  16035. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16036. */
  16037. blendMode: number;
  16038. /**
  16039. * Minimum life time of emitting particles.
  16040. */
  16041. minLifeTime: number;
  16042. /**
  16043. * Maximum life time of emitting particles.
  16044. */
  16045. maxLifeTime: number;
  16046. /**
  16047. * Minimum Size of emitting particles.
  16048. */
  16049. minSize: number;
  16050. /**
  16051. * Maximum Size of emitting particles.
  16052. */
  16053. maxSize: number;
  16054. /**
  16055. * Minimum scale of emitting particles on X axis.
  16056. */
  16057. minScaleX: number;
  16058. /**
  16059. * Maximum scale of emitting particles on X axis.
  16060. */
  16061. maxScaleX: number;
  16062. /**
  16063. * Minimum scale of emitting particles on Y axis.
  16064. */
  16065. minScaleY: number;
  16066. /**
  16067. * Maximum scale of emitting particles on Y axis.
  16068. */
  16069. maxScaleY: number;
  16070. /**
  16071. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16072. */
  16073. color1: Color4;
  16074. /**
  16075. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16076. */
  16077. color2: Color4;
  16078. /**
  16079. * Color the particle will have at the end of its lifetime.
  16080. */
  16081. colorDead: Color4;
  16082. /**
  16083. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16084. */
  16085. emitRate: number;
  16086. /**
  16087. * You can use gravity if you want to give an orientation to your particles.
  16088. */
  16089. gravity: Vector3;
  16090. /**
  16091. * Minimum power of emitting particles.
  16092. */
  16093. minEmitPower: number;
  16094. /**
  16095. * Maximum power of emitting particles.
  16096. */
  16097. maxEmitPower: number;
  16098. /**
  16099. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16100. */
  16101. minAngularSpeed: number;
  16102. /**
  16103. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16104. */
  16105. maxAngularSpeed: number;
  16106. /**
  16107. * Gets or sets the minimal initial rotation in radians.
  16108. */
  16109. minInitialRotation: number;
  16110. /**
  16111. * Gets or sets the maximal initial rotation in radians.
  16112. */
  16113. maxInitialRotation: number;
  16114. /**
  16115. * The particle emitter type defines the emitter used by the particle system.
  16116. * It can be for example box, sphere, or cone...
  16117. */
  16118. particleEmitterType: Nullable<IParticleEmitterType>;
  16119. /**
  16120. * Defines the delay in milliseconds before starting the system (0 by default)
  16121. */
  16122. startDelay: number;
  16123. /**
  16124. * 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
  16125. */
  16126. preWarmCycles: number;
  16127. /**
  16128. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16129. */
  16130. preWarmStepOffset: number;
  16131. /**
  16132. * 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)
  16133. */
  16134. spriteCellChangeSpeed: number;
  16135. /**
  16136. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16137. */
  16138. startSpriteCellID: number;
  16139. /**
  16140. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16141. */
  16142. endSpriteCellID: number;
  16143. /**
  16144. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16145. */
  16146. spriteCellWidth: number;
  16147. /**
  16148. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16149. */
  16150. spriteCellHeight: number;
  16151. /**
  16152. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16153. */
  16154. spriteRandomStartCell: boolean;
  16155. /**
  16156. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16157. */
  16158. isAnimationSheetEnabled: boolean;
  16159. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16160. translationPivot: Vector2;
  16161. /**
  16162. * Gets or sets a texture used to add random noise to particle positions
  16163. */
  16164. noiseTexture: Nullable<BaseTexture>;
  16165. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16166. noiseStrength: Vector3;
  16167. /**
  16168. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16169. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16170. */
  16171. billboardMode: number;
  16172. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16173. limitVelocityDamping: number;
  16174. /**
  16175. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16176. */
  16177. beginAnimationOnStart: boolean;
  16178. /**
  16179. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16180. */
  16181. beginAnimationFrom: number;
  16182. /**
  16183. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16184. */
  16185. beginAnimationTo: number;
  16186. /**
  16187. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16188. */
  16189. beginAnimationLoop: boolean;
  16190. /**
  16191. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16192. */
  16193. disposeOnStop: boolean;
  16194. /**
  16195. * Gets the maximum number of particles active at the same time.
  16196. * @returns The max number of active particles.
  16197. */
  16198. getCapacity(): number;
  16199. /**
  16200. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16201. * @returns True if it has been started, otherwise false.
  16202. */
  16203. isStarted(): boolean;
  16204. /**
  16205. * Animates the particle system for this frame.
  16206. */
  16207. animate(): void;
  16208. /**
  16209. * Renders the particle system in its current state.
  16210. * @returns the current number of particles
  16211. */
  16212. render(): number;
  16213. /**
  16214. * Dispose the particle system and frees its associated resources.
  16215. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16216. */
  16217. dispose(disposeTexture?: boolean): void;
  16218. /**
  16219. * Clones the particle system.
  16220. * @param name The name of the cloned object
  16221. * @param newEmitter The new emitter to use
  16222. * @returns the cloned particle system
  16223. */
  16224. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16225. /**
  16226. * Serializes the particle system to a JSON object.
  16227. * @returns the JSON object
  16228. */
  16229. serialize(): any;
  16230. /**
  16231. * Rebuild the particle system
  16232. */
  16233. rebuild(): void;
  16234. /**
  16235. * Starts the particle system and begins to emit
  16236. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16237. */
  16238. start(delay?: number): void;
  16239. /**
  16240. * Stops the particle system.
  16241. */
  16242. stop(): void;
  16243. /**
  16244. * Remove all active particles
  16245. */
  16246. reset(): void;
  16247. /**
  16248. * Is this system ready to be used/rendered
  16249. * @return true if the system is ready
  16250. */
  16251. isReady(): boolean;
  16252. /**
  16253. * Adds a new color gradient
  16254. * @param gradient defines the gradient to use (between 0 and 1)
  16255. * @param color1 defines the color to affect to the specified gradient
  16256. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16257. * @returns the current particle system
  16258. */
  16259. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16260. /**
  16261. * Remove a specific color gradient
  16262. * @param gradient defines the gradient to remove
  16263. * @returns the current particle system
  16264. */
  16265. removeColorGradient(gradient: number): IParticleSystem;
  16266. /**
  16267. * Adds a new size gradient
  16268. * @param gradient defines the gradient to use (between 0 and 1)
  16269. * @param factor defines the size factor to affect to the specified gradient
  16270. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16271. * @returns the current particle system
  16272. */
  16273. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16274. /**
  16275. * Remove a specific size gradient
  16276. * @param gradient defines the gradient to remove
  16277. * @returns the current particle system
  16278. */
  16279. removeSizeGradient(gradient: number): IParticleSystem;
  16280. /**
  16281. * Gets the current list of color gradients.
  16282. * You must use addColorGradient and removeColorGradient to udpate this list
  16283. * @returns the list of color gradients
  16284. */
  16285. getColorGradients(): Nullable<Array<ColorGradient>>;
  16286. /**
  16287. * Gets the current list of size gradients.
  16288. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16289. * @returns the list of size gradients
  16290. */
  16291. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16292. /**
  16293. * Gets the current list of angular speed gradients.
  16294. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16295. * @returns the list of angular speed gradients
  16296. */
  16297. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16298. /**
  16299. * Adds a new angular speed gradient
  16300. * @param gradient defines the gradient to use (between 0 and 1)
  16301. * @param factor defines the angular speed to affect to the specified gradient
  16302. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16303. * @returns the current particle system
  16304. */
  16305. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16306. /**
  16307. * Remove a specific angular speed gradient
  16308. * @param gradient defines the gradient to remove
  16309. * @returns the current particle system
  16310. */
  16311. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16312. /**
  16313. * Gets the current list of velocity gradients.
  16314. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16315. * @returns the list of velocity gradients
  16316. */
  16317. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16318. /**
  16319. * Adds a new velocity gradient
  16320. * @param gradient defines the gradient to use (between 0 and 1)
  16321. * @param factor defines the velocity to affect to the specified gradient
  16322. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16323. * @returns the current particle system
  16324. */
  16325. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16326. /**
  16327. * Remove a specific velocity gradient
  16328. * @param gradient defines the gradient to remove
  16329. * @returns the current particle system
  16330. */
  16331. removeVelocityGradient(gradient: number): IParticleSystem;
  16332. /**
  16333. * Gets the current list of limit velocity gradients.
  16334. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16335. * @returns the list of limit velocity gradients
  16336. */
  16337. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16338. /**
  16339. * Adds a new limit velocity gradient
  16340. * @param gradient defines the gradient to use (between 0 and 1)
  16341. * @param factor defines the limit velocity to affect to the specified gradient
  16342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16343. * @returns the current particle system
  16344. */
  16345. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16346. /**
  16347. * Remove a specific limit velocity gradient
  16348. * @param gradient defines the gradient to remove
  16349. * @returns the current particle system
  16350. */
  16351. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16352. /**
  16353. * Adds a new drag gradient
  16354. * @param gradient defines the gradient to use (between 0 and 1)
  16355. * @param factor defines the drag to affect to the specified gradient
  16356. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16357. * @returns the current particle system
  16358. */
  16359. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16360. /**
  16361. * Remove a specific drag gradient
  16362. * @param gradient defines the gradient to remove
  16363. * @returns the current particle system
  16364. */
  16365. removeDragGradient(gradient: number): IParticleSystem;
  16366. /**
  16367. * Gets the current list of drag gradients.
  16368. * You must use addDragGradient and removeDragGradient to udpate this list
  16369. * @returns the list of drag gradients
  16370. */
  16371. getDragGradients(): Nullable<Array<FactorGradient>>;
  16372. /**
  16373. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16374. * @param gradient defines the gradient to use (between 0 and 1)
  16375. * @param factor defines the emit rate to affect to the specified gradient
  16376. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16377. * @returns the current particle system
  16378. */
  16379. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16380. /**
  16381. * Remove a specific emit rate gradient
  16382. * @param gradient defines the gradient to remove
  16383. * @returns the current particle system
  16384. */
  16385. removeEmitRateGradient(gradient: number): IParticleSystem;
  16386. /**
  16387. * Gets the current list of emit rate gradients.
  16388. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16389. * @returns the list of emit rate gradients
  16390. */
  16391. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16392. /**
  16393. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16394. * @param gradient defines the gradient to use (between 0 and 1)
  16395. * @param factor defines the start size to affect to the specified gradient
  16396. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16397. * @returns the current particle system
  16398. */
  16399. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16400. /**
  16401. * Remove a specific start size gradient
  16402. * @param gradient defines the gradient to remove
  16403. * @returns the current particle system
  16404. */
  16405. removeStartSizeGradient(gradient: number): IParticleSystem;
  16406. /**
  16407. * Gets the current list of start size gradients.
  16408. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16409. * @returns the list of start size gradients
  16410. */
  16411. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16412. /**
  16413. * Adds a new life time gradient
  16414. * @param gradient defines the gradient to use (between 0 and 1)
  16415. * @param factor defines the life time factor to affect to the specified gradient
  16416. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16417. * @returns the current particle system
  16418. */
  16419. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16420. /**
  16421. * Remove a specific life time gradient
  16422. * @param gradient defines the gradient to remove
  16423. * @returns the current particle system
  16424. */
  16425. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16426. /**
  16427. * Gets the current list of life time gradients.
  16428. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16429. * @returns the list of life time gradients
  16430. */
  16431. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16432. /**
  16433. * Gets the current list of color gradients.
  16434. * You must use addColorGradient and removeColorGradient to udpate this list
  16435. * @returns the list of color gradients
  16436. */
  16437. getColorGradients(): Nullable<Array<ColorGradient>>;
  16438. /**
  16439. * Adds a new ramp gradient used to remap particle colors
  16440. * @param gradient defines the gradient to use (between 0 and 1)
  16441. * @param color defines the color to affect to the specified gradient
  16442. * @returns the current particle system
  16443. */
  16444. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16445. /**
  16446. * Gets the current list of ramp gradients.
  16447. * You must use addRampGradient and removeRampGradient to udpate this list
  16448. * @returns the list of ramp gradients
  16449. */
  16450. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16451. /** Gets or sets a boolean indicating that ramp gradients must be used
  16452. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16453. */
  16454. useRampGradients: boolean;
  16455. /**
  16456. * Adds a new color remap gradient
  16457. * @param gradient defines the gradient to use (between 0 and 1)
  16458. * @param min defines the color remap minimal range
  16459. * @param max defines the color remap maximal range
  16460. * @returns the current particle system
  16461. */
  16462. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16463. /**
  16464. * Gets the current list of color remap gradients.
  16465. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16466. * @returns the list of color remap gradients
  16467. */
  16468. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16469. /**
  16470. * Adds a new alpha remap gradient
  16471. * @param gradient defines the gradient to use (between 0 and 1)
  16472. * @param min defines the alpha remap minimal range
  16473. * @param max defines the alpha remap maximal range
  16474. * @returns the current particle system
  16475. */
  16476. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16477. /**
  16478. * Gets the current list of alpha remap gradients.
  16479. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16480. * @returns the list of alpha remap gradients
  16481. */
  16482. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16483. /**
  16484. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16485. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16486. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16487. * @returns the emitter
  16488. */
  16489. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16490. /**
  16491. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16492. * @param radius The radius of the hemisphere to emit from
  16493. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16494. * @returns the emitter
  16495. */
  16496. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16497. /**
  16498. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16499. * @param radius The radius of the sphere to emit from
  16500. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16501. * @returns the emitter
  16502. */
  16503. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16504. /**
  16505. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16506. * @param radius The radius of the sphere to emit from
  16507. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16508. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16509. * @returns the emitter
  16510. */
  16511. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16512. /**
  16513. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16514. * @param radius The radius of the emission cylinder
  16515. * @param height The height of the emission cylinder
  16516. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16517. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16518. * @returns the emitter
  16519. */
  16520. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16521. /**
  16522. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16523. * @param radius The radius of the cylinder to emit from
  16524. * @param height The height of the emission cylinder
  16525. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16526. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16527. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16528. * @returns the emitter
  16529. */
  16530. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16531. /**
  16532. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16533. * @param radius The radius of the cone to emit from
  16534. * @param angle The base angle of the cone
  16535. * @returns the emitter
  16536. */
  16537. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16538. /**
  16539. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16540. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16541. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16542. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16543. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16544. * @returns the emitter
  16545. */
  16546. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16547. /**
  16548. * Get hosting scene
  16549. * @returns the scene
  16550. */
  16551. getScene(): Scene;
  16552. }
  16553. }
  16554. declare module "babylonjs/Meshes/instancedMesh" {
  16555. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16556. import { Vector3 } from "babylonjs/Maths/math";
  16557. import { Camera } from "babylonjs/Cameras/camera";
  16558. import { Node } from "babylonjs/node";
  16559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16560. import { Mesh } from "babylonjs/Meshes/mesh";
  16561. import { Material } from "babylonjs/Materials/material";
  16562. import { Skeleton } from "babylonjs/Bones/skeleton";
  16563. /**
  16564. * Creates an instance based on a source mesh.
  16565. */
  16566. export class InstancedMesh extends AbstractMesh {
  16567. private _sourceMesh;
  16568. private _currentLOD;
  16569. /** @hidden */
  16570. _indexInSourceMeshInstanceArray: number;
  16571. constructor(name: string, source: Mesh);
  16572. /**
  16573. * Returns the string "InstancedMesh".
  16574. */
  16575. getClassName(): string;
  16576. /**
  16577. * If the source mesh receives shadows
  16578. */
  16579. readonly receiveShadows: boolean;
  16580. /**
  16581. * The material of the source mesh
  16582. */
  16583. readonly material: Nullable<Material>;
  16584. /**
  16585. * Visibility of the source mesh
  16586. */
  16587. readonly visibility: number;
  16588. /**
  16589. * Skeleton of the source mesh
  16590. */
  16591. readonly skeleton: Nullable<Skeleton>;
  16592. /**
  16593. * Rendering ground id of the source mesh
  16594. */
  16595. renderingGroupId: number;
  16596. /**
  16597. * Returns the total number of vertices (integer).
  16598. */
  16599. getTotalVertices(): number;
  16600. /**
  16601. * Returns a positive integer : the total number of indices in this mesh geometry.
  16602. * @returns the numner of indices or zero if the mesh has no geometry.
  16603. */
  16604. getTotalIndices(): number;
  16605. /**
  16606. * The source mesh of the instance
  16607. */
  16608. readonly sourceMesh: Mesh;
  16609. /**
  16610. * Is this node ready to be used/rendered
  16611. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16612. * @return {boolean} is it ready
  16613. */
  16614. isReady(completeCheck?: boolean): boolean;
  16615. /**
  16616. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16617. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16618. * @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.
  16619. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16620. */
  16621. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16622. /**
  16623. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16624. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16625. * The `data` are either a numeric array either a Float32Array.
  16626. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16627. * 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).
  16628. * Note that a new underlying VertexBuffer object is created each call.
  16629. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16630. *
  16631. * Possible `kind` values :
  16632. * - VertexBuffer.PositionKind
  16633. * - VertexBuffer.UVKind
  16634. * - VertexBuffer.UV2Kind
  16635. * - VertexBuffer.UV3Kind
  16636. * - VertexBuffer.UV4Kind
  16637. * - VertexBuffer.UV5Kind
  16638. * - VertexBuffer.UV6Kind
  16639. * - VertexBuffer.ColorKind
  16640. * - VertexBuffer.MatricesIndicesKind
  16641. * - VertexBuffer.MatricesIndicesExtraKind
  16642. * - VertexBuffer.MatricesWeightsKind
  16643. * - VertexBuffer.MatricesWeightsExtraKind
  16644. *
  16645. * Returns the Mesh.
  16646. */
  16647. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16648. /**
  16649. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16650. * If the mesh has no geometry, it is simply returned as it is.
  16651. * The `data` are either a numeric array either a Float32Array.
  16652. * No new underlying VertexBuffer object is created.
  16653. * 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.
  16654. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16655. *
  16656. * Possible `kind` values :
  16657. * - VertexBuffer.PositionKind
  16658. * - VertexBuffer.UVKind
  16659. * - VertexBuffer.UV2Kind
  16660. * - VertexBuffer.UV3Kind
  16661. * - VertexBuffer.UV4Kind
  16662. * - VertexBuffer.UV5Kind
  16663. * - VertexBuffer.UV6Kind
  16664. * - VertexBuffer.ColorKind
  16665. * - VertexBuffer.MatricesIndicesKind
  16666. * - VertexBuffer.MatricesIndicesExtraKind
  16667. * - VertexBuffer.MatricesWeightsKind
  16668. * - VertexBuffer.MatricesWeightsExtraKind
  16669. *
  16670. * Returns the Mesh.
  16671. */
  16672. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16673. /**
  16674. * Sets the mesh indices.
  16675. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16676. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16677. * This method creates a new index buffer each call.
  16678. * Returns the Mesh.
  16679. */
  16680. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16681. /**
  16682. * Boolean : True if the mesh owns the requested kind of data.
  16683. */
  16684. isVerticesDataPresent(kind: string): boolean;
  16685. /**
  16686. * Returns an array of indices (IndicesArray).
  16687. */
  16688. getIndices(): Nullable<IndicesArray>;
  16689. readonly _positions: Nullable<Vector3[]>;
  16690. /**
  16691. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16692. * This means the mesh underlying bounding box and sphere are recomputed.
  16693. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16694. * @returns the current mesh
  16695. */
  16696. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16697. /** @hidden */
  16698. _preActivate(): InstancedMesh;
  16699. /** @hidden */
  16700. _activate(renderId: number): InstancedMesh;
  16701. /**
  16702. * Returns the current associated LOD AbstractMesh.
  16703. */
  16704. getLOD(camera: Camera): AbstractMesh;
  16705. /** @hidden */
  16706. _syncSubMeshes(): InstancedMesh;
  16707. /** @hidden */
  16708. _generatePointsArray(): boolean;
  16709. /**
  16710. * Creates a new InstancedMesh from the current mesh.
  16711. * - name (string) : the cloned mesh name
  16712. * - newParent (optional Node) : the optional Node to parent the clone to.
  16713. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16714. *
  16715. * Returns the clone.
  16716. */
  16717. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16718. /**
  16719. * Disposes the InstancedMesh.
  16720. * Returns nothing.
  16721. */
  16722. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16723. }
  16724. }
  16725. declare module "babylonjs/Materials/shaderMaterial" {
  16726. import { Scene } from "babylonjs/scene";
  16727. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16728. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16729. import { Mesh } from "babylonjs/Meshes/mesh";
  16730. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16731. import { Texture } from "babylonjs/Materials/Textures/texture";
  16732. import { Material } from "babylonjs/Materials/material";
  16733. /**
  16734. * Defines the options associated with the creation of a shader material.
  16735. */
  16736. export interface IShaderMaterialOptions {
  16737. /**
  16738. * Does the material work in alpha blend mode
  16739. */
  16740. needAlphaBlending: boolean;
  16741. /**
  16742. * Does the material work in alpha test mode
  16743. */
  16744. needAlphaTesting: boolean;
  16745. /**
  16746. * The list of attribute names used in the shader
  16747. */
  16748. attributes: string[];
  16749. /**
  16750. * The list of unifrom names used in the shader
  16751. */
  16752. uniforms: string[];
  16753. /**
  16754. * The list of UBO names used in the shader
  16755. */
  16756. uniformBuffers: string[];
  16757. /**
  16758. * The list of sampler names used in the shader
  16759. */
  16760. samplers: string[];
  16761. /**
  16762. * The list of defines used in the shader
  16763. */
  16764. defines: string[];
  16765. }
  16766. /**
  16767. * 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.
  16768. *
  16769. * This returned material effects how the mesh will look based on the code in the shaders.
  16770. *
  16771. * @see http://doc.babylonjs.com/how_to/shader_material
  16772. */
  16773. export class ShaderMaterial extends Material {
  16774. private _shaderPath;
  16775. private _options;
  16776. private _textures;
  16777. private _textureArrays;
  16778. private _floats;
  16779. private _ints;
  16780. private _floatsArrays;
  16781. private _colors3;
  16782. private _colors3Arrays;
  16783. private _colors4;
  16784. private _vectors2;
  16785. private _vectors3;
  16786. private _vectors4;
  16787. private _matrices;
  16788. private _matrices3x3;
  16789. private _matrices2x2;
  16790. private _vectors2Arrays;
  16791. private _vectors3Arrays;
  16792. private _cachedWorldViewMatrix;
  16793. private _renderId;
  16794. /**
  16795. * Instantiate a new shader material.
  16796. * 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.
  16797. * This returned material effects how the mesh will look based on the code in the shaders.
  16798. * @see http://doc.babylonjs.com/how_to/shader_material
  16799. * @param name Define the name of the material in the scene
  16800. * @param scene Define the scene the material belongs to
  16801. * @param shaderPath Defines the route to the shader code in one of three ways:
  16802. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16803. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16804. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16805. * @param options Define the options used to create the shader
  16806. */
  16807. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16808. /**
  16809. * Gets the current class name of the material e.g. "ShaderMaterial"
  16810. * Mainly use in serialization.
  16811. * @returns the class name
  16812. */
  16813. getClassName(): string;
  16814. /**
  16815. * Specifies if the material will require alpha blending
  16816. * @returns a boolean specifying if alpha blending is needed
  16817. */
  16818. needAlphaBlending(): boolean;
  16819. /**
  16820. * Specifies if this material should be rendered in alpha test mode
  16821. * @returns a boolean specifying if an alpha test is needed.
  16822. */
  16823. needAlphaTesting(): boolean;
  16824. private _checkUniform;
  16825. /**
  16826. * Set a texture in the shader.
  16827. * @param name Define the name of the uniform samplers as defined in the shader
  16828. * @param texture Define the texture to bind to this sampler
  16829. * @return the material itself allowing "fluent" like uniform updates
  16830. */
  16831. setTexture(name: string, texture: Texture): ShaderMaterial;
  16832. /**
  16833. * Set a texture array in the shader.
  16834. * @param name Define the name of the uniform sampler array as defined in the shader
  16835. * @param textures Define the list of textures to bind to this sampler
  16836. * @return the material itself allowing "fluent" like uniform updates
  16837. */
  16838. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16839. /**
  16840. * Set a float in the shader.
  16841. * @param name Define the name of the uniform as defined in the shader
  16842. * @param value Define the value to give to the uniform
  16843. * @return the material itself allowing "fluent" like uniform updates
  16844. */
  16845. setFloat(name: string, value: number): ShaderMaterial;
  16846. /**
  16847. * Set a int in the shader.
  16848. * @param name Define the name of the uniform as defined in the shader
  16849. * @param value Define the value to give to the uniform
  16850. * @return the material itself allowing "fluent" like uniform updates
  16851. */
  16852. setInt(name: string, value: number): ShaderMaterial;
  16853. /**
  16854. * Set an array of floats in the shader.
  16855. * @param name Define the name of the uniform as defined in the shader
  16856. * @param value Define the value to give to the uniform
  16857. * @return the material itself allowing "fluent" like uniform updates
  16858. */
  16859. setFloats(name: string, value: number[]): ShaderMaterial;
  16860. /**
  16861. * Set a vec3 in the shader from a Color3.
  16862. * @param name Define the name of the uniform as defined in the shader
  16863. * @param value Define the value to give to the uniform
  16864. * @return the material itself allowing "fluent" like uniform updates
  16865. */
  16866. setColor3(name: string, value: Color3): ShaderMaterial;
  16867. /**
  16868. * Set a vec3 array in the shader from a Color3 array.
  16869. * @param name Define the name of the uniform as defined in the shader
  16870. * @param value Define the value to give to the uniform
  16871. * @return the material itself allowing "fluent" like uniform updates
  16872. */
  16873. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16874. /**
  16875. * Set a vec4 in the shader from a Color4.
  16876. * @param name Define the name of the uniform as defined in the shader
  16877. * @param value Define the value to give to the uniform
  16878. * @return the material itself allowing "fluent" like uniform updates
  16879. */
  16880. setColor4(name: string, value: Color4): ShaderMaterial;
  16881. /**
  16882. * Set a vec2 in the shader from a Vector2.
  16883. * @param name Define the name of the uniform as defined in the shader
  16884. * @param value Define the value to give to the uniform
  16885. * @return the material itself allowing "fluent" like uniform updates
  16886. */
  16887. setVector2(name: string, value: Vector2): ShaderMaterial;
  16888. /**
  16889. * Set a vec3 in the shader from a Vector3.
  16890. * @param name Define the name of the uniform as defined in the shader
  16891. * @param value Define the value to give to the uniform
  16892. * @return the material itself allowing "fluent" like uniform updates
  16893. */
  16894. setVector3(name: string, value: Vector3): ShaderMaterial;
  16895. /**
  16896. * Set a vec4 in the shader from a Vector4.
  16897. * @param name Define the name of the uniform as defined in the shader
  16898. * @param value Define the value to give to the uniform
  16899. * @return the material itself allowing "fluent" like uniform updates
  16900. */
  16901. setVector4(name: string, value: Vector4): ShaderMaterial;
  16902. /**
  16903. * Set a mat4 in the shader from a Matrix.
  16904. * @param name Define the name of the uniform as defined in the shader
  16905. * @param value Define the value to give to the uniform
  16906. * @return the material itself allowing "fluent" like uniform updates
  16907. */
  16908. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16909. /**
  16910. * Set a mat3 in the shader from a Float32Array.
  16911. * @param name Define the name of the uniform as defined in the shader
  16912. * @param value Define the value to give to the uniform
  16913. * @return the material itself allowing "fluent" like uniform updates
  16914. */
  16915. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16916. /**
  16917. * Set a mat2 in the shader from a Float32Array.
  16918. * @param name Define the name of the uniform as defined in the shader
  16919. * @param value Define the value to give to the uniform
  16920. * @return the material itself allowing "fluent" like uniform updates
  16921. */
  16922. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16923. /**
  16924. * Set a vec2 array in the shader from a number array.
  16925. * @param name Define the name of the uniform as defined in the shader
  16926. * @param value Define the value to give to the uniform
  16927. * @return the material itself allowing "fluent" like uniform updates
  16928. */
  16929. setArray2(name: string, value: number[]): ShaderMaterial;
  16930. /**
  16931. * Set a vec3 array in the shader from a number array.
  16932. * @param name Define the name of the uniform as defined in the shader
  16933. * @param value Define the value to give to the uniform
  16934. * @return the material itself allowing "fluent" like uniform updates
  16935. */
  16936. setArray3(name: string, value: number[]): ShaderMaterial;
  16937. private _checkCache;
  16938. /**
  16939. * Checks if the material is ready to render the requested mesh
  16940. * @param mesh Define the mesh to render
  16941. * @param useInstances Define whether or not the material is used with instances
  16942. * @returns true if ready, otherwise false
  16943. */
  16944. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16945. /**
  16946. * Binds the world matrix to the material
  16947. * @param world defines the world transformation matrix
  16948. */
  16949. bindOnlyWorldMatrix(world: Matrix): void;
  16950. /**
  16951. * Binds the material to the mesh
  16952. * @param world defines the world transformation matrix
  16953. * @param mesh defines the mesh to bind the material to
  16954. */
  16955. bind(world: Matrix, mesh?: Mesh): void;
  16956. /**
  16957. * Gets the active textures from the material
  16958. * @returns an array of textures
  16959. */
  16960. getActiveTextures(): BaseTexture[];
  16961. /**
  16962. * Specifies if the material uses a texture
  16963. * @param texture defines the texture to check against the material
  16964. * @returns a boolean specifying if the material uses the texture
  16965. */
  16966. hasTexture(texture: BaseTexture): boolean;
  16967. /**
  16968. * Makes a duplicate of the material, and gives it a new name
  16969. * @param name defines the new name for the duplicated material
  16970. * @returns the cloned material
  16971. */
  16972. clone(name: string): ShaderMaterial;
  16973. /**
  16974. * Disposes the material
  16975. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16976. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16977. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16978. */
  16979. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16980. /**
  16981. * Serializes this material in a JSON representation
  16982. * @returns the serialized material object
  16983. */
  16984. serialize(): any;
  16985. /**
  16986. * Creates a shader material from parsed shader material data
  16987. * @param source defines the JSON represnetation of the material
  16988. * @param scene defines the hosting scene
  16989. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16990. * @returns a new material
  16991. */
  16992. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16993. }
  16994. }
  16995. declare module "babylonjs/Shaders/color.fragment" {
  16996. /** @hidden */
  16997. export var colorPixelShader: {
  16998. name: string;
  16999. shader: string;
  17000. };
  17001. }
  17002. declare module "babylonjs/Shaders/color.vertex" {
  17003. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17004. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17005. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17006. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17007. /** @hidden */
  17008. export var colorVertexShader: {
  17009. name: string;
  17010. shader: string;
  17011. };
  17012. }
  17013. declare module "babylonjs/Meshes/linesMesh" {
  17014. import { Nullable } from "babylonjs/types";
  17015. import { Scene } from "babylonjs/scene";
  17016. import { Color3 } from "babylonjs/Maths/math";
  17017. import { Node } from "babylonjs/node";
  17018. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17019. import { Mesh } from "babylonjs/Meshes/mesh";
  17020. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17021. import { Effect } from "babylonjs/Materials/effect";
  17022. import { Material } from "babylonjs/Materials/material";
  17023. import "babylonjs/Shaders/color.fragment";
  17024. import "babylonjs/Shaders/color.vertex";
  17025. /**
  17026. * Line mesh
  17027. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17028. */
  17029. export class LinesMesh extends Mesh {
  17030. /**
  17031. * If vertex color should be applied to the mesh
  17032. */
  17033. useVertexColor?: boolean | undefined;
  17034. /**
  17035. * If vertex alpha should be applied to the mesh
  17036. */
  17037. useVertexAlpha?: boolean | undefined;
  17038. /**
  17039. * Color of the line (Default: White)
  17040. */
  17041. color: Color3;
  17042. /**
  17043. * Alpha of the line (Default: 1)
  17044. */
  17045. alpha: number;
  17046. /**
  17047. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17048. * This margin is expressed in world space coordinates, so its value may vary.
  17049. * Default value is 0.1
  17050. */
  17051. intersectionThreshold: number;
  17052. private _colorShader;
  17053. /**
  17054. * Creates a new LinesMesh
  17055. * @param name defines the name
  17056. * @param scene defines the hosting scene
  17057. * @param parent defines the parent mesh if any
  17058. * @param source defines the optional source LinesMesh used to clone data from
  17059. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17060. * When false, achieved by calling a clone(), also passing False.
  17061. * This will make creation of children, recursive.
  17062. * @param useVertexColor defines if this LinesMesh supports vertex color
  17063. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17064. */
  17065. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17066. /**
  17067. * If vertex color should be applied to the mesh
  17068. */
  17069. useVertexColor?: boolean | undefined,
  17070. /**
  17071. * If vertex alpha should be applied to the mesh
  17072. */
  17073. useVertexAlpha?: boolean | undefined);
  17074. /**
  17075. * Returns the string "LineMesh"
  17076. */
  17077. getClassName(): string;
  17078. /**
  17079. * @hidden
  17080. */
  17081. /**
  17082. * @hidden
  17083. */
  17084. material: Material;
  17085. /**
  17086. * @hidden
  17087. */
  17088. readonly checkCollisions: boolean;
  17089. /** @hidden */
  17090. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17091. /** @hidden */
  17092. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17093. /**
  17094. * Disposes of the line mesh
  17095. * @param doNotRecurse If children should be disposed
  17096. */
  17097. dispose(doNotRecurse?: boolean): void;
  17098. /**
  17099. * Returns a new LineMesh object cloned from the current one.
  17100. */
  17101. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17102. /**
  17103. * Creates a new InstancedLinesMesh object from the mesh model.
  17104. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17105. * @param name defines the name of the new instance
  17106. * @returns a new InstancedLinesMesh
  17107. */
  17108. createInstance(name: string): InstancedLinesMesh;
  17109. }
  17110. /**
  17111. * Creates an instance based on a source LinesMesh
  17112. */
  17113. export class InstancedLinesMesh extends InstancedMesh {
  17114. /**
  17115. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17116. * This margin is expressed in world space coordinates, so its value may vary.
  17117. * Initilized with the intersectionThreshold value of the source LinesMesh
  17118. */
  17119. intersectionThreshold: number;
  17120. constructor(name: string, source: LinesMesh);
  17121. /**
  17122. * Returns the string "InstancedLinesMesh".
  17123. */
  17124. getClassName(): string;
  17125. }
  17126. }
  17127. declare module "babylonjs/Shaders/line.fragment" {
  17128. /** @hidden */
  17129. export var linePixelShader: {
  17130. name: string;
  17131. shader: string;
  17132. };
  17133. }
  17134. declare module "babylonjs/Shaders/line.vertex" {
  17135. /** @hidden */
  17136. export var lineVertexShader: {
  17137. name: string;
  17138. shader: string;
  17139. };
  17140. }
  17141. declare module "babylonjs/Rendering/edgesRenderer" {
  17142. import { Nullable } from "babylonjs/types";
  17143. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17145. import { Vector3 } from "babylonjs/Maths/math";
  17146. import { IDisposable } from "babylonjs/scene";
  17147. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17148. import "babylonjs/Shaders/line.fragment";
  17149. import "babylonjs/Shaders/line.vertex";
  17150. module "babylonjs/Meshes/abstractMesh" {
  17151. interface AbstractMesh {
  17152. /**
  17153. * Disables the mesh edge rendering mode
  17154. * @returns the currentAbstractMesh
  17155. */
  17156. disableEdgesRendering(): AbstractMesh;
  17157. /**
  17158. * Enables the edge rendering mode on the mesh.
  17159. * This mode makes the mesh edges visible
  17160. * @param epsilon defines the maximal distance between two angles to detect a face
  17161. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17162. * @returns the currentAbstractMesh
  17163. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17164. */
  17165. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17166. /**
  17167. * Gets the edgesRenderer associated with the mesh
  17168. */
  17169. edgesRenderer: Nullable<EdgesRenderer>;
  17170. }
  17171. }
  17172. module "babylonjs/Meshes/linesMesh" {
  17173. interface LinesMesh {
  17174. /**
  17175. * Enables the edge rendering mode on the mesh.
  17176. * This mode makes the mesh edges visible
  17177. * @param epsilon defines the maximal distance between two angles to detect a face
  17178. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17179. * @returns the currentAbstractMesh
  17180. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17181. */
  17182. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17183. }
  17184. }
  17185. module "babylonjs/Meshes/linesMesh" {
  17186. interface InstancedLinesMesh {
  17187. /**
  17188. * Enables the edge rendering mode on the mesh.
  17189. * This mode makes the mesh edges visible
  17190. * @param epsilon defines the maximal distance between two angles to detect a face
  17191. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17192. * @returns the current InstancedLinesMesh
  17193. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17194. */
  17195. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17196. }
  17197. }
  17198. /**
  17199. * Defines the minimum contract an Edges renderer should follow.
  17200. */
  17201. export interface IEdgesRenderer extends IDisposable {
  17202. /**
  17203. * Gets or sets a boolean indicating if the edgesRenderer is active
  17204. */
  17205. isEnabled: boolean;
  17206. /**
  17207. * Renders the edges of the attached mesh,
  17208. */
  17209. render(): void;
  17210. /**
  17211. * Checks wether or not the edges renderer is ready to render.
  17212. * @return true if ready, otherwise false.
  17213. */
  17214. isReady(): boolean;
  17215. }
  17216. /**
  17217. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17218. */
  17219. export class EdgesRenderer implements IEdgesRenderer {
  17220. /**
  17221. * Define the size of the edges with an orthographic camera
  17222. */
  17223. edgesWidthScalerForOrthographic: number;
  17224. /**
  17225. * Define the size of the edges with a perspective camera
  17226. */
  17227. edgesWidthScalerForPerspective: number;
  17228. protected _source: AbstractMesh;
  17229. protected _linesPositions: number[];
  17230. protected _linesNormals: number[];
  17231. protected _linesIndices: number[];
  17232. protected _epsilon: number;
  17233. protected _indicesCount: number;
  17234. protected _lineShader: ShaderMaterial;
  17235. protected _ib: WebGLBuffer;
  17236. protected _buffers: {
  17237. [key: string]: Nullable<VertexBuffer>;
  17238. };
  17239. protected _checkVerticesInsteadOfIndices: boolean;
  17240. private _meshRebuildObserver;
  17241. private _meshDisposeObserver;
  17242. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17243. isEnabled: boolean;
  17244. /**
  17245. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17246. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17247. * @param source Mesh used to create edges
  17248. * @param epsilon sum of angles in adjacency to check for edge
  17249. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17250. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17251. */
  17252. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17253. protected _prepareRessources(): void;
  17254. /** @hidden */
  17255. _rebuild(): void;
  17256. /**
  17257. * Releases the required resources for the edges renderer
  17258. */
  17259. dispose(): void;
  17260. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17261. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17262. /**
  17263. * Checks if the pair of p0 and p1 is en edge
  17264. * @param faceIndex
  17265. * @param edge
  17266. * @param faceNormals
  17267. * @param p0
  17268. * @param p1
  17269. * @private
  17270. */
  17271. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17272. /**
  17273. * push line into the position, normal and index buffer
  17274. * @protected
  17275. */
  17276. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17277. /**
  17278. * Generates lines edges from adjacencjes
  17279. * @private
  17280. */
  17281. _generateEdgesLines(): void;
  17282. /**
  17283. * Checks wether or not the edges renderer is ready to render.
  17284. * @return true if ready, otherwise false.
  17285. */
  17286. isReady(): boolean;
  17287. /**
  17288. * Renders the edges of the attached mesh,
  17289. */
  17290. render(): void;
  17291. }
  17292. /**
  17293. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17294. */
  17295. export class LineEdgesRenderer extends EdgesRenderer {
  17296. /**
  17297. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17298. * @param source LineMesh used to generate edges
  17299. * @param epsilon not important (specified angle for edge detection)
  17300. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17301. */
  17302. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17303. /**
  17304. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17305. */
  17306. _generateEdgesLines(): void;
  17307. }
  17308. }
  17309. declare module "babylonjs/Rendering/renderingGroup" {
  17310. import { SmartArray } from "babylonjs/Misc/smartArray";
  17311. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17313. import { Nullable } from "babylonjs/types";
  17314. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17315. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17316. import { Material } from "babylonjs/Materials/material";
  17317. import { Scene } from "babylonjs/scene";
  17318. /**
  17319. * This represents the object necessary to create a rendering group.
  17320. * This is exclusively used and created by the rendering manager.
  17321. * To modify the behavior, you use the available helpers in your scene or meshes.
  17322. * @hidden
  17323. */
  17324. export class RenderingGroup {
  17325. index: number;
  17326. private _scene;
  17327. private _opaqueSubMeshes;
  17328. private _transparentSubMeshes;
  17329. private _alphaTestSubMeshes;
  17330. private _depthOnlySubMeshes;
  17331. private _particleSystems;
  17332. private _spriteManagers;
  17333. private _opaqueSortCompareFn;
  17334. private _alphaTestSortCompareFn;
  17335. private _transparentSortCompareFn;
  17336. private _renderOpaque;
  17337. private _renderAlphaTest;
  17338. private _renderTransparent;
  17339. private _edgesRenderers;
  17340. onBeforeTransparentRendering: () => void;
  17341. /**
  17342. * Set the opaque sort comparison function.
  17343. * If null the sub meshes will be render in the order they were created
  17344. */
  17345. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17346. /**
  17347. * Set the alpha test sort comparison function.
  17348. * If null the sub meshes will be render in the order they were created
  17349. */
  17350. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17351. /**
  17352. * Set the transparent sort comparison function.
  17353. * If null the sub meshes will be render in the order they were created
  17354. */
  17355. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17356. /**
  17357. * Creates a new rendering group.
  17358. * @param index The rendering group index
  17359. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17360. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17361. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17362. */
  17363. 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>);
  17364. /**
  17365. * Render all the sub meshes contained in the group.
  17366. * @param customRenderFunction Used to override the default render behaviour of the group.
  17367. * @returns true if rendered some submeshes.
  17368. */
  17369. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17370. /**
  17371. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17372. * @param subMeshes The submeshes to render
  17373. */
  17374. private renderOpaqueSorted;
  17375. /**
  17376. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17377. * @param subMeshes The submeshes to render
  17378. */
  17379. private renderAlphaTestSorted;
  17380. /**
  17381. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17382. * @param subMeshes The submeshes to render
  17383. */
  17384. private renderTransparentSorted;
  17385. /**
  17386. * Renders the submeshes in a specified order.
  17387. * @param subMeshes The submeshes to sort before render
  17388. * @param sortCompareFn The comparison function use to sort
  17389. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17390. * @param transparent Specifies to activate blending if true
  17391. */
  17392. private static renderSorted;
  17393. /**
  17394. * Renders the submeshes in the order they were dispatched (no sort applied).
  17395. * @param subMeshes The submeshes to render
  17396. */
  17397. private static renderUnsorted;
  17398. /**
  17399. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17400. * are rendered back to front if in the same alpha index.
  17401. *
  17402. * @param a The first submesh
  17403. * @param b The second submesh
  17404. * @returns The result of the comparison
  17405. */
  17406. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17407. /**
  17408. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17409. * are rendered back to front.
  17410. *
  17411. * @param a The first submesh
  17412. * @param b The second submesh
  17413. * @returns The result of the comparison
  17414. */
  17415. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17416. /**
  17417. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17418. * are rendered front to back (prevent overdraw).
  17419. *
  17420. * @param a The first submesh
  17421. * @param b The second submesh
  17422. * @returns The result of the comparison
  17423. */
  17424. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17425. /**
  17426. * Resets the different lists of submeshes to prepare a new frame.
  17427. */
  17428. prepare(): void;
  17429. dispose(): void;
  17430. /**
  17431. * Inserts the submesh in its correct queue depending on its material.
  17432. * @param subMesh The submesh to dispatch
  17433. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17434. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17435. */
  17436. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17437. dispatchSprites(spriteManager: ISpriteManager): void;
  17438. dispatchParticles(particleSystem: IParticleSystem): void;
  17439. private _renderParticles;
  17440. private _renderSprites;
  17441. }
  17442. }
  17443. declare module "babylonjs/Rendering/renderingManager" {
  17444. import { Nullable } from "babylonjs/types";
  17445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17446. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17447. import { SmartArray } from "babylonjs/Misc/smartArray";
  17448. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17449. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17450. import { Material } from "babylonjs/Materials/material";
  17451. import { Scene } from "babylonjs/scene";
  17452. import { Camera } from "babylonjs/Cameras/camera";
  17453. /**
  17454. * Interface describing the different options available in the rendering manager
  17455. * regarding Auto Clear between groups.
  17456. */
  17457. export interface IRenderingManagerAutoClearSetup {
  17458. /**
  17459. * Defines whether or not autoclear is enable.
  17460. */
  17461. autoClear: boolean;
  17462. /**
  17463. * Defines whether or not to autoclear the depth buffer.
  17464. */
  17465. depth: boolean;
  17466. /**
  17467. * Defines whether or not to autoclear the stencil buffer.
  17468. */
  17469. stencil: boolean;
  17470. }
  17471. /**
  17472. * This class is used by the onRenderingGroupObservable
  17473. */
  17474. export class RenderingGroupInfo {
  17475. /**
  17476. * The Scene that being rendered
  17477. */
  17478. scene: Scene;
  17479. /**
  17480. * The camera currently used for the rendering pass
  17481. */
  17482. camera: Nullable<Camera>;
  17483. /**
  17484. * The ID of the renderingGroup being processed
  17485. */
  17486. renderingGroupId: number;
  17487. }
  17488. /**
  17489. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17490. * It is enable to manage the different groups as well as the different necessary sort functions.
  17491. * This should not be used directly aside of the few static configurations
  17492. */
  17493. export class RenderingManager {
  17494. /**
  17495. * The max id used for rendering groups (not included)
  17496. */
  17497. static MAX_RENDERINGGROUPS: number;
  17498. /**
  17499. * The min id used for rendering groups (included)
  17500. */
  17501. static MIN_RENDERINGGROUPS: number;
  17502. /**
  17503. * Used to globally prevent autoclearing scenes.
  17504. */
  17505. static AUTOCLEAR: boolean;
  17506. /**
  17507. * @hidden
  17508. */
  17509. _useSceneAutoClearSetup: boolean;
  17510. private _scene;
  17511. private _renderingGroups;
  17512. private _depthStencilBufferAlreadyCleaned;
  17513. private _autoClearDepthStencil;
  17514. private _customOpaqueSortCompareFn;
  17515. private _customAlphaTestSortCompareFn;
  17516. private _customTransparentSortCompareFn;
  17517. private _renderingGroupInfo;
  17518. /**
  17519. * Instantiates a new rendering group for a particular scene
  17520. * @param scene Defines the scene the groups belongs to
  17521. */
  17522. constructor(scene: Scene);
  17523. private _clearDepthStencilBuffer;
  17524. /**
  17525. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17526. * @hidden
  17527. */
  17528. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17529. /**
  17530. * Resets the different information of the group to prepare a new frame
  17531. * @hidden
  17532. */
  17533. reset(): void;
  17534. /**
  17535. * Dispose and release the group and its associated resources.
  17536. * @hidden
  17537. */
  17538. dispose(): void;
  17539. /**
  17540. * Clear the info related to rendering groups preventing retention points during dispose.
  17541. */
  17542. freeRenderingGroups(): void;
  17543. private _prepareRenderingGroup;
  17544. /**
  17545. * Add a sprite manager to the rendering manager in order to render it this frame.
  17546. * @param spriteManager Define the sprite manager to render
  17547. */
  17548. dispatchSprites(spriteManager: ISpriteManager): void;
  17549. /**
  17550. * Add a particle system to the rendering manager in order to render it this frame.
  17551. * @param particleSystem Define the particle system to render
  17552. */
  17553. dispatchParticles(particleSystem: IParticleSystem): void;
  17554. /**
  17555. * Add a submesh to the manager in order to render it this frame
  17556. * @param subMesh The submesh to dispatch
  17557. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17558. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17559. */
  17560. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17561. /**
  17562. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17563. * This allowed control for front to back rendering or reversly depending of the special needs.
  17564. *
  17565. * @param renderingGroupId The rendering group id corresponding to its index
  17566. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17567. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17568. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17569. */
  17570. 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;
  17571. /**
  17572. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17573. *
  17574. * @param renderingGroupId The rendering group id corresponding to its index
  17575. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17576. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17577. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17578. */
  17579. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17580. /**
  17581. * Gets the current auto clear configuration for one rendering group of the rendering
  17582. * manager.
  17583. * @param index the rendering group index to get the information for
  17584. * @returns The auto clear setup for the requested rendering group
  17585. */
  17586. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17587. }
  17588. }
  17589. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17590. import { Observable } from "babylonjs/Misc/observable";
  17591. import { SmartArray } from "babylonjs/Misc/smartArray";
  17592. import { Nullable } from "babylonjs/types";
  17593. import { Camera } from "babylonjs/Cameras/camera";
  17594. import { Scene } from "babylonjs/scene";
  17595. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17596. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17598. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17599. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17600. import { Texture } from "babylonjs/Materials/Textures/texture";
  17601. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17602. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17603. import { Engine } from "babylonjs/Engines/engine";
  17604. /**
  17605. * This Helps creating a texture that will be created from a camera in your scene.
  17606. * It is basically a dynamic texture that could be used to create special effects for instance.
  17607. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17608. */
  17609. export class RenderTargetTexture extends Texture {
  17610. isCube: boolean;
  17611. /**
  17612. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17613. */
  17614. static readonly REFRESHRATE_RENDER_ONCE: number;
  17615. /**
  17616. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17617. */
  17618. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17619. /**
  17620. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17621. * the central point of your effect and can save a lot of performances.
  17622. */
  17623. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17624. /**
  17625. * Use this predicate to dynamically define the list of mesh you want to render.
  17626. * If set, the renderList property will be overwritten.
  17627. */
  17628. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17629. private _renderList;
  17630. /**
  17631. * Use this list to define the list of mesh you want to render.
  17632. */
  17633. renderList: Nullable<Array<AbstractMesh>>;
  17634. private _hookArray;
  17635. /**
  17636. * Define if particles should be rendered in your texture.
  17637. */
  17638. renderParticles: boolean;
  17639. /**
  17640. * Define if sprites should be rendered in your texture.
  17641. */
  17642. renderSprites: boolean;
  17643. /**
  17644. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17645. */
  17646. coordinatesMode: number;
  17647. /**
  17648. * Define the camera used to render the texture.
  17649. */
  17650. activeCamera: Nullable<Camera>;
  17651. /**
  17652. * Override the render function of the texture with your own one.
  17653. */
  17654. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17655. /**
  17656. * Define if camera post processes should be use while rendering the texture.
  17657. */
  17658. useCameraPostProcesses: boolean;
  17659. /**
  17660. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17661. */
  17662. ignoreCameraViewport: boolean;
  17663. private _postProcessManager;
  17664. private _postProcesses;
  17665. private _resizeObserver;
  17666. /**
  17667. * An event triggered when the texture is unbind.
  17668. */
  17669. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17670. /**
  17671. * An event triggered when the texture is unbind.
  17672. */
  17673. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17674. private _onAfterUnbindObserver;
  17675. /**
  17676. * Set a after unbind callback in the texture.
  17677. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17678. */
  17679. onAfterUnbind: () => void;
  17680. /**
  17681. * An event triggered before rendering the texture
  17682. */
  17683. onBeforeRenderObservable: Observable<number>;
  17684. private _onBeforeRenderObserver;
  17685. /**
  17686. * Set a before render callback in the texture.
  17687. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17688. */
  17689. onBeforeRender: (faceIndex: number) => void;
  17690. /**
  17691. * An event triggered after rendering the texture
  17692. */
  17693. onAfterRenderObservable: Observable<number>;
  17694. private _onAfterRenderObserver;
  17695. /**
  17696. * Set a after render callback in the texture.
  17697. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17698. */
  17699. onAfterRender: (faceIndex: number) => void;
  17700. /**
  17701. * An event triggered after the texture clear
  17702. */
  17703. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17704. private _onClearObserver;
  17705. /**
  17706. * Set a clear callback in the texture.
  17707. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17708. */
  17709. onClear: (Engine: Engine) => void;
  17710. /**
  17711. * Define the clear color of the Render Target if it should be different from the scene.
  17712. */
  17713. clearColor: Color4;
  17714. protected _size: number | {
  17715. width: number;
  17716. height: number;
  17717. };
  17718. protected _initialSizeParameter: number | {
  17719. width: number;
  17720. height: number;
  17721. } | {
  17722. ratio: number;
  17723. };
  17724. protected _sizeRatio: Nullable<number>;
  17725. /** @hidden */
  17726. _generateMipMaps: boolean;
  17727. protected _renderingManager: RenderingManager;
  17728. /** @hidden */
  17729. _waitingRenderList: string[];
  17730. protected _doNotChangeAspectRatio: boolean;
  17731. protected _currentRefreshId: number;
  17732. protected _refreshRate: number;
  17733. protected _textureMatrix: Matrix;
  17734. protected _samples: number;
  17735. protected _renderTargetOptions: RenderTargetCreationOptions;
  17736. /**
  17737. * Gets render target creation options that were used.
  17738. */
  17739. readonly renderTargetOptions: RenderTargetCreationOptions;
  17740. protected _engine: Engine;
  17741. protected _onRatioRescale(): void;
  17742. /**
  17743. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17744. * It must define where the camera used to render the texture is set
  17745. */
  17746. boundingBoxPosition: Vector3;
  17747. private _boundingBoxSize;
  17748. /**
  17749. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17750. * When defined, the cubemap will switch to local mode
  17751. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17752. * @example https://www.babylonjs-playground.com/#RNASML
  17753. */
  17754. boundingBoxSize: Vector3;
  17755. /**
  17756. * In case the RTT has been created with a depth texture, get the associated
  17757. * depth texture.
  17758. * Otherwise, return null.
  17759. */
  17760. depthStencilTexture: Nullable<InternalTexture>;
  17761. /**
  17762. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17763. * or used a shadow, depth texture...
  17764. * @param name The friendly name of the texture
  17765. * @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)
  17766. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17767. * @param generateMipMaps True if mip maps need to be generated after render.
  17768. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17769. * @param type The type of the buffer in the RTT (int, half float, float...)
  17770. * @param isCube True if a cube texture needs to be created
  17771. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17772. * @param generateDepthBuffer True to generate a depth buffer
  17773. * @param generateStencilBuffer True to generate a stencil buffer
  17774. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17775. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17776. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17777. */
  17778. constructor(name: string, size: number | {
  17779. width: number;
  17780. height: number;
  17781. } | {
  17782. ratio: number;
  17783. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17784. /**
  17785. * Creates a depth stencil texture.
  17786. * This is only available in WebGL 2 or with the depth texture extension available.
  17787. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17788. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17789. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17790. */
  17791. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17792. private _processSizeParameter;
  17793. /**
  17794. * Define the number of samples to use in case of MSAA.
  17795. * It defaults to one meaning no MSAA has been enabled.
  17796. */
  17797. samples: number;
  17798. /**
  17799. * Resets the refresh counter of the texture and start bak from scratch.
  17800. * Could be useful to regenerate the texture if it is setup to render only once.
  17801. */
  17802. resetRefreshCounter(): void;
  17803. /**
  17804. * Define the refresh rate of the texture or the rendering frequency.
  17805. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17806. */
  17807. refreshRate: number;
  17808. /**
  17809. * Adds a post process to the render target rendering passes.
  17810. * @param postProcess define the post process to add
  17811. */
  17812. addPostProcess(postProcess: PostProcess): void;
  17813. /**
  17814. * Clear all the post processes attached to the render target
  17815. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17816. */
  17817. clearPostProcesses(dispose?: boolean): void;
  17818. /**
  17819. * Remove one of the post process from the list of attached post processes to the texture
  17820. * @param postProcess define the post process to remove from the list
  17821. */
  17822. removePostProcess(postProcess: PostProcess): void;
  17823. /** @hidden */
  17824. _shouldRender(): boolean;
  17825. /**
  17826. * Gets the actual render size of the texture.
  17827. * @returns the width of the render size
  17828. */
  17829. getRenderSize(): number;
  17830. /**
  17831. * Gets the actual render width of the texture.
  17832. * @returns the width of the render size
  17833. */
  17834. getRenderWidth(): number;
  17835. /**
  17836. * Gets the actual render height of the texture.
  17837. * @returns the height of the render size
  17838. */
  17839. getRenderHeight(): number;
  17840. /**
  17841. * Get if the texture can be rescaled or not.
  17842. */
  17843. readonly canRescale: boolean;
  17844. /**
  17845. * Resize the texture using a ratio.
  17846. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17847. */
  17848. scale(ratio: number): void;
  17849. /**
  17850. * Get the texture reflection matrix used to rotate/transform the reflection.
  17851. * @returns the reflection matrix
  17852. */
  17853. getReflectionTextureMatrix(): Matrix;
  17854. /**
  17855. * Resize the texture to a new desired size.
  17856. * Be carrefull as it will recreate all the data in the new texture.
  17857. * @param size Define the new size. It can be:
  17858. * - a number for squared texture,
  17859. * - an object containing { width: number, height: number }
  17860. * - or an object containing a ratio { ratio: number }
  17861. */
  17862. resize(size: number | {
  17863. width: number;
  17864. height: number;
  17865. } | {
  17866. ratio: number;
  17867. }): void;
  17868. /**
  17869. * Renders all the objects from the render list into the texture.
  17870. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17871. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17872. */
  17873. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17874. private _bestReflectionRenderTargetDimension;
  17875. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17876. private renderToTarget;
  17877. /**
  17878. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17879. * This allowed control for front to back rendering or reversly depending of the special needs.
  17880. *
  17881. * @param renderingGroupId The rendering group id corresponding to its index
  17882. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17883. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17884. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17885. */
  17886. 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;
  17887. /**
  17888. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17889. *
  17890. * @param renderingGroupId The rendering group id corresponding to its index
  17891. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17892. */
  17893. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17894. /**
  17895. * Clones the texture.
  17896. * @returns the cloned texture
  17897. */
  17898. clone(): RenderTargetTexture;
  17899. /**
  17900. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17901. * @returns The JSON representation of the texture
  17902. */
  17903. serialize(): any;
  17904. /**
  17905. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17906. */
  17907. disposeFramebufferObjects(): void;
  17908. /**
  17909. * Dispose the texture and release its associated resources.
  17910. */
  17911. dispose(): void;
  17912. /** @hidden */
  17913. _rebuild(): void;
  17914. /**
  17915. * Clear the info related to rendering groups preventing retention point in material dispose.
  17916. */
  17917. freeRenderingGroups(): void;
  17918. }
  17919. }
  17920. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  17921. import { Scene } from "babylonjs/scene";
  17922. import { Plane } from "babylonjs/Maths/math";
  17923. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17924. /**
  17925. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17926. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17927. * You can then easily use it as a reflectionTexture on a flat surface.
  17928. * In case the surface is not a plane, please consider relying on reflection probes.
  17929. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17930. */
  17931. export class MirrorTexture extends RenderTargetTexture {
  17932. private scene;
  17933. /**
  17934. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17935. * 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.
  17936. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17937. */
  17938. mirrorPlane: Plane;
  17939. /**
  17940. * Define the blur ratio used to blur the reflection if needed.
  17941. */
  17942. blurRatio: number;
  17943. /**
  17944. * Define the adaptive blur kernel used to blur the reflection if needed.
  17945. * This will autocompute the closest best match for the `blurKernel`
  17946. */
  17947. adaptiveBlurKernel: number;
  17948. /**
  17949. * Define the blur kernel used to blur the reflection if needed.
  17950. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17951. */
  17952. blurKernel: number;
  17953. /**
  17954. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17955. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17956. */
  17957. blurKernelX: number;
  17958. /**
  17959. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17960. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17961. */
  17962. blurKernelY: number;
  17963. private _autoComputeBlurKernel;
  17964. protected _onRatioRescale(): void;
  17965. private _updateGammaSpace;
  17966. private _imageProcessingConfigChangeObserver;
  17967. private _transformMatrix;
  17968. private _mirrorMatrix;
  17969. private _savedViewMatrix;
  17970. private _blurX;
  17971. private _blurY;
  17972. private _adaptiveBlurKernel;
  17973. private _blurKernelX;
  17974. private _blurKernelY;
  17975. private _blurRatio;
  17976. /**
  17977. * Instantiates a Mirror Texture.
  17978. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17979. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17980. * You can then easily use it as a reflectionTexture on a flat surface.
  17981. * In case the surface is not a plane, please consider relying on reflection probes.
  17982. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17983. * @param name
  17984. * @param size
  17985. * @param scene
  17986. * @param generateMipMaps
  17987. * @param type
  17988. * @param samplingMode
  17989. * @param generateDepthBuffer
  17990. */
  17991. constructor(name: string, size: number | {
  17992. width: number;
  17993. height: number;
  17994. } | {
  17995. ratio: number;
  17996. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17997. private _preparePostProcesses;
  17998. /**
  17999. * Clone the mirror texture.
  18000. * @returns the cloned texture
  18001. */
  18002. clone(): MirrorTexture;
  18003. /**
  18004. * Serialize the texture to a JSON representation you could use in Parse later on
  18005. * @returns the serialized JSON representation
  18006. */
  18007. serialize(): any;
  18008. /**
  18009. * Dispose the texture and release its associated resources.
  18010. */
  18011. dispose(): void;
  18012. }
  18013. }
  18014. declare module "babylonjs/Materials/Textures/texture" {
  18015. import { Observable } from "babylonjs/Misc/observable";
  18016. import { Nullable } from "babylonjs/types";
  18017. import { Scene } from "babylonjs/scene";
  18018. import { Matrix } from "babylonjs/Maths/math";
  18019. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18020. /**
  18021. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18022. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18023. */
  18024. export class Texture extends BaseTexture {
  18025. /** @hidden */
  18026. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18027. /** @hidden */
  18028. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18029. /** @hidden */
  18030. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18031. /** nearest is mag = nearest and min = nearest and mip = linear */
  18032. static readonly NEAREST_SAMPLINGMODE: number;
  18033. /** nearest is mag = nearest and min = nearest and mip = linear */
  18034. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18035. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18036. static readonly BILINEAR_SAMPLINGMODE: number;
  18037. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18038. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18039. /** Trilinear is mag = linear and min = linear and mip = linear */
  18040. static readonly TRILINEAR_SAMPLINGMODE: number;
  18041. /** Trilinear is mag = linear and min = linear and mip = linear */
  18042. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18043. /** mag = nearest and min = nearest and mip = nearest */
  18044. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18045. /** mag = nearest and min = linear and mip = nearest */
  18046. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18047. /** mag = nearest and min = linear and mip = linear */
  18048. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18049. /** mag = nearest and min = linear and mip = none */
  18050. static readonly NEAREST_LINEAR: number;
  18051. /** mag = nearest and min = nearest and mip = none */
  18052. static readonly NEAREST_NEAREST: number;
  18053. /** mag = linear and min = nearest and mip = nearest */
  18054. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18055. /** mag = linear and min = nearest and mip = linear */
  18056. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18057. /** mag = linear and min = linear and mip = none */
  18058. static readonly LINEAR_LINEAR: number;
  18059. /** mag = linear and min = nearest and mip = none */
  18060. static readonly LINEAR_NEAREST: number;
  18061. /** Explicit coordinates mode */
  18062. static readonly EXPLICIT_MODE: number;
  18063. /** Spherical coordinates mode */
  18064. static readonly SPHERICAL_MODE: number;
  18065. /** Planar coordinates mode */
  18066. static readonly PLANAR_MODE: number;
  18067. /** Cubic coordinates mode */
  18068. static readonly CUBIC_MODE: number;
  18069. /** Projection coordinates mode */
  18070. static readonly PROJECTION_MODE: number;
  18071. /** Inverse Cubic coordinates mode */
  18072. static readonly SKYBOX_MODE: number;
  18073. /** Inverse Cubic coordinates mode */
  18074. static readonly INVCUBIC_MODE: number;
  18075. /** Equirectangular coordinates mode */
  18076. static readonly EQUIRECTANGULAR_MODE: number;
  18077. /** Equirectangular Fixed coordinates mode */
  18078. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18079. /** Equirectangular Fixed Mirrored coordinates mode */
  18080. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18081. /** Texture is not repeating outside of 0..1 UVs */
  18082. static readonly CLAMP_ADDRESSMODE: number;
  18083. /** Texture is repeating outside of 0..1 UVs */
  18084. static readonly WRAP_ADDRESSMODE: number;
  18085. /** Texture is repeating and mirrored */
  18086. static readonly MIRROR_ADDRESSMODE: number;
  18087. /**
  18088. * 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
  18089. */
  18090. static UseSerializedUrlIfAny: boolean;
  18091. /**
  18092. * Define the url of the texture.
  18093. */
  18094. url: Nullable<string>;
  18095. /**
  18096. * Define an offset on the texture to offset the u coordinates of the UVs
  18097. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18098. */
  18099. uOffset: number;
  18100. /**
  18101. * Define an offset on the texture to offset the v coordinates of the UVs
  18102. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18103. */
  18104. vOffset: number;
  18105. /**
  18106. * Define an offset on the texture to scale the u coordinates of the UVs
  18107. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18108. */
  18109. uScale: number;
  18110. /**
  18111. * Define an offset on the texture to scale the v coordinates of the UVs
  18112. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18113. */
  18114. vScale: number;
  18115. /**
  18116. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18117. * @see http://doc.babylonjs.com/how_to/more_materials
  18118. */
  18119. uAng: number;
  18120. /**
  18121. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18122. * @see http://doc.babylonjs.com/how_to/more_materials
  18123. */
  18124. vAng: number;
  18125. /**
  18126. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18127. * @see http://doc.babylonjs.com/how_to/more_materials
  18128. */
  18129. wAng: number;
  18130. /**
  18131. * Defines the center of rotation (U)
  18132. */
  18133. uRotationCenter: number;
  18134. /**
  18135. * Defines the center of rotation (V)
  18136. */
  18137. vRotationCenter: number;
  18138. /**
  18139. * Defines the center of rotation (W)
  18140. */
  18141. wRotationCenter: number;
  18142. /**
  18143. * Are mip maps generated for this texture or not.
  18144. */
  18145. readonly noMipmap: boolean;
  18146. private _noMipmap;
  18147. /** @hidden */
  18148. _invertY: boolean;
  18149. private _rowGenerationMatrix;
  18150. private _cachedTextureMatrix;
  18151. private _projectionModeMatrix;
  18152. private _t0;
  18153. private _t1;
  18154. private _t2;
  18155. private _cachedUOffset;
  18156. private _cachedVOffset;
  18157. private _cachedUScale;
  18158. private _cachedVScale;
  18159. private _cachedUAng;
  18160. private _cachedVAng;
  18161. private _cachedWAng;
  18162. private _cachedProjectionMatrixId;
  18163. private _cachedCoordinatesMode;
  18164. /** @hidden */
  18165. protected _initialSamplingMode: number;
  18166. /** @hidden */
  18167. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18168. private _deleteBuffer;
  18169. protected _format: Nullable<number>;
  18170. private _delayedOnLoad;
  18171. private _delayedOnError;
  18172. /**
  18173. * Observable triggered once the texture has been loaded.
  18174. */
  18175. onLoadObservable: Observable<Texture>;
  18176. protected _isBlocking: boolean;
  18177. /**
  18178. * Is the texture preventing material to render while loading.
  18179. * If false, a default texture will be used instead of the loading one during the preparation step.
  18180. */
  18181. isBlocking: boolean;
  18182. /**
  18183. * Get the current sampling mode associated with the texture.
  18184. */
  18185. readonly samplingMode: number;
  18186. /**
  18187. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18188. */
  18189. readonly invertY: boolean;
  18190. /**
  18191. * Instantiates a new texture.
  18192. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18193. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18194. * @param url define the url of the picture to load as a texture
  18195. * @param scene define the scene the texture will belong to
  18196. * @param noMipmap define if the texture will require mip maps or not
  18197. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18198. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18199. * @param onLoad define a callback triggered when the texture has been loaded
  18200. * @param onError define a callback triggered when an error occurred during the loading session
  18201. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18202. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18203. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18204. */
  18205. 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);
  18206. /**
  18207. * Update the url (and optional buffer) of this texture if url was null during construction.
  18208. * @param url the url of the texture
  18209. * @param buffer the buffer of the texture (defaults to null)
  18210. * @param onLoad callback called when the texture is loaded (defaults to null)
  18211. */
  18212. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18213. /**
  18214. * Finish the loading sequence of a texture flagged as delayed load.
  18215. * @hidden
  18216. */
  18217. delayLoad(): void;
  18218. private _prepareRowForTextureGeneration;
  18219. /**
  18220. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18221. * @returns the transform matrix of the texture.
  18222. */
  18223. getTextureMatrix(): Matrix;
  18224. /**
  18225. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18226. * @returns The reflection texture transform
  18227. */
  18228. getReflectionTextureMatrix(): Matrix;
  18229. /**
  18230. * Clones the texture.
  18231. * @returns the cloned texture
  18232. */
  18233. clone(): Texture;
  18234. /**
  18235. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18236. * @returns The JSON representation of the texture
  18237. */
  18238. serialize(): any;
  18239. /**
  18240. * Get the current class name of the texture useful for serialization or dynamic coding.
  18241. * @returns "Texture"
  18242. */
  18243. getClassName(): string;
  18244. /**
  18245. * Dispose the texture and release its associated resources.
  18246. */
  18247. dispose(): void;
  18248. /**
  18249. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18250. * @param parsedTexture Define the JSON representation of the texture
  18251. * @param scene Define the scene the parsed texture should be instantiated in
  18252. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18253. * @returns The parsed texture if successful
  18254. */
  18255. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18256. /**
  18257. * Creates a texture from its base 64 representation.
  18258. * @param data Define the base64 payload without the data: prefix
  18259. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18260. * @param scene Define the scene the texture should belong to
  18261. * @param noMipmap Forces the texture to not create mip map information if true
  18262. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18263. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18264. * @param onLoad define a callback triggered when the texture has been loaded
  18265. * @param onError define a callback triggered when an error occurred during the loading session
  18266. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18267. * @returns the created texture
  18268. */
  18269. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18270. /**
  18271. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18272. * @param data Define the base64 payload without the data: prefix
  18273. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18274. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18275. * @param scene Define the scene the texture should belong to
  18276. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18277. * @param noMipmap Forces the texture to not create mip map information if true
  18278. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18279. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18280. * @param onLoad define a callback triggered when the texture has been loaded
  18281. * @param onError define a callback triggered when an error occurred during the loading session
  18282. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18283. * @returns the created texture
  18284. */
  18285. 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;
  18286. }
  18287. }
  18288. declare module "babylonjs/Materials/Textures/rawTexture" {
  18289. import { Scene } from "babylonjs/scene";
  18290. import { Texture } from "babylonjs/Materials/Textures/texture";
  18291. /**
  18292. * Raw texture can help creating a texture directly from an array of data.
  18293. * This can be super useful if you either get the data from an uncompressed source or
  18294. * if you wish to create your texture pixel by pixel.
  18295. */
  18296. export class RawTexture extends Texture {
  18297. /**
  18298. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18299. */
  18300. format: number;
  18301. private _engine;
  18302. /**
  18303. * Instantiates a new RawTexture.
  18304. * Raw texture can help creating a texture directly from an array of data.
  18305. * This can be super useful if you either get the data from an uncompressed source or
  18306. * if you wish to create your texture pixel by pixel.
  18307. * @param data define the array of data to use to create the texture
  18308. * @param width define the width of the texture
  18309. * @param height define the height of the texture
  18310. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18311. * @param scene define the scene the texture belongs to
  18312. * @param generateMipMaps define whether mip maps should be generated or not
  18313. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18314. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18315. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18316. */
  18317. constructor(data: ArrayBufferView, width: number, height: number,
  18318. /**
  18319. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18320. */
  18321. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18322. /**
  18323. * Updates the texture underlying data.
  18324. * @param data Define the new data of the texture
  18325. */
  18326. update(data: ArrayBufferView): void;
  18327. /**
  18328. * Creates a luminance texture from some data.
  18329. * @param data Define the texture data
  18330. * @param width Define the width of the texture
  18331. * @param height Define the height of the texture
  18332. * @param scene Define the scene the texture belongs to
  18333. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18334. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18335. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18336. * @returns the luminance texture
  18337. */
  18338. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18339. /**
  18340. * Creates a luminance alpha texture from some data.
  18341. * @param data Define the texture data
  18342. * @param width Define the width of the texture
  18343. * @param height Define the height of the texture
  18344. * @param scene Define the scene the texture belongs to
  18345. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18346. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18347. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18348. * @returns the luminance alpha texture
  18349. */
  18350. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18351. /**
  18352. * Creates an alpha texture from some data.
  18353. * @param data Define the texture data
  18354. * @param width Define the width of the texture
  18355. * @param height Define the height of the texture
  18356. * @param scene Define the scene the texture belongs to
  18357. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18358. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18359. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18360. * @returns the alpha texture
  18361. */
  18362. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18363. /**
  18364. * Creates a RGB texture from some data.
  18365. * @param data Define the texture data
  18366. * @param width Define the width of the texture
  18367. * @param height Define the height of the texture
  18368. * @param scene Define the scene the texture belongs to
  18369. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18370. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18371. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18372. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18373. * @returns the RGB alpha texture
  18374. */
  18375. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18376. /**
  18377. * Creates a RGBA texture from some data.
  18378. * @param data Define the texture data
  18379. * @param width Define the width of the texture
  18380. * @param height Define the height of the texture
  18381. * @param scene Define the scene the texture belongs to
  18382. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18383. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18384. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18385. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18386. * @returns the RGBA texture
  18387. */
  18388. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18389. /**
  18390. * Creates a R texture from some data.
  18391. * @param data Define the texture data
  18392. * @param width Define the width of the texture
  18393. * @param height Define the height of the texture
  18394. * @param scene Define the scene the texture belongs to
  18395. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18396. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18397. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18398. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18399. * @returns the R texture
  18400. */
  18401. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18402. }
  18403. }
  18404. declare module "babylonjs/Animations/runtimeAnimation" {
  18405. import { Animation } from "babylonjs/Animations/animation";
  18406. import { Animatable } from "babylonjs/Animations/animatable";
  18407. import { Scene } from "babylonjs/scene";
  18408. /**
  18409. * Defines a runtime animation
  18410. */
  18411. export class RuntimeAnimation {
  18412. private _events;
  18413. /**
  18414. * The current frame of the runtime animation
  18415. */
  18416. private _currentFrame;
  18417. /**
  18418. * The animation used by the runtime animation
  18419. */
  18420. private _animation;
  18421. /**
  18422. * The target of the runtime animation
  18423. */
  18424. private _target;
  18425. /**
  18426. * The initiating animatable
  18427. */
  18428. private _host;
  18429. /**
  18430. * The original value of the runtime animation
  18431. */
  18432. private _originalValue;
  18433. /**
  18434. * The original blend value of the runtime animation
  18435. */
  18436. private _originalBlendValue;
  18437. /**
  18438. * The offsets cache of the runtime animation
  18439. */
  18440. private _offsetsCache;
  18441. /**
  18442. * The high limits cache of the runtime animation
  18443. */
  18444. private _highLimitsCache;
  18445. /**
  18446. * Specifies if the runtime animation has been stopped
  18447. */
  18448. private _stopped;
  18449. /**
  18450. * The blending factor of the runtime animation
  18451. */
  18452. private _blendingFactor;
  18453. /**
  18454. * The BabylonJS scene
  18455. */
  18456. private _scene;
  18457. /**
  18458. * The current value of the runtime animation
  18459. */
  18460. private _currentValue;
  18461. /** @hidden */
  18462. _workValue: any;
  18463. /**
  18464. * The active target of the runtime animation
  18465. */
  18466. private _activeTarget;
  18467. /**
  18468. * The target path of the runtime animation
  18469. */
  18470. private _targetPath;
  18471. /**
  18472. * The weight of the runtime animation
  18473. */
  18474. private _weight;
  18475. /**
  18476. * The ratio offset of the runtime animation
  18477. */
  18478. private _ratioOffset;
  18479. /**
  18480. * The previous delay of the runtime animation
  18481. */
  18482. private _previousDelay;
  18483. /**
  18484. * The previous ratio of the runtime animation
  18485. */
  18486. private _previousRatio;
  18487. /**
  18488. * Gets the current frame of the runtime animation
  18489. */
  18490. readonly currentFrame: number;
  18491. /**
  18492. * Gets the weight of the runtime animation
  18493. */
  18494. readonly weight: number;
  18495. /**
  18496. * Gets the current value of the runtime animation
  18497. */
  18498. readonly currentValue: any;
  18499. /**
  18500. * Gets the target path of the runtime animation
  18501. */
  18502. readonly targetPath: string;
  18503. /**
  18504. * Gets the actual target of the runtime animation
  18505. */
  18506. readonly target: any;
  18507. /**
  18508. * Create a new RuntimeAnimation object
  18509. * @param target defines the target of the animation
  18510. * @param animation defines the source animation object
  18511. * @param scene defines the hosting scene
  18512. * @param host defines the initiating Animatable
  18513. */
  18514. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18515. /**
  18516. * Gets the animation from the runtime animation
  18517. */
  18518. readonly animation: Animation;
  18519. /**
  18520. * Resets the runtime animation to the beginning
  18521. * @param restoreOriginal defines whether to restore the target property to the original value
  18522. */
  18523. reset(restoreOriginal?: boolean): void;
  18524. /**
  18525. * Specifies if the runtime animation is stopped
  18526. * @returns Boolean specifying if the runtime animation is stopped
  18527. */
  18528. isStopped(): boolean;
  18529. /**
  18530. * Disposes of the runtime animation
  18531. */
  18532. dispose(): void;
  18533. /**
  18534. * Interpolates the animation from the current frame
  18535. * @param currentFrame The frame to interpolate the animation to
  18536. * @param repeatCount The number of times that the animation should loop
  18537. * @param loopMode The type of looping mode to use
  18538. * @param offsetValue Animation offset value
  18539. * @param highLimitValue The high limit value
  18540. * @returns The interpolated value
  18541. */
  18542. private _interpolate;
  18543. /**
  18544. * Apply the interpolated value to the target
  18545. * @param currentValue defines the value computed by the animation
  18546. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18547. */
  18548. setValue(currentValue: any, weight?: number): void;
  18549. private _setValue;
  18550. /**
  18551. * Gets the loop pmode of the runtime animation
  18552. * @returns Loop Mode
  18553. */
  18554. private _getCorrectLoopMode;
  18555. /**
  18556. * Move the current animation to a given frame
  18557. * @param frame defines the frame to move to
  18558. */
  18559. goToFrame(frame: number): void;
  18560. /**
  18561. * @hidden Internal use only
  18562. */
  18563. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18564. /**
  18565. * Execute the current animation
  18566. * @param delay defines the delay to add to the current frame
  18567. * @param from defines the lower bound of the animation range
  18568. * @param to defines the upper bound of the animation range
  18569. * @param loop defines if the current animation must loop
  18570. * @param speedRatio defines the current speed ratio
  18571. * @param weight defines the weight of the animation (default is -1 so no weight)
  18572. * @param onLoop optional callback called when animation loops
  18573. * @returns a boolean indicating if the animation is running
  18574. */
  18575. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18576. }
  18577. }
  18578. declare module "babylonjs/Animations/animatable" {
  18579. import { Animation } from "babylonjs/Animations/animation";
  18580. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18581. import { Nullable } from "babylonjs/types";
  18582. import { Observable } from "babylonjs/Misc/observable";
  18583. import { Scene } from "babylonjs/scene";
  18584. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18585. import { Node } from "babylonjs/node";
  18586. /**
  18587. * Class used to store an actual running animation
  18588. */
  18589. export class Animatable {
  18590. /** defines the target object */
  18591. target: any;
  18592. /** defines the starting frame number (default is 0) */
  18593. fromFrame: number;
  18594. /** defines the ending frame number (default is 100) */
  18595. toFrame: number;
  18596. /** defines if the animation must loop (default is false) */
  18597. loopAnimation: boolean;
  18598. /** defines a callback to call when animation ends if it is not looping */
  18599. onAnimationEnd?: (() => void) | null | undefined;
  18600. /** defines a callback to call when animation loops */
  18601. onAnimationLoop?: (() => void) | null | undefined;
  18602. private _localDelayOffset;
  18603. private _pausedDelay;
  18604. private _runtimeAnimations;
  18605. private _paused;
  18606. private _scene;
  18607. private _speedRatio;
  18608. private _weight;
  18609. private _syncRoot;
  18610. /**
  18611. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18612. * This will only apply for non looping animation (default is true)
  18613. */
  18614. disposeOnEnd: boolean;
  18615. /**
  18616. * Gets a boolean indicating if the animation has started
  18617. */
  18618. animationStarted: boolean;
  18619. /**
  18620. * Observer raised when the animation ends
  18621. */
  18622. onAnimationEndObservable: Observable<Animatable>;
  18623. /**
  18624. * Observer raised when the animation loops
  18625. */
  18626. onAnimationLoopObservable: Observable<Animatable>;
  18627. /**
  18628. * Gets the root Animatable used to synchronize and normalize animations
  18629. */
  18630. readonly syncRoot: Animatable;
  18631. /**
  18632. * Gets the current frame of the first RuntimeAnimation
  18633. * Used to synchronize Animatables
  18634. */
  18635. readonly masterFrame: number;
  18636. /**
  18637. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18638. */
  18639. weight: number;
  18640. /**
  18641. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18642. */
  18643. speedRatio: number;
  18644. /**
  18645. * Creates a new Animatable
  18646. * @param scene defines the hosting scene
  18647. * @param target defines the target object
  18648. * @param fromFrame defines the starting frame number (default is 0)
  18649. * @param toFrame defines the ending frame number (default is 100)
  18650. * @param loopAnimation defines if the animation must loop (default is false)
  18651. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18652. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18653. * @param animations defines a group of animation to add to the new Animatable
  18654. * @param onAnimationLoop defines a callback to call when animation loops
  18655. */
  18656. constructor(scene: Scene,
  18657. /** defines the target object */
  18658. target: any,
  18659. /** defines the starting frame number (default is 0) */
  18660. fromFrame?: number,
  18661. /** defines the ending frame number (default is 100) */
  18662. toFrame?: number,
  18663. /** defines if the animation must loop (default is false) */
  18664. loopAnimation?: boolean, speedRatio?: number,
  18665. /** defines a callback to call when animation ends if it is not looping */
  18666. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18667. /** defines a callback to call when animation loops */
  18668. onAnimationLoop?: (() => void) | null | undefined);
  18669. /**
  18670. * Synchronize and normalize current Animatable with a source Animatable
  18671. * This is useful when using animation weights and when animations are not of the same length
  18672. * @param root defines the root Animatable to synchronize with
  18673. * @returns the current Animatable
  18674. */
  18675. syncWith(root: Animatable): Animatable;
  18676. /**
  18677. * Gets the list of runtime animations
  18678. * @returns an array of RuntimeAnimation
  18679. */
  18680. getAnimations(): RuntimeAnimation[];
  18681. /**
  18682. * Adds more animations to the current animatable
  18683. * @param target defines the target of the animations
  18684. * @param animations defines the new animations to add
  18685. */
  18686. appendAnimations(target: any, animations: Animation[]): void;
  18687. /**
  18688. * Gets the source animation for a specific property
  18689. * @param property defines the propertyu to look for
  18690. * @returns null or the source animation for the given property
  18691. */
  18692. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18693. /**
  18694. * Gets the runtime animation for a specific property
  18695. * @param property defines the propertyu to look for
  18696. * @returns null or the runtime animation for the given property
  18697. */
  18698. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18699. /**
  18700. * Resets the animatable to its original state
  18701. */
  18702. reset(): void;
  18703. /**
  18704. * Allows the animatable to blend with current running animations
  18705. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18706. * @param blendingSpeed defines the blending speed to use
  18707. */
  18708. enableBlending(blendingSpeed: number): void;
  18709. /**
  18710. * Disable animation blending
  18711. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18712. */
  18713. disableBlending(): void;
  18714. /**
  18715. * Jump directly to a given frame
  18716. * @param frame defines the frame to jump to
  18717. */
  18718. goToFrame(frame: number): void;
  18719. /**
  18720. * Pause the animation
  18721. */
  18722. pause(): void;
  18723. /**
  18724. * Restart the animation
  18725. */
  18726. restart(): void;
  18727. private _raiseOnAnimationEnd;
  18728. /**
  18729. * Stop and delete the current animation
  18730. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18731. * @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)
  18732. */
  18733. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18734. /**
  18735. * Wait asynchronously for the animation to end
  18736. * @returns a promise which will be fullfilled when the animation ends
  18737. */
  18738. waitAsync(): Promise<Animatable>;
  18739. /** @hidden */
  18740. _animate(delay: number): boolean;
  18741. }
  18742. module "babylonjs/scene" {
  18743. interface Scene {
  18744. /** @hidden */
  18745. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18746. /** @hidden */
  18747. _processLateAnimationBindingsForMatrices(holder: {
  18748. totalWeight: number;
  18749. animations: RuntimeAnimation[];
  18750. originalValue: Matrix;
  18751. }): any;
  18752. /** @hidden */
  18753. _processLateAnimationBindingsForQuaternions(holder: {
  18754. totalWeight: number;
  18755. animations: RuntimeAnimation[];
  18756. originalValue: Quaternion;
  18757. }, refQuaternion: Quaternion): Quaternion;
  18758. /** @hidden */
  18759. _processLateAnimationBindings(): void;
  18760. /**
  18761. * Will start the animation sequence of a given target
  18762. * @param target defines the target
  18763. * @param from defines from which frame should animation start
  18764. * @param to defines until which frame should animation run.
  18765. * @param weight defines the weight to apply to the animation (1.0 by default)
  18766. * @param loop defines if the animation loops
  18767. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18768. * @param onAnimationEnd defines the function to be executed when the animation ends
  18769. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18770. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18771. * @param onAnimationLoop defines the callback to call when an animation loops
  18772. * @returns the animatable object created for this animation
  18773. */
  18774. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18775. /**
  18776. * Will start the animation sequence of a given target
  18777. * @param target defines the target
  18778. * @param from defines from which frame should animation start
  18779. * @param to defines until which frame should animation run.
  18780. * @param loop defines if the animation loops
  18781. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18782. * @param onAnimationEnd defines the function to be executed when the animation ends
  18783. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18784. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18785. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18786. * @param onAnimationLoop defines the callback to call when an animation loops
  18787. * @returns the animatable object created for this animation
  18788. */
  18789. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18790. /**
  18791. * Will start the animation sequence of a given target and its hierarchy
  18792. * @param target defines the target
  18793. * @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.
  18794. * @param from defines from which frame should animation start
  18795. * @param to defines until which frame should animation run.
  18796. * @param loop defines if the animation loops
  18797. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18798. * @param onAnimationEnd defines the function to be executed when the animation ends
  18799. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18800. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18801. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18802. * @param onAnimationLoop defines the callback to call when an animation loops
  18803. * @returns the list of created animatables
  18804. */
  18805. 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[];
  18806. /**
  18807. * Begin a new animation on a given node
  18808. * @param target defines the target where the animation will take place
  18809. * @param animations defines the list of animations to start
  18810. * @param from defines the initial value
  18811. * @param to defines the final value
  18812. * @param loop defines if you want animation to loop (off by default)
  18813. * @param speedRatio defines the speed ratio to apply to all animations
  18814. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18815. * @param onAnimationLoop defines the callback to call when an animation loops
  18816. * @returns the list of created animatables
  18817. */
  18818. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18819. /**
  18820. * Begin a new animation on a given node and its hierarchy
  18821. * @param target defines the root node where the animation will take place
  18822. * @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.
  18823. * @param animations defines the list of animations to start
  18824. * @param from defines the initial value
  18825. * @param to defines the final value
  18826. * @param loop defines if you want animation to loop (off by default)
  18827. * @param speedRatio defines the speed ratio to apply to all animations
  18828. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18829. * @param onAnimationLoop defines the callback to call when an animation loops
  18830. * @returns the list of animatables created for all nodes
  18831. */
  18832. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18833. /**
  18834. * Gets the animatable associated with a specific target
  18835. * @param target defines the target of the animatable
  18836. * @returns the required animatable if found
  18837. */
  18838. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18839. /**
  18840. * Gets all animatables associated with a given target
  18841. * @param target defines the target to look animatables for
  18842. * @returns an array of Animatables
  18843. */
  18844. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18845. /**
  18846. * Will stop the animation of the given target
  18847. * @param target - the target
  18848. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18849. * @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)
  18850. */
  18851. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18852. /**
  18853. * Stops and removes all animations that have been applied to the scene
  18854. */
  18855. stopAllAnimations(): void;
  18856. }
  18857. }
  18858. module "babylonjs/Bones/bone" {
  18859. interface Bone {
  18860. /**
  18861. * Copy an animation range from another bone
  18862. * @param source defines the source bone
  18863. * @param rangeName defines the range name to copy
  18864. * @param frameOffset defines the frame offset
  18865. * @param rescaleAsRequired defines if rescaling must be applied if required
  18866. * @param skelDimensionsRatio defines the scaling ratio
  18867. * @returns true if operation was successful
  18868. */
  18869. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18870. }
  18871. }
  18872. }
  18873. declare module "babylonjs/Bones/skeleton" {
  18874. import { Bone } from "babylonjs/Bones/bone";
  18875. import { IAnimatable } from "babylonjs/Misc/tools";
  18876. import { Observable } from "babylonjs/Misc/observable";
  18877. import { Vector3, Matrix } from "babylonjs/Maths/math";
  18878. import { Scene } from "babylonjs/scene";
  18879. import { Nullable } from "babylonjs/types";
  18880. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18881. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  18882. import { Animatable } from "babylonjs/Animations/animatable";
  18883. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  18884. import { Animation } from "babylonjs/Animations/animation";
  18885. import { AnimationRange } from "babylonjs/Animations/animationRange";
  18886. /**
  18887. * Class used to handle skinning animations
  18888. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18889. */
  18890. export class Skeleton implements IAnimatable {
  18891. /** defines the skeleton name */
  18892. name: string;
  18893. /** defines the skeleton Id */
  18894. id: string;
  18895. /**
  18896. * Defines the list of child bones
  18897. */
  18898. bones: Bone[];
  18899. /**
  18900. * Defines an estimate of the dimension of the skeleton at rest
  18901. */
  18902. dimensionsAtRest: Vector3;
  18903. /**
  18904. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18905. */
  18906. needInitialSkinMatrix: boolean;
  18907. /**
  18908. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18909. */
  18910. overrideMesh: Nullable<AbstractMesh>;
  18911. /**
  18912. * Gets the list of animations attached to this skeleton
  18913. */
  18914. animations: Array<Animation>;
  18915. private _scene;
  18916. private _isDirty;
  18917. private _transformMatrices;
  18918. private _transformMatrixTexture;
  18919. private _meshesWithPoseMatrix;
  18920. private _animatables;
  18921. private _identity;
  18922. private _synchronizedWithMesh;
  18923. private _ranges;
  18924. private _lastAbsoluteTransformsUpdateId;
  18925. private _canUseTextureForBones;
  18926. /** @hidden */
  18927. _numBonesWithLinkedTransformNode: number;
  18928. /**
  18929. * Specifies if the skeleton should be serialized
  18930. */
  18931. doNotSerialize: boolean;
  18932. /**
  18933. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18934. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18935. */
  18936. useTextureToStoreBoneMatrices: boolean;
  18937. private _animationPropertiesOverride;
  18938. /**
  18939. * Gets or sets the animation properties override
  18940. */
  18941. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18942. /**
  18943. * An observable triggered before computing the skeleton's matrices
  18944. */
  18945. onBeforeComputeObservable: Observable<Skeleton>;
  18946. /**
  18947. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18948. */
  18949. readonly isUsingTextureForMatrices: boolean;
  18950. /**
  18951. * Creates a new skeleton
  18952. * @param name defines the skeleton name
  18953. * @param id defines the skeleton Id
  18954. * @param scene defines the hosting scene
  18955. */
  18956. constructor(
  18957. /** defines the skeleton name */
  18958. name: string,
  18959. /** defines the skeleton Id */
  18960. id: string, scene: Scene);
  18961. /**
  18962. * Gets the current object class name.
  18963. * @return the class name
  18964. */
  18965. getClassName(): string;
  18966. /**
  18967. * Returns an array containing the root bones
  18968. * @returns an array containing the root bones
  18969. */
  18970. getChildren(): Array<Bone>;
  18971. /**
  18972. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18973. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18974. * @returns a Float32Array containing matrices data
  18975. */
  18976. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18977. /**
  18978. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18979. * @returns a raw texture containing the data
  18980. */
  18981. getTransformMatrixTexture(): Nullable<RawTexture>;
  18982. /**
  18983. * Gets the current hosting scene
  18984. * @returns a scene object
  18985. */
  18986. getScene(): Scene;
  18987. /**
  18988. * Gets a string representing the current skeleton data
  18989. * @param fullDetails defines a boolean indicating if we want a verbose version
  18990. * @returns a string representing the current skeleton data
  18991. */
  18992. toString(fullDetails?: boolean): string;
  18993. /**
  18994. * Get bone's index searching by name
  18995. * @param name defines bone's name to search for
  18996. * @return the indice of the bone. Returns -1 if not found
  18997. */
  18998. getBoneIndexByName(name: string): number;
  18999. /**
  19000. * Creater a new animation range
  19001. * @param name defines the name of the range
  19002. * @param from defines the start key
  19003. * @param to defines the end key
  19004. */
  19005. createAnimationRange(name: string, from: number, to: number): void;
  19006. /**
  19007. * Delete a specific animation range
  19008. * @param name defines the name of the range
  19009. * @param deleteFrames defines if frames must be removed as well
  19010. */
  19011. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19012. /**
  19013. * Gets a specific animation range
  19014. * @param name defines the name of the range to look for
  19015. * @returns the requested animation range or null if not found
  19016. */
  19017. getAnimationRange(name: string): Nullable<AnimationRange>;
  19018. /**
  19019. * Gets the list of all animation ranges defined on this skeleton
  19020. * @returns an array
  19021. */
  19022. getAnimationRanges(): Nullable<AnimationRange>[];
  19023. /**
  19024. * Copy animation range from a source skeleton.
  19025. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19026. * @param source defines the source skeleton
  19027. * @param name defines the name of the range to copy
  19028. * @param rescaleAsRequired defines if rescaling must be applied if required
  19029. * @returns true if operation was successful
  19030. */
  19031. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19032. /**
  19033. * Forces the skeleton to go to rest pose
  19034. */
  19035. returnToRest(): void;
  19036. private _getHighestAnimationFrame;
  19037. /**
  19038. * Begin a specific animation range
  19039. * @param name defines the name of the range to start
  19040. * @param loop defines if looping must be turned on (false by default)
  19041. * @param speedRatio defines the speed ratio to apply (1 by default)
  19042. * @param onAnimationEnd defines a callback which will be called when animation will end
  19043. * @returns a new animatable
  19044. */
  19045. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19046. /** @hidden */
  19047. _markAsDirty(): void;
  19048. /** @hidden */
  19049. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19050. /** @hidden */
  19051. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19052. private _computeTransformMatrices;
  19053. /**
  19054. * Build all resources required to render a skeleton
  19055. */
  19056. prepare(): void;
  19057. /**
  19058. * Gets the list of animatables currently running for this skeleton
  19059. * @returns an array of animatables
  19060. */
  19061. getAnimatables(): IAnimatable[];
  19062. /**
  19063. * Clone the current skeleton
  19064. * @param name defines the name of the new skeleton
  19065. * @param id defines the id of the enw skeleton
  19066. * @returns the new skeleton
  19067. */
  19068. clone(name: string, id: string): Skeleton;
  19069. /**
  19070. * Enable animation blending for this skeleton
  19071. * @param blendingSpeed defines the blending speed to apply
  19072. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19073. */
  19074. enableBlending(blendingSpeed?: number): void;
  19075. /**
  19076. * Releases all resources associated with the current skeleton
  19077. */
  19078. dispose(): void;
  19079. /**
  19080. * Serialize the skeleton in a JSON object
  19081. * @returns a JSON object
  19082. */
  19083. serialize(): any;
  19084. /**
  19085. * Creates a new skeleton from serialized data
  19086. * @param parsedSkeleton defines the serialized data
  19087. * @param scene defines the hosting scene
  19088. * @returns a new skeleton
  19089. */
  19090. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19091. /**
  19092. * Compute all node absolute transforms
  19093. * @param forceUpdate defines if computation must be done even if cache is up to date
  19094. */
  19095. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19096. /**
  19097. * Gets the root pose matrix
  19098. * @returns a matrix
  19099. */
  19100. getPoseMatrix(): Nullable<Matrix>;
  19101. /**
  19102. * Sorts bones per internal index
  19103. */
  19104. sortBones(): void;
  19105. private _sortBones;
  19106. }
  19107. }
  19108. declare module "babylonjs/Morph/morphTarget" {
  19109. import { IAnimatable } from "babylonjs/Misc/tools";
  19110. import { Observable } from "babylonjs/Misc/observable";
  19111. import { Nullable, FloatArray } from "babylonjs/types";
  19112. import { Scene } from "babylonjs/scene";
  19113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19114. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19115. /**
  19116. * Defines a target to use with MorphTargetManager
  19117. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19118. */
  19119. export class MorphTarget implements IAnimatable {
  19120. /** defines the name of the target */
  19121. name: string;
  19122. /**
  19123. * Gets or sets the list of animations
  19124. */
  19125. animations: import("babylonjs/Animations/animation").Animation[];
  19126. private _scene;
  19127. private _positions;
  19128. private _normals;
  19129. private _tangents;
  19130. private _influence;
  19131. /**
  19132. * Observable raised when the influence changes
  19133. */
  19134. onInfluenceChanged: Observable<boolean>;
  19135. /** @hidden */
  19136. _onDataLayoutChanged: Observable<void>;
  19137. /**
  19138. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19139. */
  19140. influence: number;
  19141. /**
  19142. * Gets or sets the id of the morph Target
  19143. */
  19144. id: string;
  19145. private _animationPropertiesOverride;
  19146. /**
  19147. * Gets or sets the animation properties override
  19148. */
  19149. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19150. /**
  19151. * Creates a new MorphTarget
  19152. * @param name defines the name of the target
  19153. * @param influence defines the influence to use
  19154. * @param scene defines the scene the morphtarget belongs to
  19155. */
  19156. constructor(
  19157. /** defines the name of the target */
  19158. name: string, influence?: number, scene?: Nullable<Scene>);
  19159. /**
  19160. * Gets a boolean defining if the target contains position data
  19161. */
  19162. readonly hasPositions: boolean;
  19163. /**
  19164. * Gets a boolean defining if the target contains normal data
  19165. */
  19166. readonly hasNormals: boolean;
  19167. /**
  19168. * Gets a boolean defining if the target contains tangent data
  19169. */
  19170. readonly hasTangents: boolean;
  19171. /**
  19172. * Affects position data to this target
  19173. * @param data defines the position data to use
  19174. */
  19175. setPositions(data: Nullable<FloatArray>): void;
  19176. /**
  19177. * Gets the position data stored in this target
  19178. * @returns a FloatArray containing the position data (or null if not present)
  19179. */
  19180. getPositions(): Nullable<FloatArray>;
  19181. /**
  19182. * Affects normal data to this target
  19183. * @param data defines the normal data to use
  19184. */
  19185. setNormals(data: Nullable<FloatArray>): void;
  19186. /**
  19187. * Gets the normal data stored in this target
  19188. * @returns a FloatArray containing the normal data (or null if not present)
  19189. */
  19190. getNormals(): Nullable<FloatArray>;
  19191. /**
  19192. * Affects tangent data to this target
  19193. * @param data defines the tangent data to use
  19194. */
  19195. setTangents(data: Nullable<FloatArray>): void;
  19196. /**
  19197. * Gets the tangent data stored in this target
  19198. * @returns a FloatArray containing the tangent data (or null if not present)
  19199. */
  19200. getTangents(): Nullable<FloatArray>;
  19201. /**
  19202. * Serializes the current target into a Serialization object
  19203. * @returns the serialized object
  19204. */
  19205. serialize(): any;
  19206. /**
  19207. * Returns the string "MorphTarget"
  19208. * @returns "MorphTarget"
  19209. */
  19210. getClassName(): string;
  19211. /**
  19212. * Creates a new target from serialized data
  19213. * @param serializationObject defines the serialized data to use
  19214. * @returns a new MorphTarget
  19215. */
  19216. static Parse(serializationObject: any): MorphTarget;
  19217. /**
  19218. * Creates a MorphTarget from mesh data
  19219. * @param mesh defines the source mesh
  19220. * @param name defines the name to use for the new target
  19221. * @param influence defines the influence to attach to the target
  19222. * @returns a new MorphTarget
  19223. */
  19224. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19225. }
  19226. }
  19227. declare module "babylonjs/Morph/morphTargetManager" {
  19228. import { Nullable } from "babylonjs/types";
  19229. import { Scene } from "babylonjs/scene";
  19230. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19231. /**
  19232. * This class is used to deform meshes using morphing between different targets
  19233. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19234. */
  19235. export class MorphTargetManager {
  19236. private _targets;
  19237. private _targetInfluenceChangedObservers;
  19238. private _targetDataLayoutChangedObservers;
  19239. private _activeTargets;
  19240. private _scene;
  19241. private _influences;
  19242. private _supportsNormals;
  19243. private _supportsTangents;
  19244. private _vertexCount;
  19245. private _uniqueId;
  19246. private _tempInfluences;
  19247. /**
  19248. * Creates a new MorphTargetManager
  19249. * @param scene defines the current scene
  19250. */
  19251. constructor(scene?: Nullable<Scene>);
  19252. /**
  19253. * Gets the unique ID of this manager
  19254. */
  19255. readonly uniqueId: number;
  19256. /**
  19257. * Gets the number of vertices handled by this manager
  19258. */
  19259. readonly vertexCount: number;
  19260. /**
  19261. * Gets a boolean indicating if this manager supports morphing of normals
  19262. */
  19263. readonly supportsNormals: boolean;
  19264. /**
  19265. * Gets a boolean indicating if this manager supports morphing of tangents
  19266. */
  19267. readonly supportsTangents: boolean;
  19268. /**
  19269. * Gets the number of targets stored in this manager
  19270. */
  19271. readonly numTargets: number;
  19272. /**
  19273. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19274. */
  19275. readonly numInfluencers: number;
  19276. /**
  19277. * Gets the list of influences (one per target)
  19278. */
  19279. readonly influences: Float32Array;
  19280. /**
  19281. * Gets the active target at specified index. An active target is a target with an influence > 0
  19282. * @param index defines the index to check
  19283. * @returns the requested target
  19284. */
  19285. getActiveTarget(index: number): MorphTarget;
  19286. /**
  19287. * Gets the target at specified index
  19288. * @param index defines the index to check
  19289. * @returns the requested target
  19290. */
  19291. getTarget(index: number): MorphTarget;
  19292. /**
  19293. * Add a new target to this manager
  19294. * @param target defines the target to add
  19295. */
  19296. addTarget(target: MorphTarget): void;
  19297. /**
  19298. * Removes a target from the manager
  19299. * @param target defines the target to remove
  19300. */
  19301. removeTarget(target: MorphTarget): void;
  19302. /**
  19303. * Serializes the current manager into a Serialization object
  19304. * @returns the serialized object
  19305. */
  19306. serialize(): any;
  19307. private _syncActiveTargets;
  19308. /**
  19309. * Syncrhonize the targets with all the meshes using this morph target manager
  19310. */
  19311. synchronize(): void;
  19312. /**
  19313. * Creates a new MorphTargetManager from serialized data
  19314. * @param serializationObject defines the serialized data
  19315. * @param scene defines the hosting scene
  19316. * @returns the new MorphTargetManager
  19317. */
  19318. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19319. }
  19320. }
  19321. declare module "babylonjs/Meshes/groundMesh" {
  19322. import { Scene } from "babylonjs/scene";
  19323. import { Vector3 } from "babylonjs/Maths/math";
  19324. import { Mesh } from "babylonjs/Meshes/mesh";
  19325. /**
  19326. * Mesh representing the gorund
  19327. */
  19328. export class GroundMesh extends Mesh {
  19329. /** If octree should be generated */
  19330. generateOctree: boolean;
  19331. private _heightQuads;
  19332. /** @hidden */
  19333. _subdivisionsX: number;
  19334. /** @hidden */
  19335. _subdivisionsY: number;
  19336. /** @hidden */
  19337. _width: number;
  19338. /** @hidden */
  19339. _height: number;
  19340. /** @hidden */
  19341. _minX: number;
  19342. /** @hidden */
  19343. _maxX: number;
  19344. /** @hidden */
  19345. _minZ: number;
  19346. /** @hidden */
  19347. _maxZ: number;
  19348. constructor(name: string, scene: Scene);
  19349. /**
  19350. * "GroundMesh"
  19351. * @returns "GroundMesh"
  19352. */
  19353. getClassName(): string;
  19354. /**
  19355. * The minimum of x and y subdivisions
  19356. */
  19357. readonly subdivisions: number;
  19358. /**
  19359. * X subdivisions
  19360. */
  19361. readonly subdivisionsX: number;
  19362. /**
  19363. * Y subdivisions
  19364. */
  19365. readonly subdivisionsY: number;
  19366. /**
  19367. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19368. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19369. * @param chunksCount the number of subdivisions for x and y
  19370. * @param octreeBlocksSize (Default: 32)
  19371. */
  19372. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19373. /**
  19374. * Returns a height (y) value in the Worl system :
  19375. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19376. * @param x x coordinate
  19377. * @param z z coordinate
  19378. * @returns the ground y position if (x, z) are outside the ground surface.
  19379. */
  19380. getHeightAtCoordinates(x: number, z: number): number;
  19381. /**
  19382. * Returns a normalized vector (Vector3) orthogonal to the ground
  19383. * at the ground coordinates (x, z) expressed in the World system.
  19384. * @param x x coordinate
  19385. * @param z z coordinate
  19386. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19387. */
  19388. getNormalAtCoordinates(x: number, z: number): Vector3;
  19389. /**
  19390. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19391. * at the ground coordinates (x, z) expressed in the World system.
  19392. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19393. * @param x x coordinate
  19394. * @param z z coordinate
  19395. * @param ref vector to store the result
  19396. * @returns the GroundMesh.
  19397. */
  19398. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19399. /**
  19400. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19401. * if the ground has been updated.
  19402. * This can be used in the render loop.
  19403. * @returns the GroundMesh.
  19404. */
  19405. updateCoordinateHeights(): GroundMesh;
  19406. private _getFacetAt;
  19407. private _initHeightQuads;
  19408. private _computeHeightQuads;
  19409. /**
  19410. * Serializes this ground mesh
  19411. * @param serializationObject object to write serialization to
  19412. */
  19413. serialize(serializationObject: any): void;
  19414. /**
  19415. * Parses a serialized ground mesh
  19416. * @param parsedMesh the serialized mesh
  19417. * @param scene the scene to create the ground mesh in
  19418. * @returns the created ground mesh
  19419. */
  19420. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19421. }
  19422. }
  19423. declare module "babylonjs/Physics/physicsJoint" {
  19424. import { Vector3 } from "babylonjs/Maths/math";
  19425. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19426. /**
  19427. * Interface for Physics-Joint data
  19428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19429. */
  19430. export interface PhysicsJointData {
  19431. /**
  19432. * The main pivot of the joint
  19433. */
  19434. mainPivot?: Vector3;
  19435. /**
  19436. * The connected pivot of the joint
  19437. */
  19438. connectedPivot?: Vector3;
  19439. /**
  19440. * The main axis of the joint
  19441. */
  19442. mainAxis?: Vector3;
  19443. /**
  19444. * The connected axis of the joint
  19445. */
  19446. connectedAxis?: Vector3;
  19447. /**
  19448. * The collision of the joint
  19449. */
  19450. collision?: boolean;
  19451. /**
  19452. * Native Oimo/Cannon/Energy data
  19453. */
  19454. nativeParams?: any;
  19455. }
  19456. /**
  19457. * This is a holder class for the physics joint created by the physics plugin
  19458. * It holds a set of functions to control the underlying joint
  19459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19460. */
  19461. export class PhysicsJoint {
  19462. /**
  19463. * The type of the physics joint
  19464. */
  19465. type: number;
  19466. /**
  19467. * The data for the physics joint
  19468. */
  19469. jointData: PhysicsJointData;
  19470. private _physicsJoint;
  19471. protected _physicsPlugin: IPhysicsEnginePlugin;
  19472. /**
  19473. * Initializes the physics joint
  19474. * @param type The type of the physics joint
  19475. * @param jointData The data for the physics joint
  19476. */
  19477. constructor(
  19478. /**
  19479. * The type of the physics joint
  19480. */
  19481. type: number,
  19482. /**
  19483. * The data for the physics joint
  19484. */
  19485. jointData: PhysicsJointData);
  19486. /**
  19487. * Gets the physics joint
  19488. */
  19489. /**
  19490. * Sets the physics joint
  19491. */
  19492. physicsJoint: any;
  19493. /**
  19494. * Sets the physics plugin
  19495. */
  19496. physicsPlugin: IPhysicsEnginePlugin;
  19497. /**
  19498. * Execute a function that is physics-plugin specific.
  19499. * @param {Function} func the function that will be executed.
  19500. * It accepts two parameters: the physics world and the physics joint
  19501. */
  19502. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19503. /**
  19504. * Distance-Joint type
  19505. */
  19506. static DistanceJoint: number;
  19507. /**
  19508. * Hinge-Joint type
  19509. */
  19510. static HingeJoint: number;
  19511. /**
  19512. * Ball-and-Socket joint type
  19513. */
  19514. static BallAndSocketJoint: number;
  19515. /**
  19516. * Wheel-Joint type
  19517. */
  19518. static WheelJoint: number;
  19519. /**
  19520. * Slider-Joint type
  19521. */
  19522. static SliderJoint: number;
  19523. /**
  19524. * Prismatic-Joint type
  19525. */
  19526. static PrismaticJoint: number;
  19527. /**
  19528. * Universal-Joint type
  19529. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19530. */
  19531. static UniversalJoint: number;
  19532. /**
  19533. * Hinge-Joint 2 type
  19534. */
  19535. static Hinge2Joint: number;
  19536. /**
  19537. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19538. */
  19539. static PointToPointJoint: number;
  19540. /**
  19541. * Spring-Joint type
  19542. */
  19543. static SpringJoint: number;
  19544. /**
  19545. * Lock-Joint type
  19546. */
  19547. static LockJoint: number;
  19548. }
  19549. /**
  19550. * A class representing a physics distance joint
  19551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19552. */
  19553. export class DistanceJoint extends PhysicsJoint {
  19554. /**
  19555. *
  19556. * @param jointData The data for the Distance-Joint
  19557. */
  19558. constructor(jointData: DistanceJointData);
  19559. /**
  19560. * Update the predefined distance.
  19561. * @param maxDistance The maximum preferred distance
  19562. * @param minDistance The minimum preferred distance
  19563. */
  19564. updateDistance(maxDistance: number, minDistance?: number): void;
  19565. }
  19566. /**
  19567. * Represents a Motor-Enabled Joint
  19568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19569. */
  19570. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19571. /**
  19572. * Initializes the Motor-Enabled Joint
  19573. * @param type The type of the joint
  19574. * @param jointData The physica joint data for the joint
  19575. */
  19576. constructor(type: number, jointData: PhysicsJointData);
  19577. /**
  19578. * Set the motor values.
  19579. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19580. * @param force the force to apply
  19581. * @param maxForce max force for this motor.
  19582. */
  19583. setMotor(force?: number, maxForce?: number): void;
  19584. /**
  19585. * Set the motor's limits.
  19586. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19587. * @param upperLimit The upper limit of the motor
  19588. * @param lowerLimit The lower limit of the motor
  19589. */
  19590. setLimit(upperLimit: number, lowerLimit?: number): void;
  19591. }
  19592. /**
  19593. * This class represents a single physics Hinge-Joint
  19594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19595. */
  19596. export class HingeJoint extends MotorEnabledJoint {
  19597. /**
  19598. * Initializes the Hinge-Joint
  19599. * @param jointData The joint data for the Hinge-Joint
  19600. */
  19601. constructor(jointData: PhysicsJointData);
  19602. /**
  19603. * Set the motor values.
  19604. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19605. * @param {number} force the force to apply
  19606. * @param {number} maxForce max force for this motor.
  19607. */
  19608. setMotor(force?: number, maxForce?: number): void;
  19609. /**
  19610. * Set the motor's limits.
  19611. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19612. * @param upperLimit The upper limit of the motor
  19613. * @param lowerLimit The lower limit of the motor
  19614. */
  19615. setLimit(upperLimit: number, lowerLimit?: number): void;
  19616. }
  19617. /**
  19618. * This class represents a dual hinge physics joint (same as wheel joint)
  19619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19620. */
  19621. export class Hinge2Joint extends MotorEnabledJoint {
  19622. /**
  19623. * Initializes the Hinge2-Joint
  19624. * @param jointData The joint data for the Hinge2-Joint
  19625. */
  19626. constructor(jointData: PhysicsJointData);
  19627. /**
  19628. * Set the motor values.
  19629. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19630. * @param {number} targetSpeed the speed the motor is to reach
  19631. * @param {number} maxForce max force for this motor.
  19632. * @param {motorIndex} the motor's index, 0 or 1.
  19633. */
  19634. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19635. /**
  19636. * Set the motor limits.
  19637. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19638. * @param {number} upperLimit the upper limit
  19639. * @param {number} lowerLimit lower limit
  19640. * @param {motorIndex} the motor's index, 0 or 1.
  19641. */
  19642. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19643. }
  19644. /**
  19645. * Interface for a motor enabled joint
  19646. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19647. */
  19648. export interface IMotorEnabledJoint {
  19649. /**
  19650. * Physics joint
  19651. */
  19652. physicsJoint: any;
  19653. /**
  19654. * Sets the motor of the motor-enabled joint
  19655. * @param force The force of the motor
  19656. * @param maxForce The maximum force of the motor
  19657. * @param motorIndex The index of the motor
  19658. */
  19659. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19660. /**
  19661. * Sets the limit of the motor
  19662. * @param upperLimit The upper limit of the motor
  19663. * @param lowerLimit The lower limit of the motor
  19664. * @param motorIndex The index of the motor
  19665. */
  19666. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19667. }
  19668. /**
  19669. * Joint data for a Distance-Joint
  19670. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19671. */
  19672. export interface DistanceJointData extends PhysicsJointData {
  19673. /**
  19674. * Max distance the 2 joint objects can be apart
  19675. */
  19676. maxDistance: number;
  19677. }
  19678. /**
  19679. * Joint data from a spring joint
  19680. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19681. */
  19682. export interface SpringJointData extends PhysicsJointData {
  19683. /**
  19684. * Length of the spring
  19685. */
  19686. length: number;
  19687. /**
  19688. * Stiffness of the spring
  19689. */
  19690. stiffness: number;
  19691. /**
  19692. * Damping of the spring
  19693. */
  19694. damping: number;
  19695. /** this callback will be called when applying the force to the impostors. */
  19696. forceApplicationCallback: () => void;
  19697. }
  19698. }
  19699. declare module "babylonjs/Physics/IPhysicsEngine" {
  19700. import { Nullable } from "babylonjs/types";
  19701. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  19702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19703. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19704. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  19705. /**
  19706. * Interface used to describe a physics joint
  19707. */
  19708. export interface PhysicsImpostorJoint {
  19709. /** Defines the main impostor to which the joint is linked */
  19710. mainImpostor: PhysicsImpostor;
  19711. /** Defines the impostor that is connected to the main impostor using this joint */
  19712. connectedImpostor: PhysicsImpostor;
  19713. /** Defines the joint itself */
  19714. joint: PhysicsJoint;
  19715. }
  19716. /** @hidden */
  19717. export interface IPhysicsEnginePlugin {
  19718. world: any;
  19719. name: string;
  19720. setGravity(gravity: Vector3): void;
  19721. setTimeStep(timeStep: number): void;
  19722. getTimeStep(): number;
  19723. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19724. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19725. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19726. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19727. removePhysicsBody(impostor: PhysicsImpostor): void;
  19728. generateJoint(joint: PhysicsImpostorJoint): void;
  19729. removeJoint(joint: PhysicsImpostorJoint): void;
  19730. isSupported(): boolean;
  19731. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19732. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19733. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19734. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19735. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19736. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19737. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19738. getBodyMass(impostor: PhysicsImpostor): number;
  19739. getBodyFriction(impostor: PhysicsImpostor): number;
  19740. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19741. getBodyRestitution(impostor: PhysicsImpostor): number;
  19742. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19743. sleepBody(impostor: PhysicsImpostor): void;
  19744. wakeUpBody(impostor: PhysicsImpostor): void;
  19745. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19746. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19747. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19748. getRadius(impostor: PhysicsImpostor): number;
  19749. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19750. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19751. dispose(): void;
  19752. }
  19753. /**
  19754. * Interface used to define a physics engine
  19755. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19756. */
  19757. export interface IPhysicsEngine {
  19758. /**
  19759. * Gets the gravity vector used by the simulation
  19760. */
  19761. gravity: Vector3;
  19762. /**
  19763. * Sets the gravity vector used by the simulation
  19764. * @param gravity defines the gravity vector to use
  19765. */
  19766. setGravity(gravity: Vector3): void;
  19767. /**
  19768. * Set the time step of the physics engine.
  19769. * Default is 1/60.
  19770. * To slow it down, enter 1/600 for example.
  19771. * To speed it up, 1/30
  19772. * @param newTimeStep the new timestep to apply to this world.
  19773. */
  19774. setTimeStep(newTimeStep: number): void;
  19775. /**
  19776. * Get the time step of the physics engine.
  19777. * @returns the current time step
  19778. */
  19779. getTimeStep(): number;
  19780. /**
  19781. * Release all resources
  19782. */
  19783. dispose(): void;
  19784. /**
  19785. * Gets the name of the current physics plugin
  19786. * @returns the name of the plugin
  19787. */
  19788. getPhysicsPluginName(): string;
  19789. /**
  19790. * Adding a new impostor for the impostor tracking.
  19791. * This will be done by the impostor itself.
  19792. * @param impostor the impostor to add
  19793. */
  19794. addImpostor(impostor: PhysicsImpostor): void;
  19795. /**
  19796. * Remove an impostor from the engine.
  19797. * This impostor and its mesh will not longer be updated by the physics engine.
  19798. * @param impostor the impostor to remove
  19799. */
  19800. removeImpostor(impostor: PhysicsImpostor): void;
  19801. /**
  19802. * Add a joint to the physics engine
  19803. * @param mainImpostor defines the main impostor to which the joint is added.
  19804. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19805. * @param joint defines the joint that will connect both impostors.
  19806. */
  19807. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19808. /**
  19809. * Removes a joint from the simulation
  19810. * @param mainImpostor defines the impostor used with the joint
  19811. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19812. * @param joint defines the joint to remove
  19813. */
  19814. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19815. /**
  19816. * Gets the current plugin used to run the simulation
  19817. * @returns current plugin
  19818. */
  19819. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19820. /**
  19821. * Gets the list of physic impostors
  19822. * @returns an array of PhysicsImpostor
  19823. */
  19824. getImpostors(): Array<PhysicsImpostor>;
  19825. /**
  19826. * Gets the impostor for a physics enabled object
  19827. * @param object defines the object impersonated by the impostor
  19828. * @returns the PhysicsImpostor or null if not found
  19829. */
  19830. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19831. /**
  19832. * Gets the impostor for a physics body object
  19833. * @param body defines physics body used by the impostor
  19834. * @returns the PhysicsImpostor or null if not found
  19835. */
  19836. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19837. /**
  19838. * Called by the scene. No need to call it.
  19839. * @param delta defines the timespam between frames
  19840. */
  19841. _step(delta: number): void;
  19842. }
  19843. }
  19844. declare module "babylonjs/Physics/physicsImpostor" {
  19845. import { Nullable, IndicesArray } from "babylonjs/types";
  19846. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  19847. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19848. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19849. import { Scene } from "babylonjs/scene";
  19850. import { Bone } from "babylonjs/Bones/bone";
  19851. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  19852. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  19853. /**
  19854. * The interface for the physics imposter parameters
  19855. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19856. */
  19857. export interface PhysicsImpostorParameters {
  19858. /**
  19859. * The mass of the physics imposter
  19860. */
  19861. mass: number;
  19862. /**
  19863. * The friction of the physics imposter
  19864. */
  19865. friction?: number;
  19866. /**
  19867. * The coefficient of restitution of the physics imposter
  19868. */
  19869. restitution?: number;
  19870. /**
  19871. * The native options of the physics imposter
  19872. */
  19873. nativeOptions?: any;
  19874. /**
  19875. * Specifies if the parent should be ignored
  19876. */
  19877. ignoreParent?: boolean;
  19878. /**
  19879. * Specifies if bi-directional transformations should be disabled
  19880. */
  19881. disableBidirectionalTransformation?: boolean;
  19882. }
  19883. /**
  19884. * Interface for a physics-enabled object
  19885. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19886. */
  19887. export interface IPhysicsEnabledObject {
  19888. /**
  19889. * The position of the physics-enabled object
  19890. */
  19891. position: Vector3;
  19892. /**
  19893. * The rotation of the physics-enabled object
  19894. */
  19895. rotationQuaternion: Nullable<Quaternion>;
  19896. /**
  19897. * The scale of the physics-enabled object
  19898. */
  19899. scaling: Vector3;
  19900. /**
  19901. * The rotation of the physics-enabled object
  19902. */
  19903. rotation?: Vector3;
  19904. /**
  19905. * The parent of the physics-enabled object
  19906. */
  19907. parent?: any;
  19908. /**
  19909. * The bounding info of the physics-enabled object
  19910. * @returns The bounding info of the physics-enabled object
  19911. */
  19912. getBoundingInfo(): BoundingInfo;
  19913. /**
  19914. * Computes the world matrix
  19915. * @param force Specifies if the world matrix should be computed by force
  19916. * @returns A world matrix
  19917. */
  19918. computeWorldMatrix(force: boolean): Matrix;
  19919. /**
  19920. * Gets the world matrix
  19921. * @returns A world matrix
  19922. */
  19923. getWorldMatrix?(): Matrix;
  19924. /**
  19925. * Gets the child meshes
  19926. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19927. * @returns An array of abstract meshes
  19928. */
  19929. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19930. /**
  19931. * Gets the vertex data
  19932. * @param kind The type of vertex data
  19933. * @returns A nullable array of numbers, or a float32 array
  19934. */
  19935. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19936. /**
  19937. * Gets the indices from the mesh
  19938. * @returns A nullable array of index arrays
  19939. */
  19940. getIndices?(): Nullable<IndicesArray>;
  19941. /**
  19942. * Gets the scene from the mesh
  19943. * @returns the indices array or null
  19944. */
  19945. getScene?(): Scene;
  19946. /**
  19947. * Gets the absolute position from the mesh
  19948. * @returns the absolute position
  19949. */
  19950. getAbsolutePosition(): Vector3;
  19951. /**
  19952. * Gets the absolute pivot point from the mesh
  19953. * @returns the absolute pivot point
  19954. */
  19955. getAbsolutePivotPoint(): Vector3;
  19956. /**
  19957. * Rotates the mesh
  19958. * @param axis The axis of rotation
  19959. * @param amount The amount of rotation
  19960. * @param space The space of the rotation
  19961. * @returns The rotation transform node
  19962. */
  19963. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19964. /**
  19965. * Translates the mesh
  19966. * @param axis The axis of translation
  19967. * @param distance The distance of translation
  19968. * @param space The space of the translation
  19969. * @returns The transform node
  19970. */
  19971. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19972. /**
  19973. * Sets the absolute position of the mesh
  19974. * @param absolutePosition The absolute position of the mesh
  19975. * @returns The transform node
  19976. */
  19977. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19978. /**
  19979. * Gets the class name of the mesh
  19980. * @returns The class name
  19981. */
  19982. getClassName(): string;
  19983. }
  19984. /**
  19985. * Represents a physics imposter
  19986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19987. */
  19988. export class PhysicsImpostor {
  19989. /**
  19990. * The physics-enabled object used as the physics imposter
  19991. */
  19992. object: IPhysicsEnabledObject;
  19993. /**
  19994. * The type of the physics imposter
  19995. */
  19996. type: number;
  19997. private _options;
  19998. private _scene?;
  19999. /**
  20000. * The default object size of the imposter
  20001. */
  20002. static DEFAULT_OBJECT_SIZE: Vector3;
  20003. /**
  20004. * The identity quaternion of the imposter
  20005. */
  20006. static IDENTITY_QUATERNION: Quaternion;
  20007. /** @hidden */
  20008. _pluginData: any;
  20009. private _physicsEngine;
  20010. private _physicsBody;
  20011. private _bodyUpdateRequired;
  20012. private _onBeforePhysicsStepCallbacks;
  20013. private _onAfterPhysicsStepCallbacks;
  20014. /** @hidden */
  20015. _onPhysicsCollideCallbacks: Array<{
  20016. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20017. otherImpostors: Array<PhysicsImpostor>;
  20018. }>;
  20019. private _deltaPosition;
  20020. private _deltaRotation;
  20021. private _deltaRotationConjugated;
  20022. private _parent;
  20023. private _isDisposed;
  20024. private static _tmpVecs;
  20025. private static _tmpQuat;
  20026. /**
  20027. * Specifies if the physics imposter is disposed
  20028. */
  20029. readonly isDisposed: boolean;
  20030. /**
  20031. * Gets the mass of the physics imposter
  20032. */
  20033. mass: number;
  20034. /**
  20035. * Gets the coefficient of friction
  20036. */
  20037. /**
  20038. * Sets the coefficient of friction
  20039. */
  20040. friction: number;
  20041. /**
  20042. * Gets the coefficient of restitution
  20043. */
  20044. /**
  20045. * Sets the coefficient of restitution
  20046. */
  20047. restitution: number;
  20048. /**
  20049. * The unique id of the physics imposter
  20050. * set by the physics engine when adding this impostor to the array
  20051. */
  20052. uniqueId: number;
  20053. private _joints;
  20054. /**
  20055. * Initializes the physics imposter
  20056. * @param object The physics-enabled object used as the physics imposter
  20057. * @param type The type of the physics imposter
  20058. * @param _options The options for the physics imposter
  20059. * @param _scene The Babylon scene
  20060. */
  20061. constructor(
  20062. /**
  20063. * The physics-enabled object used as the physics imposter
  20064. */
  20065. object: IPhysicsEnabledObject,
  20066. /**
  20067. * The type of the physics imposter
  20068. */
  20069. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20070. /**
  20071. * This function will completly initialize this impostor.
  20072. * It will create a new body - but only if this mesh has no parent.
  20073. * If it has, this impostor will not be used other than to define the impostor
  20074. * of the child mesh.
  20075. * @hidden
  20076. */
  20077. _init(): void;
  20078. private _getPhysicsParent;
  20079. /**
  20080. * Should a new body be generated.
  20081. * @returns boolean specifying if body initialization is required
  20082. */
  20083. isBodyInitRequired(): boolean;
  20084. /**
  20085. * Sets the updated scaling
  20086. * @param updated Specifies if the scaling is updated
  20087. */
  20088. setScalingUpdated(): void;
  20089. /**
  20090. * Force a regeneration of this or the parent's impostor's body.
  20091. * Use under cautious - This will remove all joints already implemented.
  20092. */
  20093. forceUpdate(): void;
  20094. /**
  20095. * Gets the body that holds this impostor. Either its own, or its parent.
  20096. */
  20097. /**
  20098. * Set the physics body. Used mainly by the physics engine/plugin
  20099. */
  20100. physicsBody: any;
  20101. /**
  20102. * Get the parent of the physics imposter
  20103. * @returns Physics imposter or null
  20104. */
  20105. /**
  20106. * Sets the parent of the physics imposter
  20107. */
  20108. parent: Nullable<PhysicsImpostor>;
  20109. /**
  20110. * Resets the update flags
  20111. */
  20112. resetUpdateFlags(): void;
  20113. /**
  20114. * Gets the object extend size
  20115. * @returns the object extend size
  20116. */
  20117. getObjectExtendSize(): Vector3;
  20118. /**
  20119. * Gets the object center
  20120. * @returns The object center
  20121. */
  20122. getObjectCenter(): Vector3;
  20123. /**
  20124. * Get a specific parametes from the options parameter
  20125. * @param paramName The object parameter name
  20126. * @returns The object parameter
  20127. */
  20128. getParam(paramName: string): any;
  20129. /**
  20130. * Sets a specific parameter in the options given to the physics plugin
  20131. * @param paramName The parameter name
  20132. * @param value The value of the parameter
  20133. */
  20134. setParam(paramName: string, value: number): void;
  20135. /**
  20136. * Specifically change the body's mass option. Won't recreate the physics body object
  20137. * @param mass The mass of the physics imposter
  20138. */
  20139. setMass(mass: number): void;
  20140. /**
  20141. * Gets the linear velocity
  20142. * @returns linear velocity or null
  20143. */
  20144. getLinearVelocity(): Nullable<Vector3>;
  20145. /**
  20146. * Sets the linear velocity
  20147. * @param velocity linear velocity or null
  20148. */
  20149. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20150. /**
  20151. * Gets the angular velocity
  20152. * @returns angular velocity or null
  20153. */
  20154. getAngularVelocity(): Nullable<Vector3>;
  20155. /**
  20156. * Sets the angular velocity
  20157. * @param velocity The velocity or null
  20158. */
  20159. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20160. /**
  20161. * Execute a function with the physics plugin native code
  20162. * Provide a function the will have two variables - the world object and the physics body object
  20163. * @param func The function to execute with the physics plugin native code
  20164. */
  20165. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20166. /**
  20167. * Register a function that will be executed before the physics world is stepping forward
  20168. * @param func The function to execute before the physics world is stepped forward
  20169. */
  20170. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20171. /**
  20172. * Unregister a function that will be executed before the physics world is stepping forward
  20173. * @param func The function to execute before the physics world is stepped forward
  20174. */
  20175. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20176. /**
  20177. * Register a function that will be executed after the physics step
  20178. * @param func The function to execute after physics step
  20179. */
  20180. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20181. /**
  20182. * Unregisters a function that will be executed after the physics step
  20183. * @param func The function to execute after physics step
  20184. */
  20185. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20186. /**
  20187. * register a function that will be executed when this impostor collides against a different body
  20188. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20189. * @param func Callback that is executed on collision
  20190. */
  20191. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20192. /**
  20193. * Unregisters the physics imposter on contact
  20194. * @param collideAgainst The physics object to collide against
  20195. * @param func Callback to execute on collision
  20196. */
  20197. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20198. private _tmpQuat;
  20199. private _tmpQuat2;
  20200. /**
  20201. * Get the parent rotation
  20202. * @returns The parent rotation
  20203. */
  20204. getParentsRotation(): Quaternion;
  20205. /**
  20206. * this function is executed by the physics engine.
  20207. */
  20208. beforeStep: () => void;
  20209. /**
  20210. * this function is executed by the physics engine
  20211. */
  20212. afterStep: () => void;
  20213. /**
  20214. * Legacy collision detection event support
  20215. */
  20216. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20217. /**
  20218. * event and body object due to cannon's event-based architecture.
  20219. */
  20220. onCollide: (e: {
  20221. body: any;
  20222. }) => void;
  20223. /**
  20224. * Apply a force
  20225. * @param force The force to apply
  20226. * @param contactPoint The contact point for the force
  20227. * @returns The physics imposter
  20228. */
  20229. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20230. /**
  20231. * Apply an impulse
  20232. * @param force The impulse force
  20233. * @param contactPoint The contact point for the impulse force
  20234. * @returns The physics imposter
  20235. */
  20236. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20237. /**
  20238. * A help function to create a joint
  20239. * @param otherImpostor A physics imposter used to create a joint
  20240. * @param jointType The type of joint
  20241. * @param jointData The data for the joint
  20242. * @returns The physics imposter
  20243. */
  20244. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20245. /**
  20246. * Add a joint to this impostor with a different impostor
  20247. * @param otherImpostor A physics imposter used to add a joint
  20248. * @param joint The joint to add
  20249. * @returns The physics imposter
  20250. */
  20251. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20252. /**
  20253. * Will keep this body still, in a sleep mode.
  20254. * @returns the physics imposter
  20255. */
  20256. sleep(): PhysicsImpostor;
  20257. /**
  20258. * Wake the body up.
  20259. * @returns The physics imposter
  20260. */
  20261. wakeUp(): PhysicsImpostor;
  20262. /**
  20263. * Clones the physics imposter
  20264. * @param newObject The physics imposter clones to this physics-enabled object
  20265. * @returns A nullable physics imposter
  20266. */
  20267. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20268. /**
  20269. * Disposes the physics imposter
  20270. */
  20271. dispose(): void;
  20272. /**
  20273. * Sets the delta position
  20274. * @param position The delta position amount
  20275. */
  20276. setDeltaPosition(position: Vector3): void;
  20277. /**
  20278. * Sets the delta rotation
  20279. * @param rotation The delta rotation amount
  20280. */
  20281. setDeltaRotation(rotation: Quaternion): void;
  20282. /**
  20283. * Gets the box size of the physics imposter and stores the result in the input parameter
  20284. * @param result Stores the box size
  20285. * @returns The physics imposter
  20286. */
  20287. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20288. /**
  20289. * Gets the radius of the physics imposter
  20290. * @returns Radius of the physics imposter
  20291. */
  20292. getRadius(): number;
  20293. /**
  20294. * Sync a bone with this impostor
  20295. * @param bone The bone to sync to the impostor.
  20296. * @param boneMesh The mesh that the bone is influencing.
  20297. * @param jointPivot The pivot of the joint / bone in local space.
  20298. * @param distToJoint Optional distance from the impostor to the joint.
  20299. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20300. */
  20301. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20302. /**
  20303. * Sync impostor to a bone
  20304. * @param bone The bone that the impostor will be synced to.
  20305. * @param boneMesh The mesh that the bone is influencing.
  20306. * @param jointPivot The pivot of the joint / bone in local space.
  20307. * @param distToJoint Optional distance from the impostor to the joint.
  20308. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20309. * @param boneAxis Optional vector3 axis the bone is aligned with
  20310. */
  20311. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20312. /**
  20313. * No-Imposter type
  20314. */
  20315. static NoImpostor: number;
  20316. /**
  20317. * Sphere-Imposter type
  20318. */
  20319. static SphereImpostor: number;
  20320. /**
  20321. * Box-Imposter type
  20322. */
  20323. static BoxImpostor: number;
  20324. /**
  20325. * Plane-Imposter type
  20326. */
  20327. static PlaneImpostor: number;
  20328. /**
  20329. * Mesh-imposter type
  20330. */
  20331. static MeshImpostor: number;
  20332. /**
  20333. * Cylinder-Imposter type
  20334. */
  20335. static CylinderImpostor: number;
  20336. /**
  20337. * Particle-Imposter type
  20338. */
  20339. static ParticleImpostor: number;
  20340. /**
  20341. * Heightmap-Imposter type
  20342. */
  20343. static HeightmapImpostor: number;
  20344. }
  20345. }
  20346. declare module "babylonjs/Meshes/mesh" {
  20347. import { Observable } from "babylonjs/Misc/observable";
  20348. import { IAnimatable } from "babylonjs/Misc/tools";
  20349. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20350. import { Camera } from "babylonjs/Cameras/camera";
  20351. import { Scene } from "babylonjs/scene";
  20352. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20353. import { Engine } from "babylonjs/Engines/engine";
  20354. import { Node } from "babylonjs/node";
  20355. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20356. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20357. import { Buffer } from "babylonjs/Meshes/buffer";
  20358. import { Geometry } from "babylonjs/Meshes/geometry";
  20359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20360. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20361. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20362. import { Effect } from "babylonjs/Materials/effect";
  20363. import { Material } from "babylonjs/Materials/material";
  20364. import { Skeleton } from "babylonjs/Bones/skeleton";
  20365. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20366. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20367. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20368. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20369. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20370. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20371. /**
  20372. * Class used to represent a specific level of detail of a mesh
  20373. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20374. */
  20375. export class MeshLODLevel {
  20376. /** Defines the distance where this level should star being displayed */
  20377. distance: number;
  20378. /** Defines the mesh to use to render this level */
  20379. mesh: Nullable<Mesh>;
  20380. /**
  20381. * Creates a new LOD level
  20382. * @param distance defines the distance where this level should star being displayed
  20383. * @param mesh defines the mesh to use to render this level
  20384. */
  20385. constructor(
  20386. /** Defines the distance where this level should star being displayed */
  20387. distance: number,
  20388. /** Defines the mesh to use to render this level */
  20389. mesh: Nullable<Mesh>);
  20390. }
  20391. /**
  20392. * @hidden
  20393. **/
  20394. export class _CreationDataStorage {
  20395. closePath?: boolean;
  20396. closeArray?: boolean;
  20397. idx: number[];
  20398. dashSize: number;
  20399. gapSize: number;
  20400. path3D: Path3D;
  20401. pathArray: Vector3[][];
  20402. arc: number;
  20403. radius: number;
  20404. cap: number;
  20405. tessellation: number;
  20406. }
  20407. /**
  20408. * @hidden
  20409. **/
  20410. class _InstanceDataStorage {
  20411. visibleInstances: any;
  20412. renderIdForInstances: number[];
  20413. batchCache: _InstancesBatch;
  20414. instancesBufferSize: number;
  20415. instancesBuffer: Nullable<Buffer>;
  20416. instancesData: Float32Array;
  20417. overridenInstanceCount: number;
  20418. }
  20419. /**
  20420. * @hidden
  20421. **/
  20422. export class _InstancesBatch {
  20423. mustReturn: boolean;
  20424. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20425. renderSelf: boolean[];
  20426. }
  20427. /**
  20428. * Class used to represent renderable models
  20429. */
  20430. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20431. /**
  20432. * Mesh side orientation : usually the external or front surface
  20433. */
  20434. static readonly FRONTSIDE: number;
  20435. /**
  20436. * Mesh side orientation : usually the internal or back surface
  20437. */
  20438. static readonly BACKSIDE: number;
  20439. /**
  20440. * Mesh side orientation : both internal and external or front and back surfaces
  20441. */
  20442. static readonly DOUBLESIDE: number;
  20443. /**
  20444. * Mesh side orientation : by default, `FRONTSIDE`
  20445. */
  20446. static readonly DEFAULTSIDE: number;
  20447. /**
  20448. * Mesh cap setting : no cap
  20449. */
  20450. static readonly NO_CAP: number;
  20451. /**
  20452. * Mesh cap setting : one cap at the beginning of the mesh
  20453. */
  20454. static readonly CAP_START: number;
  20455. /**
  20456. * Mesh cap setting : one cap at the end of the mesh
  20457. */
  20458. static readonly CAP_END: number;
  20459. /**
  20460. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20461. */
  20462. static readonly CAP_ALL: number;
  20463. /**
  20464. * Gets the default side orientation.
  20465. * @param orientation the orientation to value to attempt to get
  20466. * @returns the default orientation
  20467. * @hidden
  20468. */
  20469. static _GetDefaultSideOrientation(orientation?: number): number;
  20470. private _onBeforeRenderObservable;
  20471. private _onBeforeBindObservable;
  20472. private _onAfterRenderObservable;
  20473. private _onBeforeDrawObservable;
  20474. /**
  20475. * An event triggered before rendering the mesh
  20476. */
  20477. readonly onBeforeRenderObservable: Observable<Mesh>;
  20478. /**
  20479. * An event triggered before binding the mesh
  20480. */
  20481. readonly onBeforeBindObservable: Observable<Mesh>;
  20482. /**
  20483. * An event triggered after rendering the mesh
  20484. */
  20485. readonly onAfterRenderObservable: Observable<Mesh>;
  20486. /**
  20487. * An event triggered before drawing the mesh
  20488. */
  20489. readonly onBeforeDrawObservable: Observable<Mesh>;
  20490. private _onBeforeDrawObserver;
  20491. /**
  20492. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20493. */
  20494. onBeforeDraw: () => void;
  20495. /**
  20496. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20497. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20498. */
  20499. delayLoadState: number;
  20500. /**
  20501. * Gets the list of instances created from this mesh
  20502. * it is not supposed to be modified manually.
  20503. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20504. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20505. */
  20506. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  20507. /**
  20508. * Gets the file containing delay loading data for this mesh
  20509. */
  20510. delayLoadingFile: string;
  20511. /** @hidden */
  20512. _binaryInfo: any;
  20513. private _LODLevels;
  20514. /**
  20515. * User defined function used to change how LOD level selection is done
  20516. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20517. */
  20518. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20519. private _morphTargetManager;
  20520. /**
  20521. * Gets or sets the morph target manager
  20522. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20523. */
  20524. morphTargetManager: Nullable<MorphTargetManager>;
  20525. /** @hidden */
  20526. _creationDataStorage: Nullable<_CreationDataStorage>;
  20527. /** @hidden */
  20528. _geometry: Nullable<Geometry>;
  20529. /** @hidden */
  20530. _delayInfo: Array<string>;
  20531. /** @hidden */
  20532. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20533. /** @hidden */
  20534. _instanceDataStorage: _InstanceDataStorage;
  20535. private _effectiveMaterial;
  20536. /** @hidden */
  20537. _shouldGenerateFlatShading: boolean;
  20538. private _preActivateId;
  20539. /** @hidden */
  20540. _originalBuilderSideOrientation: number;
  20541. /**
  20542. * Use this property to change the original side orientation defined at construction time
  20543. */
  20544. overrideMaterialSideOrientation: Nullable<number>;
  20545. private _areNormalsFrozen;
  20546. private _sourcePositions;
  20547. private _sourceNormals;
  20548. private _source;
  20549. private meshMap;
  20550. /**
  20551. * Gets the source mesh (the one used to clone this one from)
  20552. */
  20553. readonly source: Nullable<Mesh>;
  20554. /**
  20555. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20556. */
  20557. isUnIndexed: boolean;
  20558. /**
  20559. * @constructor
  20560. * @param name The value used by scene.getMeshByName() to do a lookup.
  20561. * @param scene The scene to add this mesh to.
  20562. * @param parent The parent of this mesh, if it has one
  20563. * @param source An optional Mesh from which geometry is shared, cloned.
  20564. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20565. * When false, achieved by calling a clone(), also passing False.
  20566. * This will make creation of children, recursive.
  20567. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20568. */
  20569. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20570. /**
  20571. * Gets the class name
  20572. * @returns the string "Mesh".
  20573. */
  20574. getClassName(): string;
  20575. /** @hidden */
  20576. readonly _isMesh: boolean;
  20577. /**
  20578. * Returns a description of this mesh
  20579. * @param fullDetails define if full details about this mesh must be used
  20580. * @returns a descriptive string representing this mesh
  20581. */
  20582. toString(fullDetails?: boolean): string;
  20583. /** @hidden */
  20584. _unBindEffect(): void;
  20585. /**
  20586. * Gets a boolean indicating if this mesh has LOD
  20587. */
  20588. readonly hasLODLevels: boolean;
  20589. /**
  20590. * Gets the list of MeshLODLevel associated with the current mesh
  20591. * @returns an array of MeshLODLevel
  20592. */
  20593. getLODLevels(): MeshLODLevel[];
  20594. private _sortLODLevels;
  20595. /**
  20596. * Add a mesh as LOD level triggered at the given distance.
  20597. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20598. * @param distance The distance from the center of the object to show this level
  20599. * @param mesh The mesh to be added as LOD level (can be null)
  20600. * @return This mesh (for chaining)
  20601. */
  20602. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20603. /**
  20604. * Returns the LOD level mesh at the passed distance or null if not found.
  20605. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20606. * @param distance The distance from the center of the object to show this level
  20607. * @returns a Mesh or `null`
  20608. */
  20609. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20610. /**
  20611. * Remove a mesh from the LOD array
  20612. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20613. * @param mesh defines the mesh to be removed
  20614. * @return This mesh (for chaining)
  20615. */
  20616. removeLODLevel(mesh: Mesh): Mesh;
  20617. /**
  20618. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20619. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20620. * @param camera defines the camera to use to compute distance
  20621. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20622. * @return This mesh (for chaining)
  20623. */
  20624. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20625. /**
  20626. * Gets the mesh internal Geometry object
  20627. */
  20628. readonly geometry: Nullable<Geometry>;
  20629. /**
  20630. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20631. * @returns the total number of vertices
  20632. */
  20633. getTotalVertices(): number;
  20634. /**
  20635. * Returns the content of an associated vertex buffer
  20636. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20637. * - VertexBuffer.PositionKind
  20638. * - VertexBuffer.UVKind
  20639. * - VertexBuffer.UV2Kind
  20640. * - VertexBuffer.UV3Kind
  20641. * - VertexBuffer.UV4Kind
  20642. * - VertexBuffer.UV5Kind
  20643. * - VertexBuffer.UV6Kind
  20644. * - VertexBuffer.ColorKind
  20645. * - VertexBuffer.MatricesIndicesKind
  20646. * - VertexBuffer.MatricesIndicesExtraKind
  20647. * - VertexBuffer.MatricesWeightsKind
  20648. * - VertexBuffer.MatricesWeightsExtraKind
  20649. * @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
  20650. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20651. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20652. */
  20653. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20654. /**
  20655. * Returns the mesh VertexBuffer object from the requested `kind`
  20656. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20657. * - VertexBuffer.PositionKind
  20658. * - VertexBuffer.UVKind
  20659. * - VertexBuffer.UV2Kind
  20660. * - VertexBuffer.UV3Kind
  20661. * - VertexBuffer.UV4Kind
  20662. * - VertexBuffer.UV5Kind
  20663. * - VertexBuffer.UV6Kind
  20664. * - VertexBuffer.ColorKind
  20665. * - VertexBuffer.MatricesIndicesKind
  20666. * - VertexBuffer.MatricesIndicesExtraKind
  20667. * - VertexBuffer.MatricesWeightsKind
  20668. * - VertexBuffer.MatricesWeightsExtraKind
  20669. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20670. */
  20671. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20672. /**
  20673. * Tests if a specific vertex buffer is associated with this mesh
  20674. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20675. * - VertexBuffer.PositionKind
  20676. * - VertexBuffer.UVKind
  20677. * - VertexBuffer.UV2Kind
  20678. * - VertexBuffer.UV3Kind
  20679. * - VertexBuffer.UV4Kind
  20680. * - VertexBuffer.UV5Kind
  20681. * - VertexBuffer.UV6Kind
  20682. * - VertexBuffer.ColorKind
  20683. * - VertexBuffer.MatricesIndicesKind
  20684. * - VertexBuffer.MatricesIndicesExtraKind
  20685. * - VertexBuffer.MatricesWeightsKind
  20686. * - VertexBuffer.MatricesWeightsExtraKind
  20687. * @returns a boolean
  20688. */
  20689. isVerticesDataPresent(kind: string): boolean;
  20690. /**
  20691. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20692. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20693. * - VertexBuffer.PositionKind
  20694. * - VertexBuffer.UVKind
  20695. * - VertexBuffer.UV2Kind
  20696. * - VertexBuffer.UV3Kind
  20697. * - VertexBuffer.UV4Kind
  20698. * - VertexBuffer.UV5Kind
  20699. * - VertexBuffer.UV6Kind
  20700. * - VertexBuffer.ColorKind
  20701. * - VertexBuffer.MatricesIndicesKind
  20702. * - VertexBuffer.MatricesIndicesExtraKind
  20703. * - VertexBuffer.MatricesWeightsKind
  20704. * - VertexBuffer.MatricesWeightsExtraKind
  20705. * @returns a boolean
  20706. */
  20707. isVertexBufferUpdatable(kind: string): boolean;
  20708. /**
  20709. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20710. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20711. * - VertexBuffer.PositionKind
  20712. * - VertexBuffer.UVKind
  20713. * - VertexBuffer.UV2Kind
  20714. * - VertexBuffer.UV3Kind
  20715. * - VertexBuffer.UV4Kind
  20716. * - VertexBuffer.UV5Kind
  20717. * - VertexBuffer.UV6Kind
  20718. * - VertexBuffer.ColorKind
  20719. * - VertexBuffer.MatricesIndicesKind
  20720. * - VertexBuffer.MatricesIndicesExtraKind
  20721. * - VertexBuffer.MatricesWeightsKind
  20722. * - VertexBuffer.MatricesWeightsExtraKind
  20723. * @returns an array of strings
  20724. */
  20725. getVerticesDataKinds(): string[];
  20726. /**
  20727. * Returns a positive integer : the total number of indices in this mesh geometry.
  20728. * @returns the numner of indices or zero if the mesh has no geometry.
  20729. */
  20730. getTotalIndices(): number;
  20731. /**
  20732. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20733. * @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.
  20734. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20735. * @returns the indices array or an empty array if the mesh has no geometry
  20736. */
  20737. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20738. readonly isBlocked: boolean;
  20739. /**
  20740. * Determine if the current mesh is ready to be rendered
  20741. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20742. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20743. * @returns true if all associated assets are ready (material, textures, shaders)
  20744. */
  20745. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20746. /**
  20747. * 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.
  20748. */
  20749. readonly areNormalsFrozen: boolean;
  20750. /**
  20751. * 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.
  20752. * @returns the current mesh
  20753. */
  20754. freezeNormals(): Mesh;
  20755. /**
  20756. * 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
  20757. * @returns the current mesh
  20758. */
  20759. unfreezeNormals(): Mesh;
  20760. /**
  20761. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20762. */
  20763. overridenInstanceCount: number;
  20764. /** @hidden */
  20765. _preActivate(): Mesh;
  20766. /** @hidden */
  20767. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20768. /** @hidden */
  20769. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20770. /**
  20771. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20772. * This means the mesh underlying bounding box and sphere are recomputed.
  20773. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20774. * @returns the current mesh
  20775. */
  20776. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20777. /** @hidden */
  20778. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20779. /**
  20780. * This function will subdivide the mesh into multiple submeshes
  20781. * @param count defines the expected number of submeshes
  20782. */
  20783. subdivide(count: number): void;
  20784. /**
  20785. * Copy a FloatArray into a specific associated vertex buffer
  20786. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20787. * - VertexBuffer.PositionKind
  20788. * - VertexBuffer.UVKind
  20789. * - VertexBuffer.UV2Kind
  20790. * - VertexBuffer.UV3Kind
  20791. * - VertexBuffer.UV4Kind
  20792. * - VertexBuffer.UV5Kind
  20793. * - VertexBuffer.UV6Kind
  20794. * - VertexBuffer.ColorKind
  20795. * - VertexBuffer.MatricesIndicesKind
  20796. * - VertexBuffer.MatricesIndicesExtraKind
  20797. * - VertexBuffer.MatricesWeightsKind
  20798. * - VertexBuffer.MatricesWeightsExtraKind
  20799. * @param data defines the data source
  20800. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20801. * @param stride defines the data stride size (can be null)
  20802. * @returns the current mesh
  20803. */
  20804. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20805. /**
  20806. * Flags an associated vertex buffer as updatable
  20807. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20808. * - VertexBuffer.PositionKind
  20809. * - VertexBuffer.UVKind
  20810. * - VertexBuffer.UV2Kind
  20811. * - VertexBuffer.UV3Kind
  20812. * - VertexBuffer.UV4Kind
  20813. * - VertexBuffer.UV5Kind
  20814. * - VertexBuffer.UV6Kind
  20815. * - VertexBuffer.ColorKind
  20816. * - VertexBuffer.MatricesIndicesKind
  20817. * - VertexBuffer.MatricesIndicesExtraKind
  20818. * - VertexBuffer.MatricesWeightsKind
  20819. * - VertexBuffer.MatricesWeightsExtraKind
  20820. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20821. */
  20822. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20823. /**
  20824. * Sets the mesh global Vertex Buffer
  20825. * @param buffer defines the buffer to use
  20826. * @returns the current mesh
  20827. */
  20828. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20829. /**
  20830. * Update a specific associated vertex buffer
  20831. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20832. * - VertexBuffer.PositionKind
  20833. * - VertexBuffer.UVKind
  20834. * - VertexBuffer.UV2Kind
  20835. * - VertexBuffer.UV3Kind
  20836. * - VertexBuffer.UV4Kind
  20837. * - VertexBuffer.UV5Kind
  20838. * - VertexBuffer.UV6Kind
  20839. * - VertexBuffer.ColorKind
  20840. * - VertexBuffer.MatricesIndicesKind
  20841. * - VertexBuffer.MatricesIndicesExtraKind
  20842. * - VertexBuffer.MatricesWeightsKind
  20843. * - VertexBuffer.MatricesWeightsExtraKind
  20844. * @param data defines the data source
  20845. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20846. * @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)
  20847. * @returns the current mesh
  20848. */
  20849. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20850. /**
  20851. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20852. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20853. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20854. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20855. * @returns the current mesh
  20856. */
  20857. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20858. /**
  20859. * Creates a un-shared specific occurence of the geometry for the mesh.
  20860. * @returns the current mesh
  20861. */
  20862. makeGeometryUnique(): Mesh;
  20863. /**
  20864. * Set the index buffer of this mesh
  20865. * @param indices defines the source data
  20866. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20867. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20868. * @returns the current mesh
  20869. */
  20870. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20871. /**
  20872. * Update the current index buffer
  20873. * @param indices defines the source data
  20874. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20875. * @returns the current mesh
  20876. */
  20877. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20878. /**
  20879. * Invert the geometry to move from a right handed system to a left handed one.
  20880. * @returns the current mesh
  20881. */
  20882. toLeftHanded(): Mesh;
  20883. /** @hidden */
  20884. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20885. /** @hidden */
  20886. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20887. /**
  20888. * Registers for this mesh a javascript function called just before the rendering process
  20889. * @param func defines the function to call before rendering this mesh
  20890. * @returns the current mesh
  20891. */
  20892. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20893. /**
  20894. * Disposes a previously registered javascript function called before the rendering
  20895. * @param func defines the function to remove
  20896. * @returns the current mesh
  20897. */
  20898. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20899. /**
  20900. * Registers for this mesh a javascript function called just after the rendering is complete
  20901. * @param func defines the function to call after rendering this mesh
  20902. * @returns the current mesh
  20903. */
  20904. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20905. /**
  20906. * Disposes a previously registered javascript function called after the rendering.
  20907. * @param func defines the function to remove
  20908. * @returns the current mesh
  20909. */
  20910. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20911. /** @hidden */
  20912. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20913. /** @hidden */
  20914. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20915. /** @hidden */
  20916. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20917. /**
  20918. * 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
  20919. * @param subMesh defines the subMesh to render
  20920. * @param enableAlphaMode defines if alpha mode can be changed
  20921. * @returns the current mesh
  20922. */
  20923. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20924. private _onBeforeDraw;
  20925. /**
  20926. * Renormalize the mesh and patch it up if there are no weights
  20927. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20928. * However in the case of zero weights then we set just a single influence to 1.
  20929. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20930. */
  20931. cleanMatrixWeights(): void;
  20932. private normalizeSkinFourWeights;
  20933. private normalizeSkinWeightsAndExtra;
  20934. /**
  20935. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20936. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20937. * the user know there was an issue with importing the mesh
  20938. * @returns a validation object with skinned, valid and report string
  20939. */
  20940. validateSkinning(): {
  20941. skinned: boolean;
  20942. valid: boolean;
  20943. report: string;
  20944. };
  20945. /** @hidden */
  20946. _checkDelayState(): Mesh;
  20947. private _queueLoad;
  20948. /**
  20949. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20950. * A mesh is in the frustum if its bounding box intersects the frustum
  20951. * @param frustumPlanes defines the frustum to test
  20952. * @returns true if the mesh is in the frustum planes
  20953. */
  20954. isInFrustum(frustumPlanes: Plane[]): boolean;
  20955. /**
  20956. * Sets the mesh material by the material or multiMaterial `id` property
  20957. * @param id is a string identifying the material or the multiMaterial
  20958. * @returns the current mesh
  20959. */
  20960. setMaterialByID(id: string): Mesh;
  20961. /**
  20962. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20963. * @returns an array of IAnimatable
  20964. */
  20965. getAnimatables(): IAnimatable[];
  20966. /**
  20967. * Modifies the mesh geometry according to the passed transformation matrix.
  20968. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20969. * The mesh normals are modified using the same transformation.
  20970. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20971. * @param transform defines the transform matrix to use
  20972. * @see http://doc.babylonjs.com/resources/baking_transformations
  20973. * @returns the current mesh
  20974. */
  20975. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20976. /**
  20977. * Modifies the mesh geometry according to its own current World Matrix.
  20978. * The mesh World Matrix is then reset.
  20979. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20980. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20981. * @see http://doc.babylonjs.com/resources/baking_transformations
  20982. * @returns the current mesh
  20983. */
  20984. bakeCurrentTransformIntoVertices(): Mesh;
  20985. /** @hidden */
  20986. readonly _positions: Nullable<Vector3[]>;
  20987. /** @hidden */
  20988. _resetPointsArrayCache(): Mesh;
  20989. /** @hidden */
  20990. _generatePointsArray(): boolean;
  20991. /**
  20992. * Returns a new Mesh object generated from the current mesh properties.
  20993. * This method must not get confused with createInstance()
  20994. * @param name is a string, the name given to the new mesh
  20995. * @param newParent can be any Node object (default `null`)
  20996. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20997. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20998. * @returns a new mesh
  20999. */
  21000. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21001. /**
  21002. * Releases resources associated with this mesh.
  21003. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21004. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21005. */
  21006. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21007. /**
  21008. * Modifies the mesh geometry according to a displacement map.
  21009. * 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.
  21010. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21011. * @param url is a string, the URL from the image file is to be downloaded.
  21012. * @param minHeight is the lower limit of the displacement.
  21013. * @param maxHeight is the upper limit of the displacement.
  21014. * @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.
  21015. * @param uvOffset is an optional vector2 used to offset UV.
  21016. * @param uvScale is an optional vector2 used to scale UV.
  21017. * @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.
  21018. * @returns the Mesh.
  21019. */
  21020. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21021. /**
  21022. * Modifies the mesh geometry according to a displacementMap buffer.
  21023. * 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.
  21024. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21025. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21026. * @param heightMapWidth is the width of the buffer image.
  21027. * @param heightMapHeight is the height of the buffer image.
  21028. * @param minHeight is the lower limit of the displacement.
  21029. * @param maxHeight is the upper limit of the displacement.
  21030. * @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.
  21031. * @param uvOffset is an optional vector2 used to offset UV.
  21032. * @param uvScale is an optional vector2 used to scale UV.
  21033. * @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.
  21034. * @returns the Mesh.
  21035. */
  21036. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21037. /**
  21038. * Modify the mesh to get a flat shading rendering.
  21039. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21040. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21041. * @returns current mesh
  21042. */
  21043. convertToFlatShadedMesh(): Mesh;
  21044. /**
  21045. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21046. * In other words, more vertices, no more indices and a single bigger VBO.
  21047. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21048. * @returns current mesh
  21049. */
  21050. convertToUnIndexedMesh(): Mesh;
  21051. /**
  21052. * Inverses facet orientations.
  21053. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21054. * @param flipNormals will also inverts the normals
  21055. * @returns current mesh
  21056. */
  21057. flipFaces(flipNormals?: boolean): Mesh;
  21058. /** @hidden */
  21059. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21060. /** @hidden */
  21061. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21062. /**
  21063. * Creates a new InstancedMesh object from the mesh model.
  21064. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21065. * @param name defines the name of the new instance
  21066. * @returns a new InstancedMesh
  21067. */
  21068. createInstance(name: string): InstancedMesh;
  21069. /**
  21070. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21071. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21072. * @returns the current mesh
  21073. */
  21074. synchronizeInstances(): Mesh;
  21075. /**
  21076. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21077. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21078. * This should be used together with the simplification to avoid disappearing triangles.
  21079. * @param successCallback an optional success callback to be called after the optimization finished.
  21080. * @returns the current mesh
  21081. */
  21082. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21083. /**
  21084. * Serialize current mesh
  21085. * @param serializationObject defines the object which will receive the serialization data
  21086. */
  21087. serialize(serializationObject: any): void;
  21088. /** @hidden */
  21089. _syncGeometryWithMorphTargetManager(): void;
  21090. /** @hidden */
  21091. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21092. /**
  21093. * Returns a new Mesh object parsed from the source provided.
  21094. * @param parsedMesh is the source
  21095. * @param scene defines the hosting scene
  21096. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21097. * @returns a new Mesh
  21098. */
  21099. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21100. /**
  21101. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21102. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21103. * @param name defines the name of the mesh to create
  21104. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21105. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21106. * @param closePath creates a seam between the first and the last points of each path of the path array
  21107. * @param offset is taken in account only if the `pathArray` is containing a single path
  21108. * @param scene defines the hosting scene
  21109. * @param updatable defines if the mesh must be flagged as updatable
  21110. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21111. * @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)
  21112. * @returns a new Mesh
  21113. */
  21114. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21115. /**
  21116. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21117. * @param name defines the name of the mesh to create
  21118. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21119. * @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
  21120. * @param scene defines the hosting scene
  21121. * @param updatable defines if the mesh must be flagged as updatable
  21122. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21123. * @returns a new Mesh
  21124. */
  21125. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21126. /**
  21127. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21128. * @param name defines the name of the mesh to create
  21129. * @param size sets the size (float) of each box side (default 1)
  21130. * @param scene defines the hosting scene
  21131. * @param updatable defines if the mesh must be flagged as updatable
  21132. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21133. * @returns a new Mesh
  21134. */
  21135. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21136. /**
  21137. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21138. * @param name defines the name of the mesh to create
  21139. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21140. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21141. * @param scene defines the hosting scene
  21142. * @param updatable defines if the mesh must be flagged as updatable
  21143. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21144. * @returns a new Mesh
  21145. */
  21146. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21147. /**
  21148. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21149. * @param name defines the name of the mesh to create
  21150. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21151. * @param diameterTop set the top cap diameter (floats, default 1)
  21152. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21153. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21154. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21155. * @param scene defines the hosting scene
  21156. * @param updatable defines if the mesh must be flagged as updatable
  21157. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21158. * @returns a new Mesh
  21159. */
  21160. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21161. /**
  21162. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21163. * @param name defines the name of the mesh to create
  21164. * @param diameter sets the diameter size (float) of the torus (default 1)
  21165. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21166. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21167. * @param scene defines the hosting scene
  21168. * @param updatable defines if the mesh must be flagged as updatable
  21169. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21170. * @returns a new Mesh
  21171. */
  21172. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21173. /**
  21174. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21175. * @param name defines the name of the mesh to create
  21176. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21177. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21178. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21179. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21180. * @param p the number of windings on X axis (positive integers, default 2)
  21181. * @param q the number of windings on Y axis (positive integers, default 3)
  21182. * @param scene defines the hosting scene
  21183. * @param updatable defines if the mesh must be flagged as updatable
  21184. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21185. * @returns a new Mesh
  21186. */
  21187. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21188. /**
  21189. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21190. * @param name defines the name of the mesh to create
  21191. * @param points is an array successive Vector3
  21192. * @param scene defines the hosting scene
  21193. * @param updatable defines if the mesh must be flagged as updatable
  21194. * @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).
  21195. * @returns a new Mesh
  21196. */
  21197. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21198. /**
  21199. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21200. * @param name defines the name of the mesh to create
  21201. * @param points is an array successive Vector3
  21202. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21203. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21204. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21205. * @param scene defines the hosting scene
  21206. * @param updatable defines if the mesh must be flagged as updatable
  21207. * @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)
  21208. * @returns a new Mesh
  21209. */
  21210. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21211. /**
  21212. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21213. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21214. * 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.
  21215. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21216. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21217. * Remember you can only change the shape positions, not their number when updating a polygon.
  21218. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21219. * @param name defines the name of the mesh to create
  21220. * @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
  21221. * @param scene defines the hosting scene
  21222. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21223. * @param updatable defines if the mesh must be flagged as updatable
  21224. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21225. * @param earcutInjection can be used to inject your own earcut reference
  21226. * @returns a new Mesh
  21227. */
  21228. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21229. /**
  21230. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21231. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21232. * @param name defines the name of the mesh to create
  21233. * @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
  21234. * @param depth defines the height of extrusion
  21235. * @param scene defines the hosting scene
  21236. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21237. * @param updatable defines if the mesh must be flagged as updatable
  21238. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21239. * @param earcutInjection can be used to inject your own earcut reference
  21240. * @returns a new Mesh
  21241. */
  21242. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21243. /**
  21244. * Creates an extruded shape mesh.
  21245. * 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
  21246. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21247. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21248. * @param name defines the name of the mesh to create
  21249. * @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
  21250. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21251. * @param scale is the value to scale the shape
  21252. * @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
  21253. * @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
  21254. * @param scene defines the hosting scene
  21255. * @param updatable defines if the mesh must be flagged as updatable
  21256. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21257. * @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)
  21258. * @returns a new Mesh
  21259. */
  21260. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21261. /**
  21262. * Creates an custom extruded shape mesh.
  21263. * The custom extrusion is a parametric shape.
  21264. * It has no predefined shape. Its final shape will depend on the input parameters.
  21265. * Please consider using the same method from the MeshBuilder class instead
  21266. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21267. * @param name defines the name of the mesh to create
  21268. * @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
  21269. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21270. * @param scaleFunction is a custom Javascript function called on each path point
  21271. * @param rotationFunction is a custom Javascript function called on each path point
  21272. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21273. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21274. * @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
  21275. * @param scene defines the hosting scene
  21276. * @param updatable defines if the mesh must be flagged as updatable
  21277. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21278. * @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)
  21279. * @returns a new Mesh
  21280. */
  21281. 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;
  21282. /**
  21283. * Creates lathe mesh.
  21284. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21285. * Please consider using the same method from the MeshBuilder class instead
  21286. * @param name defines the name of the mesh to create
  21287. * @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
  21288. * @param radius is the radius value of the lathe
  21289. * @param tessellation is the side number of the lathe.
  21290. * @param scene defines the hosting scene
  21291. * @param updatable defines if the mesh must be flagged as updatable
  21292. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21293. * @returns a new Mesh
  21294. */
  21295. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21296. /**
  21297. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21298. * @param name defines the name of the mesh to create
  21299. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21300. * @param scene defines the hosting scene
  21301. * @param updatable defines if the mesh must be flagged as updatable
  21302. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21303. * @returns a new Mesh
  21304. */
  21305. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21306. /**
  21307. * Creates a ground mesh.
  21308. * Please consider using the same method from the MeshBuilder class instead
  21309. * @param name defines the name of the mesh to create
  21310. * @param width set the width of the ground
  21311. * @param height set the height of the ground
  21312. * @param subdivisions sets the number of subdivisions per side
  21313. * @param scene defines the hosting scene
  21314. * @param updatable defines if the mesh must be flagged as updatable
  21315. * @returns a new Mesh
  21316. */
  21317. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21318. /**
  21319. * Creates a tiled ground mesh.
  21320. * Please consider using the same method from the MeshBuilder class instead
  21321. * @param name defines the name of the mesh to create
  21322. * @param xmin set the ground minimum X coordinate
  21323. * @param zmin set the ground minimum Y coordinate
  21324. * @param xmax set the ground maximum X coordinate
  21325. * @param zmax set the ground maximum Z coordinate
  21326. * @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
  21327. * @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
  21328. * @param scene defines the hosting scene
  21329. * @param updatable defines if the mesh must be flagged as updatable
  21330. * @returns a new Mesh
  21331. */
  21332. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21333. w: number;
  21334. h: number;
  21335. }, precision: {
  21336. w: number;
  21337. h: number;
  21338. }, scene: Scene, updatable?: boolean): Mesh;
  21339. /**
  21340. * Creates a ground mesh from a height map.
  21341. * Please consider using the same method from the MeshBuilder class instead
  21342. * @see http://doc.babylonjs.com/babylon101/height_map
  21343. * @param name defines the name of the mesh to create
  21344. * @param url sets the URL of the height map image resource
  21345. * @param width set the ground width size
  21346. * @param height set the ground height size
  21347. * @param subdivisions sets the number of subdivision per side
  21348. * @param minHeight is the minimum altitude on the ground
  21349. * @param maxHeight is the maximum altitude on the ground
  21350. * @param scene defines the hosting scene
  21351. * @param updatable defines if the mesh must be flagged as updatable
  21352. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21353. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21354. * @returns a new Mesh
  21355. */
  21356. 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;
  21357. /**
  21358. * Creates a tube mesh.
  21359. * The tube is a parametric shape.
  21360. * It has no predefined shape. Its final shape will depend on the input parameters.
  21361. * Please consider using the same method from the MeshBuilder class instead
  21362. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21363. * @param name defines the name of the mesh to create
  21364. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21365. * @param radius sets the tube radius size
  21366. * @param tessellation is the number of sides on the tubular surface
  21367. * @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
  21368. * @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
  21369. * @param scene defines the hosting scene
  21370. * @param updatable defines if the mesh must be flagged as updatable
  21371. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21372. * @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)
  21373. * @returns a new Mesh
  21374. */
  21375. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21376. (i: number, distance: number): number;
  21377. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21378. /**
  21379. * Creates a polyhedron mesh.
  21380. * Please consider using the same method from the MeshBuilder class instead.
  21381. * * 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
  21382. * * The parameter `size` (positive float, default 1) sets the polygon size
  21383. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21384. * * 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`
  21385. * * 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
  21386. * * 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)`)
  21387. * * 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
  21388. * * 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
  21389. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21390. * * If you create a double-sided mesh, you can choose what parts of 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
  21391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21392. * @param name defines the name of the mesh to create
  21393. * @param options defines the options used to create the mesh
  21394. * @param scene defines the hosting scene
  21395. * @returns a new Mesh
  21396. */
  21397. static CreatePolyhedron(name: string, options: {
  21398. type?: number;
  21399. size?: number;
  21400. sizeX?: number;
  21401. sizeY?: number;
  21402. sizeZ?: number;
  21403. custom?: any;
  21404. faceUV?: Vector4[];
  21405. faceColors?: Color4[];
  21406. updatable?: boolean;
  21407. sideOrientation?: number;
  21408. }, scene: Scene): Mesh;
  21409. /**
  21410. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21411. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21412. * * 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`)
  21413. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21414. * * 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
  21415. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21416. * * If you create a double-sided mesh, you can choose what parts of 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
  21417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21418. * @param name defines the name of the mesh
  21419. * @param options defines the options used to create the mesh
  21420. * @param scene defines the hosting scene
  21421. * @returns a new Mesh
  21422. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21423. */
  21424. static CreateIcoSphere(name: string, options: {
  21425. radius?: number;
  21426. flat?: boolean;
  21427. subdivisions?: number;
  21428. sideOrientation?: number;
  21429. updatable?: boolean;
  21430. }, scene: Scene): Mesh;
  21431. /**
  21432. * Creates a decal mesh.
  21433. * Please consider using the same method from the MeshBuilder class instead.
  21434. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21435. * @param name defines the name of the mesh
  21436. * @param sourceMesh defines the mesh receiving the decal
  21437. * @param position sets the position of the decal in world coordinates
  21438. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21439. * @param size sets the decal scaling
  21440. * @param angle sets the angle to rotate the decal
  21441. * @returns a new Mesh
  21442. */
  21443. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21444. /**
  21445. * Prepare internal position array for software CPU skinning
  21446. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21447. */
  21448. setPositionsForCPUSkinning(): Float32Array;
  21449. /**
  21450. * Prepare internal normal array for software CPU skinning
  21451. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21452. */
  21453. setNormalsForCPUSkinning(): Float32Array;
  21454. /**
  21455. * Updates the vertex buffer by applying transformation from the bones
  21456. * @param skeleton defines the skeleton to apply to current mesh
  21457. * @returns the current mesh
  21458. */
  21459. applySkeleton(skeleton: Skeleton): Mesh;
  21460. /**
  21461. * 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
  21462. * @param meshes defines the list of meshes to scan
  21463. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21464. */
  21465. static MinMax(meshes: AbstractMesh[]): {
  21466. min: Vector3;
  21467. max: Vector3;
  21468. };
  21469. /**
  21470. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21471. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21472. * @returns a vector3
  21473. */
  21474. static Center(meshesOrMinMaxVector: {
  21475. min: Vector3;
  21476. max: Vector3;
  21477. } | AbstractMesh[]): Vector3;
  21478. /**
  21479. * Merge the array of meshes into a single mesh for performance reasons.
  21480. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21481. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21482. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21483. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21484. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21485. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21486. * @returns a new mesh
  21487. */
  21488. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21489. /** @hidden */
  21490. addInstance(instance: InstancedMesh): void;
  21491. /** @hidden */
  21492. removeInstance(instance: InstancedMesh): void;
  21493. }
  21494. }
  21495. declare module "babylonjs/Materials/material" {
  21496. import { IAnimatable } from "babylonjs/Misc/tools";
  21497. import { SmartArray } from "babylonjs/Misc/smartArray";
  21498. import { Observable } from "babylonjs/Misc/observable";
  21499. import { Nullable } from "babylonjs/types";
  21500. import { Scene } from "babylonjs/scene";
  21501. import { Matrix } from "babylonjs/Maths/math";
  21502. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21504. import { Mesh } from "babylonjs/Meshes/mesh";
  21505. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21506. import { Effect } from "babylonjs/Materials/effect";
  21507. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21508. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21509. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21510. import { Animation } from "babylonjs/Animations/animation";
  21511. /**
  21512. * Base class for the main features of a material in Babylon.js
  21513. */
  21514. export class Material implements IAnimatable {
  21515. /**
  21516. * Returns the triangle fill mode
  21517. */
  21518. static readonly TriangleFillMode: number;
  21519. /**
  21520. * Returns the wireframe mode
  21521. */
  21522. static readonly WireFrameFillMode: number;
  21523. /**
  21524. * Returns the point fill mode
  21525. */
  21526. static readonly PointFillMode: number;
  21527. /**
  21528. * Returns the point list draw mode
  21529. */
  21530. static readonly PointListDrawMode: number;
  21531. /**
  21532. * Returns the line list draw mode
  21533. */
  21534. static readonly LineListDrawMode: number;
  21535. /**
  21536. * Returns the line loop draw mode
  21537. */
  21538. static readonly LineLoopDrawMode: number;
  21539. /**
  21540. * Returns the line strip draw mode
  21541. */
  21542. static readonly LineStripDrawMode: number;
  21543. /**
  21544. * Returns the triangle strip draw mode
  21545. */
  21546. static readonly TriangleStripDrawMode: number;
  21547. /**
  21548. * Returns the triangle fan draw mode
  21549. */
  21550. static readonly TriangleFanDrawMode: number;
  21551. /**
  21552. * Stores the clock-wise side orientation
  21553. */
  21554. static readonly ClockWiseSideOrientation: number;
  21555. /**
  21556. * Stores the counter clock-wise side orientation
  21557. */
  21558. static readonly CounterClockWiseSideOrientation: number;
  21559. /**
  21560. * The dirty texture flag value
  21561. */
  21562. static readonly TextureDirtyFlag: number;
  21563. /**
  21564. * The dirty light flag value
  21565. */
  21566. static readonly LightDirtyFlag: number;
  21567. /**
  21568. * The dirty fresnel flag value
  21569. */
  21570. static readonly FresnelDirtyFlag: number;
  21571. /**
  21572. * The dirty attribute flag value
  21573. */
  21574. static readonly AttributesDirtyFlag: number;
  21575. /**
  21576. * The dirty misc flag value
  21577. */
  21578. static readonly MiscDirtyFlag: number;
  21579. /**
  21580. * The all dirty flag value
  21581. */
  21582. static readonly AllDirtyFlag: number;
  21583. /**
  21584. * The ID of the material
  21585. */
  21586. id: string;
  21587. /**
  21588. * Gets or sets the unique id of the material
  21589. */
  21590. uniqueId: number;
  21591. /**
  21592. * The name of the material
  21593. */
  21594. name: string;
  21595. /**
  21596. * Gets or sets user defined metadata
  21597. */
  21598. metadata: any;
  21599. /**
  21600. * For internal use only. Please do not use.
  21601. */
  21602. reservedDataStore: any;
  21603. /**
  21604. * Specifies if the ready state should be checked on each call
  21605. */
  21606. checkReadyOnEveryCall: boolean;
  21607. /**
  21608. * Specifies if the ready state should be checked once
  21609. */
  21610. checkReadyOnlyOnce: boolean;
  21611. /**
  21612. * The state of the material
  21613. */
  21614. state: string;
  21615. /**
  21616. * The alpha value of the material
  21617. */
  21618. protected _alpha: number;
  21619. /**
  21620. * Sets the alpha value of the material
  21621. */
  21622. /**
  21623. * Gets the alpha value of the material
  21624. */
  21625. alpha: number;
  21626. /**
  21627. * Specifies if back face culling is enabled
  21628. */
  21629. protected _backFaceCulling: boolean;
  21630. /**
  21631. * Sets the back-face culling state
  21632. */
  21633. /**
  21634. * Gets the back-face culling state
  21635. */
  21636. backFaceCulling: boolean;
  21637. /**
  21638. * Stores the value for side orientation
  21639. */
  21640. sideOrientation: number;
  21641. /**
  21642. * Callback triggered when the material is compiled
  21643. */
  21644. onCompiled: (effect: Effect) => void;
  21645. /**
  21646. * Callback triggered when an error occurs
  21647. */
  21648. onError: (effect: Effect, errors: string) => void;
  21649. /**
  21650. * Callback triggered to get the render target textures
  21651. */
  21652. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21653. /**
  21654. * Gets a boolean indicating that current material needs to register RTT
  21655. */
  21656. readonly hasRenderTargetTextures: boolean;
  21657. /**
  21658. * Specifies if the material should be serialized
  21659. */
  21660. doNotSerialize: boolean;
  21661. /**
  21662. * @hidden
  21663. */
  21664. _storeEffectOnSubMeshes: boolean;
  21665. /**
  21666. * Stores the animations for the material
  21667. */
  21668. animations: Array<Animation>;
  21669. /**
  21670. * An event triggered when the material is disposed
  21671. */
  21672. onDisposeObservable: Observable<Material>;
  21673. /**
  21674. * An observer which watches for dispose events
  21675. */
  21676. private _onDisposeObserver;
  21677. private _onUnBindObservable;
  21678. /**
  21679. * Called during a dispose event
  21680. */
  21681. onDispose: () => void;
  21682. private _onBindObservable;
  21683. /**
  21684. * An event triggered when the material is bound
  21685. */
  21686. readonly onBindObservable: Observable<AbstractMesh>;
  21687. /**
  21688. * An observer which watches for bind events
  21689. */
  21690. private _onBindObserver;
  21691. /**
  21692. * Called during a bind event
  21693. */
  21694. onBind: (Mesh: AbstractMesh) => void;
  21695. /**
  21696. * An event triggered when the material is unbound
  21697. */
  21698. readonly onUnBindObservable: Observable<Material>;
  21699. /**
  21700. * Stores the value of the alpha mode
  21701. */
  21702. private _alphaMode;
  21703. /**
  21704. * Sets the value of the alpha mode.
  21705. *
  21706. * | Value | Type | Description |
  21707. * | --- | --- | --- |
  21708. * | 0 | ALPHA_DISABLE | |
  21709. * | 1 | ALPHA_ADD | |
  21710. * | 2 | ALPHA_COMBINE | |
  21711. * | 3 | ALPHA_SUBTRACT | |
  21712. * | 4 | ALPHA_MULTIPLY | |
  21713. * | 5 | ALPHA_MAXIMIZED | |
  21714. * | 6 | ALPHA_ONEONE | |
  21715. * | 7 | ALPHA_PREMULTIPLIED | |
  21716. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21717. * | 9 | ALPHA_INTERPOLATE | |
  21718. * | 10 | ALPHA_SCREENMODE | |
  21719. *
  21720. */
  21721. /**
  21722. * Gets the value of the alpha mode
  21723. */
  21724. alphaMode: number;
  21725. /**
  21726. * Stores the state of the need depth pre-pass value
  21727. */
  21728. private _needDepthPrePass;
  21729. /**
  21730. * Sets the need depth pre-pass value
  21731. */
  21732. /**
  21733. * Gets the depth pre-pass value
  21734. */
  21735. needDepthPrePass: boolean;
  21736. /**
  21737. * Specifies if depth writing should be disabled
  21738. */
  21739. disableDepthWrite: boolean;
  21740. /**
  21741. * Specifies if depth writing should be forced
  21742. */
  21743. forceDepthWrite: boolean;
  21744. /**
  21745. * Specifies if there should be a separate pass for culling
  21746. */
  21747. separateCullingPass: boolean;
  21748. /**
  21749. * Stores the state specifing if fog should be enabled
  21750. */
  21751. private _fogEnabled;
  21752. /**
  21753. * Sets the state for enabling fog
  21754. */
  21755. /**
  21756. * Gets the value of the fog enabled state
  21757. */
  21758. fogEnabled: boolean;
  21759. /**
  21760. * Stores the size of points
  21761. */
  21762. pointSize: number;
  21763. /**
  21764. * Stores the z offset value
  21765. */
  21766. zOffset: number;
  21767. /**
  21768. * Gets a value specifying if wireframe mode is enabled
  21769. */
  21770. /**
  21771. * Sets the state of wireframe mode
  21772. */
  21773. wireframe: boolean;
  21774. /**
  21775. * Gets the value specifying if point clouds are enabled
  21776. */
  21777. /**
  21778. * Sets the state of point cloud mode
  21779. */
  21780. pointsCloud: boolean;
  21781. /**
  21782. * Gets the material fill mode
  21783. */
  21784. /**
  21785. * Sets the material fill mode
  21786. */
  21787. fillMode: number;
  21788. /**
  21789. * @hidden
  21790. * Stores the effects for the material
  21791. */
  21792. _effect: Nullable<Effect>;
  21793. /**
  21794. * @hidden
  21795. * Specifies if the material was previously ready
  21796. */
  21797. _wasPreviouslyReady: boolean;
  21798. /**
  21799. * Specifies if uniform buffers should be used
  21800. */
  21801. private _useUBO;
  21802. /**
  21803. * Stores a reference to the scene
  21804. */
  21805. private _scene;
  21806. /**
  21807. * Stores the fill mode state
  21808. */
  21809. private _fillMode;
  21810. /**
  21811. * Specifies if the depth write state should be cached
  21812. */
  21813. private _cachedDepthWriteState;
  21814. /**
  21815. * Stores the uniform buffer
  21816. */
  21817. protected _uniformBuffer: UniformBuffer;
  21818. /** @hidden */
  21819. _indexInSceneMaterialArray: number;
  21820. /** @hidden */
  21821. meshMap: Nullable<{
  21822. [id: string]: AbstractMesh | undefined;
  21823. }>;
  21824. /**
  21825. * Creates a material instance
  21826. * @param name defines the name of the material
  21827. * @param scene defines the scene to reference
  21828. * @param doNotAdd specifies if the material should be added to the scene
  21829. */
  21830. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21831. /**
  21832. * Returns a string representation of the current material
  21833. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21834. * @returns a string with material information
  21835. */
  21836. toString(fullDetails?: boolean): string;
  21837. /**
  21838. * Gets the class name of the material
  21839. * @returns a string with the class name of the material
  21840. */
  21841. getClassName(): string;
  21842. /**
  21843. * Specifies if updates for the material been locked
  21844. */
  21845. readonly isFrozen: boolean;
  21846. /**
  21847. * Locks updates for the material
  21848. */
  21849. freeze(): void;
  21850. /**
  21851. * Unlocks updates for the material
  21852. */
  21853. unfreeze(): void;
  21854. /**
  21855. * Specifies if the material is ready to be used
  21856. * @param mesh defines the mesh to check
  21857. * @param useInstances specifies if instances should be used
  21858. * @returns a boolean indicating if the material is ready to be used
  21859. */
  21860. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21861. /**
  21862. * Specifies that the submesh is ready to be used
  21863. * @param mesh defines the mesh to check
  21864. * @param subMesh defines which submesh to check
  21865. * @param useInstances specifies that instances should be used
  21866. * @returns a boolean indicating that the submesh is ready or not
  21867. */
  21868. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21869. /**
  21870. * Returns the material effect
  21871. * @returns the effect associated with the material
  21872. */
  21873. getEffect(): Nullable<Effect>;
  21874. /**
  21875. * Returns the current scene
  21876. * @returns a Scene
  21877. */
  21878. getScene(): Scene;
  21879. /**
  21880. * Specifies if the material will require alpha blending
  21881. * @returns a boolean specifying if alpha blending is needed
  21882. */
  21883. needAlphaBlending(): boolean;
  21884. /**
  21885. * Specifies if the mesh will require alpha blending
  21886. * @param mesh defines the mesh to check
  21887. * @returns a boolean specifying if alpha blending is needed for the mesh
  21888. */
  21889. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21890. /**
  21891. * Specifies if this material should be rendered in alpha test mode
  21892. * @returns a boolean specifying if an alpha test is needed.
  21893. */
  21894. needAlphaTesting(): boolean;
  21895. /**
  21896. * Gets the texture used for the alpha test
  21897. * @returns the texture to use for alpha testing
  21898. */
  21899. getAlphaTestTexture(): Nullable<BaseTexture>;
  21900. /**
  21901. * Marks the material to indicate that it needs to be re-calculated
  21902. */
  21903. markDirty(): void;
  21904. /** @hidden */
  21905. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21906. /**
  21907. * Binds the material to the mesh
  21908. * @param world defines the world transformation matrix
  21909. * @param mesh defines the mesh to bind the material to
  21910. */
  21911. bind(world: Matrix, mesh?: Mesh): void;
  21912. /**
  21913. * Binds the submesh to the material
  21914. * @param world defines the world transformation matrix
  21915. * @param mesh defines the mesh containing the submesh
  21916. * @param subMesh defines the submesh to bind the material to
  21917. */
  21918. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21919. /**
  21920. * Binds the world matrix to the material
  21921. * @param world defines the world transformation matrix
  21922. */
  21923. bindOnlyWorldMatrix(world: Matrix): void;
  21924. /**
  21925. * Binds the scene's uniform buffer to the effect.
  21926. * @param effect defines the effect to bind to the scene uniform buffer
  21927. * @param sceneUbo defines the uniform buffer storing scene data
  21928. */
  21929. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21930. /**
  21931. * Binds the view matrix to the effect
  21932. * @param effect defines the effect to bind the view matrix to
  21933. */
  21934. bindView(effect: Effect): void;
  21935. /**
  21936. * Binds the view projection matrix to the effect
  21937. * @param effect defines the effect to bind the view projection matrix to
  21938. */
  21939. bindViewProjection(effect: Effect): void;
  21940. /**
  21941. * Specifies if material alpha testing should be turned on for the mesh
  21942. * @param mesh defines the mesh to check
  21943. */
  21944. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21945. /**
  21946. * Processes to execute after binding the material to a mesh
  21947. * @param mesh defines the rendered mesh
  21948. */
  21949. protected _afterBind(mesh?: Mesh): void;
  21950. /**
  21951. * Unbinds the material from the mesh
  21952. */
  21953. unbind(): void;
  21954. /**
  21955. * Gets the active textures from the material
  21956. * @returns an array of textures
  21957. */
  21958. getActiveTextures(): BaseTexture[];
  21959. /**
  21960. * Specifies if the material uses a texture
  21961. * @param texture defines the texture to check against the material
  21962. * @returns a boolean specifying if the material uses the texture
  21963. */
  21964. hasTexture(texture: BaseTexture): boolean;
  21965. /**
  21966. * Makes a duplicate of the material, and gives it a new name
  21967. * @param name defines the new name for the duplicated material
  21968. * @returns the cloned material
  21969. */
  21970. clone(name: string): Nullable<Material>;
  21971. /**
  21972. * Gets the meshes bound to the material
  21973. * @returns an array of meshes bound to the material
  21974. */
  21975. getBindedMeshes(): AbstractMesh[];
  21976. /**
  21977. * Force shader compilation
  21978. * @param mesh defines the mesh associated with this material
  21979. * @param onCompiled defines a function to execute once the material is compiled
  21980. * @param options defines the options to configure the compilation
  21981. */
  21982. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21983. clipPlane: boolean;
  21984. }>): void;
  21985. /**
  21986. * Force shader compilation
  21987. * @param mesh defines the mesh that will use this material
  21988. * @param options defines additional options for compiling the shaders
  21989. * @returns a promise that resolves when the compilation completes
  21990. */
  21991. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21992. clipPlane: boolean;
  21993. }>): Promise<void>;
  21994. private static readonly _ImageProcessingDirtyCallBack;
  21995. private static readonly _TextureDirtyCallBack;
  21996. private static readonly _FresnelDirtyCallBack;
  21997. private static readonly _MiscDirtyCallBack;
  21998. private static readonly _LightsDirtyCallBack;
  21999. private static readonly _AttributeDirtyCallBack;
  22000. private static _FresnelAndMiscDirtyCallBack;
  22001. private static _TextureAndMiscDirtyCallBack;
  22002. private static readonly _DirtyCallbackArray;
  22003. private static readonly _RunDirtyCallBacks;
  22004. /**
  22005. * Marks a define in the material to indicate that it needs to be re-computed
  22006. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22007. */
  22008. markAsDirty(flag: number): void;
  22009. /**
  22010. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22011. * @param func defines a function which checks material defines against the submeshes
  22012. */
  22013. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22014. /**
  22015. * Indicates that image processing needs to be re-calculated for all submeshes
  22016. */
  22017. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22018. /**
  22019. * Indicates that textures need to be re-calculated for all submeshes
  22020. */
  22021. protected _markAllSubMeshesAsTexturesDirty(): void;
  22022. /**
  22023. * Indicates that fresnel needs to be re-calculated for all submeshes
  22024. */
  22025. protected _markAllSubMeshesAsFresnelDirty(): void;
  22026. /**
  22027. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22028. */
  22029. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22030. /**
  22031. * Indicates that lights need to be re-calculated for all submeshes
  22032. */
  22033. protected _markAllSubMeshesAsLightsDirty(): void;
  22034. /**
  22035. * Indicates that attributes need to be re-calculated for all submeshes
  22036. */
  22037. protected _markAllSubMeshesAsAttributesDirty(): void;
  22038. /**
  22039. * Indicates that misc needs to be re-calculated for all submeshes
  22040. */
  22041. protected _markAllSubMeshesAsMiscDirty(): void;
  22042. /**
  22043. * Indicates that textures and misc need to be re-calculated for all submeshes
  22044. */
  22045. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22046. /**
  22047. * Disposes the material
  22048. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22049. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22050. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22051. */
  22052. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22053. /** @hidden */
  22054. private releaseVertexArrayObject;
  22055. /**
  22056. * Serializes this material
  22057. * @returns the serialized material object
  22058. */
  22059. serialize(): any;
  22060. /**
  22061. * Creates a material from parsed material data
  22062. * @param parsedMaterial defines parsed material data
  22063. * @param scene defines the hosting scene
  22064. * @param rootUrl defines the root URL to use to load textures
  22065. * @returns a new material
  22066. */
  22067. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22068. }
  22069. }
  22070. declare module "babylonjs/Meshes/subMesh" {
  22071. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22072. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22073. import { Engine } from "babylonjs/Engines/engine";
  22074. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22075. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22076. import { Effect } from "babylonjs/Materials/effect";
  22077. import { Collider } from "babylonjs/Collisions/collider";
  22078. import { Material } from "babylonjs/Materials/material";
  22079. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22080. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22081. import { Mesh } from "babylonjs/Meshes/mesh";
  22082. import { Ray } from "babylonjs/Culling/ray";
  22083. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22084. /**
  22085. * Base class for submeshes
  22086. */
  22087. export class BaseSubMesh {
  22088. /** @hidden */
  22089. _materialDefines: Nullable<MaterialDefines>;
  22090. /** @hidden */
  22091. _materialEffect: Nullable<Effect>;
  22092. /**
  22093. * Gets associated effect
  22094. */
  22095. readonly effect: Nullable<Effect>;
  22096. /**
  22097. * Sets associated effect (effect used to render this submesh)
  22098. * @param effect defines the effect to associate with
  22099. * @param defines defines the set of defines used to compile this effect
  22100. */
  22101. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22102. }
  22103. /**
  22104. * Defines a subdivision inside a mesh
  22105. */
  22106. export class SubMesh extends BaseSubMesh implements ICullable {
  22107. /** the material index to use */
  22108. materialIndex: number;
  22109. /** vertex index start */
  22110. verticesStart: number;
  22111. /** vertices count */
  22112. verticesCount: number;
  22113. /** index start */
  22114. indexStart: number;
  22115. /** indices count */
  22116. indexCount: number;
  22117. /** @hidden */
  22118. _linesIndexCount: number;
  22119. private _mesh;
  22120. private _renderingMesh;
  22121. private _boundingInfo;
  22122. private _linesIndexBuffer;
  22123. /** @hidden */
  22124. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22125. /** @hidden */
  22126. _trianglePlanes: Plane[];
  22127. /** @hidden */
  22128. _lastColliderTransformMatrix: Matrix;
  22129. /** @hidden */
  22130. _renderId: number;
  22131. /** @hidden */
  22132. _alphaIndex: number;
  22133. /** @hidden */
  22134. _distanceToCamera: number;
  22135. /** @hidden */
  22136. _id: number;
  22137. private _currentMaterial;
  22138. /**
  22139. * Add a new submesh to a mesh
  22140. * @param materialIndex defines the material index to use
  22141. * @param verticesStart defines vertex index start
  22142. * @param verticesCount defines vertices count
  22143. * @param indexStart defines index start
  22144. * @param indexCount defines indices count
  22145. * @param mesh defines the parent mesh
  22146. * @param renderingMesh defines an optional rendering mesh
  22147. * @param createBoundingBox defines if bounding box should be created for this submesh
  22148. * @returns the new submesh
  22149. */
  22150. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22151. /**
  22152. * Creates a new submesh
  22153. * @param materialIndex defines the material index to use
  22154. * @param verticesStart defines vertex index start
  22155. * @param verticesCount defines vertices count
  22156. * @param indexStart defines index start
  22157. * @param indexCount defines indices count
  22158. * @param mesh defines the parent mesh
  22159. * @param renderingMesh defines an optional rendering mesh
  22160. * @param createBoundingBox defines if bounding box should be created for this submesh
  22161. */
  22162. constructor(
  22163. /** the material index to use */
  22164. materialIndex: number,
  22165. /** vertex index start */
  22166. verticesStart: number,
  22167. /** vertices count */
  22168. verticesCount: number,
  22169. /** index start */
  22170. indexStart: number,
  22171. /** indices count */
  22172. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22173. /**
  22174. * Returns true if this submesh covers the entire parent mesh
  22175. * @ignorenaming
  22176. */
  22177. readonly IsGlobal: boolean;
  22178. /**
  22179. * Returns the submesh BoudingInfo object
  22180. * @returns current bounding info (or mesh's one if the submesh is global)
  22181. */
  22182. getBoundingInfo(): BoundingInfo;
  22183. /**
  22184. * Sets the submesh BoundingInfo
  22185. * @param boundingInfo defines the new bounding info to use
  22186. * @returns the SubMesh
  22187. */
  22188. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22189. /**
  22190. * Returns the mesh of the current submesh
  22191. * @return the parent mesh
  22192. */
  22193. getMesh(): AbstractMesh;
  22194. /**
  22195. * Returns the rendering mesh of the submesh
  22196. * @returns the rendering mesh (could be different from parent mesh)
  22197. */
  22198. getRenderingMesh(): Mesh;
  22199. /**
  22200. * Returns the submesh material
  22201. * @returns null or the current material
  22202. */
  22203. getMaterial(): Nullable<Material>;
  22204. /**
  22205. * Sets a new updated BoundingInfo object to the submesh
  22206. * @returns the SubMesh
  22207. */
  22208. refreshBoundingInfo(): SubMesh;
  22209. /** @hidden */
  22210. _checkCollision(collider: Collider): boolean;
  22211. /**
  22212. * Updates the submesh BoundingInfo
  22213. * @param world defines the world matrix to use to update the bounding info
  22214. * @returns the submesh
  22215. */
  22216. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22217. /**
  22218. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22219. * @param frustumPlanes defines the frustum planes
  22220. * @returns true if the submesh is intersecting with the frustum
  22221. */
  22222. isInFrustum(frustumPlanes: Plane[]): boolean;
  22223. /**
  22224. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22225. * @param frustumPlanes defines the frustum planes
  22226. * @returns true if the submesh is inside the frustum
  22227. */
  22228. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22229. /**
  22230. * Renders the submesh
  22231. * @param enableAlphaMode defines if alpha needs to be used
  22232. * @returns the submesh
  22233. */
  22234. render(enableAlphaMode: boolean): SubMesh;
  22235. /**
  22236. * @hidden
  22237. */
  22238. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22239. /**
  22240. * Checks if the submesh intersects with a ray
  22241. * @param ray defines the ray to test
  22242. * @returns true is the passed ray intersects the submesh bounding box
  22243. */
  22244. canIntersects(ray: Ray): boolean;
  22245. /**
  22246. * Intersects current submesh with a ray
  22247. * @param ray defines the ray to test
  22248. * @param positions defines mesh's positions array
  22249. * @param indices defines mesh's indices array
  22250. * @param fastCheck defines if only bounding info should be used
  22251. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22252. * @returns intersection info or null if no intersection
  22253. */
  22254. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22255. /** @hidden */
  22256. private _intersectLines;
  22257. /** @hidden */
  22258. private _intersectTriangles;
  22259. /** @hidden */
  22260. _rebuild(): void;
  22261. /**
  22262. * Creates a new submesh from the passed mesh
  22263. * @param newMesh defines the new hosting mesh
  22264. * @param newRenderingMesh defines an optional rendering mesh
  22265. * @returns the new submesh
  22266. */
  22267. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22268. /**
  22269. * Release associated resources
  22270. */
  22271. dispose(): void;
  22272. /**
  22273. * Gets the class name
  22274. * @returns the string "SubMesh".
  22275. */
  22276. getClassName(): string;
  22277. /**
  22278. * Creates a new submesh from indices data
  22279. * @param materialIndex the index of the main mesh material
  22280. * @param startIndex the index where to start the copy in the mesh indices array
  22281. * @param indexCount the number of indices to copy then from the startIndex
  22282. * @param mesh the main mesh to create the submesh from
  22283. * @param renderingMesh the optional rendering mesh
  22284. * @returns a new submesh
  22285. */
  22286. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22287. }
  22288. }
  22289. declare module "babylonjs/Meshes/geometry" {
  22290. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22291. import { Scene } from "babylonjs/scene";
  22292. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22293. import { Engine } from "babylonjs/Engines/engine";
  22294. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22295. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22296. import { Effect } from "babylonjs/Materials/effect";
  22297. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22298. import { Mesh } from "babylonjs/Meshes/mesh";
  22299. /**
  22300. * Class used to store geometry data (vertex buffers + index buffer)
  22301. */
  22302. export class Geometry implements IGetSetVerticesData {
  22303. /**
  22304. * Gets or sets the ID of the geometry
  22305. */
  22306. id: string;
  22307. /**
  22308. * Gets or sets the unique ID of the geometry
  22309. */
  22310. uniqueId: number;
  22311. /**
  22312. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22313. */
  22314. delayLoadState: number;
  22315. /**
  22316. * Gets the file containing the data to load when running in delay load state
  22317. */
  22318. delayLoadingFile: Nullable<string>;
  22319. /**
  22320. * Callback called when the geometry is updated
  22321. */
  22322. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22323. private _scene;
  22324. private _engine;
  22325. private _meshes;
  22326. private _totalVertices;
  22327. /** @hidden */
  22328. _indices: IndicesArray;
  22329. /** @hidden */
  22330. _vertexBuffers: {
  22331. [key: string]: VertexBuffer;
  22332. };
  22333. private _isDisposed;
  22334. private _extend;
  22335. private _boundingBias;
  22336. /** @hidden */
  22337. _delayInfo: Array<string>;
  22338. private _indexBuffer;
  22339. private _indexBufferIsUpdatable;
  22340. /** @hidden */
  22341. _boundingInfo: Nullable<BoundingInfo>;
  22342. /** @hidden */
  22343. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22344. /** @hidden */
  22345. _softwareSkinningFrameId: number;
  22346. private _vertexArrayObjects;
  22347. private _updatable;
  22348. /** @hidden */
  22349. _positions: Nullable<Vector3[]>;
  22350. /**
  22351. * 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
  22352. */
  22353. /**
  22354. * 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
  22355. */
  22356. boundingBias: Vector2;
  22357. /**
  22358. * Static function used to attach a new empty geometry to a mesh
  22359. * @param mesh defines the mesh to attach the geometry to
  22360. * @returns the new Geometry
  22361. */
  22362. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22363. /**
  22364. * Creates a new geometry
  22365. * @param id defines the unique ID
  22366. * @param scene defines the hosting scene
  22367. * @param vertexData defines the VertexData used to get geometry data
  22368. * @param updatable defines if geometry must be updatable (false by default)
  22369. * @param mesh defines the mesh that will be associated with the geometry
  22370. */
  22371. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22372. /**
  22373. * Gets the current extend of the geometry
  22374. */
  22375. readonly extend: {
  22376. minimum: Vector3;
  22377. maximum: Vector3;
  22378. };
  22379. /**
  22380. * Gets the hosting scene
  22381. * @returns the hosting Scene
  22382. */
  22383. getScene(): Scene;
  22384. /**
  22385. * Gets the hosting engine
  22386. * @returns the hosting Engine
  22387. */
  22388. getEngine(): Engine;
  22389. /**
  22390. * Defines if the geometry is ready to use
  22391. * @returns true if the geometry is ready to be used
  22392. */
  22393. isReady(): boolean;
  22394. /**
  22395. * Gets a value indicating that the geometry should not be serialized
  22396. */
  22397. readonly doNotSerialize: boolean;
  22398. /** @hidden */
  22399. _rebuild(): void;
  22400. /**
  22401. * Affects all geometry data in one call
  22402. * @param vertexData defines the geometry data
  22403. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22404. */
  22405. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22406. /**
  22407. * Set specific vertex data
  22408. * @param kind defines the data kind (Position, normal, etc...)
  22409. * @param data defines the vertex data to use
  22410. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22411. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22412. */
  22413. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22414. /**
  22415. * Removes a specific vertex data
  22416. * @param kind defines the data kind (Position, normal, etc...)
  22417. */
  22418. removeVerticesData(kind: string): void;
  22419. /**
  22420. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22421. * @param buffer defines the vertex buffer to use
  22422. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22423. */
  22424. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22425. /**
  22426. * Update a specific vertex buffer
  22427. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22428. * It will do nothing if the buffer is not updatable
  22429. * @param kind defines the data kind (Position, normal, etc...)
  22430. * @param data defines the data to use
  22431. * @param offset defines the offset in the target buffer where to store the data
  22432. * @param useBytes set to true if the offset is in bytes
  22433. */
  22434. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22435. /**
  22436. * Update a specific vertex buffer
  22437. * This function will create a new buffer if the current one is not updatable
  22438. * @param kind defines the data kind (Position, normal, etc...)
  22439. * @param data defines the data to use
  22440. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22441. */
  22442. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22443. private _updateBoundingInfo;
  22444. /** @hidden */
  22445. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22446. /**
  22447. * Gets total number of vertices
  22448. * @returns the total number of vertices
  22449. */
  22450. getTotalVertices(): number;
  22451. /**
  22452. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22453. * @param kind defines the data kind (Position, normal, etc...)
  22454. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22455. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22456. * @returns a float array containing vertex data
  22457. */
  22458. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22459. /**
  22460. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22461. * @param kind defines the data kind (Position, normal, etc...)
  22462. * @returns true if the vertex buffer with the specified kind is updatable
  22463. */
  22464. isVertexBufferUpdatable(kind: string): boolean;
  22465. /**
  22466. * Gets a specific vertex buffer
  22467. * @param kind defines the data kind (Position, normal, etc...)
  22468. * @returns a VertexBuffer
  22469. */
  22470. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22471. /**
  22472. * Returns all vertex buffers
  22473. * @return an object holding all vertex buffers indexed by kind
  22474. */
  22475. getVertexBuffers(): Nullable<{
  22476. [key: string]: VertexBuffer;
  22477. }>;
  22478. /**
  22479. * Gets a boolean indicating if specific vertex buffer is present
  22480. * @param kind defines the data kind (Position, normal, etc...)
  22481. * @returns true if data is present
  22482. */
  22483. isVerticesDataPresent(kind: string): boolean;
  22484. /**
  22485. * Gets a list of all attached data kinds (Position, normal, etc...)
  22486. * @returns a list of string containing all kinds
  22487. */
  22488. getVerticesDataKinds(): string[];
  22489. /**
  22490. * Update index buffer
  22491. * @param indices defines the indices to store in the index buffer
  22492. * @param offset defines the offset in the target buffer where to store the data
  22493. */
  22494. updateIndices(indices: IndicesArray, offset?: number): void;
  22495. /**
  22496. * Creates a new index buffer
  22497. * @param indices defines the indices to store in the index buffer
  22498. * @param totalVertices defines the total number of vertices (could be null)
  22499. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22500. */
  22501. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22502. /**
  22503. * Return the total number of indices
  22504. * @returns the total number of indices
  22505. */
  22506. getTotalIndices(): number;
  22507. /**
  22508. * Gets the index buffer array
  22509. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22510. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22511. * @returns the index buffer array
  22512. */
  22513. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22514. /**
  22515. * Gets the index buffer
  22516. * @return the index buffer
  22517. */
  22518. getIndexBuffer(): Nullable<WebGLBuffer>;
  22519. /** @hidden */
  22520. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22521. /**
  22522. * Release the associated resources for a specific mesh
  22523. * @param mesh defines the source mesh
  22524. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22525. */
  22526. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22527. /**
  22528. * Apply current geometry to a given mesh
  22529. * @param mesh defines the mesh to apply geometry to
  22530. */
  22531. applyToMesh(mesh: Mesh): void;
  22532. private _updateExtend;
  22533. private _applyToMesh;
  22534. private notifyUpdate;
  22535. /**
  22536. * Load the geometry if it was flagged as delay loaded
  22537. * @param scene defines the hosting scene
  22538. * @param onLoaded defines a callback called when the geometry is loaded
  22539. */
  22540. load(scene: Scene, onLoaded?: () => void): void;
  22541. private _queueLoad;
  22542. /**
  22543. * Invert the geometry to move from a right handed system to a left handed one.
  22544. */
  22545. toLeftHanded(): void;
  22546. /** @hidden */
  22547. _resetPointsArrayCache(): void;
  22548. /** @hidden */
  22549. _generatePointsArray(): boolean;
  22550. /**
  22551. * Gets a value indicating if the geometry is disposed
  22552. * @returns true if the geometry was disposed
  22553. */
  22554. isDisposed(): boolean;
  22555. private _disposeVertexArrayObjects;
  22556. /**
  22557. * Free all associated resources
  22558. */
  22559. dispose(): void;
  22560. /**
  22561. * Clone the current geometry into a new geometry
  22562. * @param id defines the unique ID of the new geometry
  22563. * @returns a new geometry object
  22564. */
  22565. copy(id: string): Geometry;
  22566. /**
  22567. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22568. * @return a JSON representation of the current geometry data (without the vertices data)
  22569. */
  22570. serialize(): any;
  22571. private toNumberArray;
  22572. /**
  22573. * Serialize all vertices data into a JSON oject
  22574. * @returns a JSON representation of the current geometry data
  22575. */
  22576. serializeVerticeData(): any;
  22577. /**
  22578. * Extracts a clone of a mesh geometry
  22579. * @param mesh defines the source mesh
  22580. * @param id defines the unique ID of the new geometry object
  22581. * @returns the new geometry object
  22582. */
  22583. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22584. /**
  22585. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22586. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22587. * Be aware Math.random() could cause collisions, but:
  22588. * "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"
  22589. * @returns a string containing a new GUID
  22590. */
  22591. static RandomId(): string;
  22592. /** @hidden */
  22593. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22594. private static _CleanMatricesWeights;
  22595. /**
  22596. * Create a new geometry from persisted data (Using .babylon file format)
  22597. * @param parsedVertexData defines the persisted data
  22598. * @param scene defines the hosting scene
  22599. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22600. * @returns the new geometry object
  22601. */
  22602. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22603. }
  22604. }
  22605. declare module "babylonjs/Meshes/mesh.vertexData" {
  22606. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22607. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  22608. import { Geometry } from "babylonjs/Meshes/geometry";
  22609. import { Mesh } from "babylonjs/Meshes/mesh";
  22610. /**
  22611. * Define an interface for all classes that will get and set the data on vertices
  22612. */
  22613. export interface IGetSetVerticesData {
  22614. /**
  22615. * Gets a boolean indicating if specific vertex data is present
  22616. * @param kind defines the vertex data kind to use
  22617. * @returns true is data kind is present
  22618. */
  22619. isVerticesDataPresent(kind: string): boolean;
  22620. /**
  22621. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22622. * @param kind defines the data kind (Position, normal, etc...)
  22623. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22624. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22625. * @returns a float array containing vertex data
  22626. */
  22627. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22628. /**
  22629. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22630. * @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.
  22631. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22632. * @returns the indices array or an empty array if the mesh has no geometry
  22633. */
  22634. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22635. /**
  22636. * Set specific vertex data
  22637. * @param kind defines the data kind (Position, normal, etc...)
  22638. * @param data defines the vertex data to use
  22639. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22640. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22641. */
  22642. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22643. /**
  22644. * Update a specific associated vertex buffer
  22645. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22646. * - VertexBuffer.PositionKind
  22647. * - VertexBuffer.UVKind
  22648. * - VertexBuffer.UV2Kind
  22649. * - VertexBuffer.UV3Kind
  22650. * - VertexBuffer.UV4Kind
  22651. * - VertexBuffer.UV5Kind
  22652. * - VertexBuffer.UV6Kind
  22653. * - VertexBuffer.ColorKind
  22654. * - VertexBuffer.MatricesIndicesKind
  22655. * - VertexBuffer.MatricesIndicesExtraKind
  22656. * - VertexBuffer.MatricesWeightsKind
  22657. * - VertexBuffer.MatricesWeightsExtraKind
  22658. * @param data defines the data source
  22659. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22660. * @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)
  22661. */
  22662. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22663. /**
  22664. * Creates a new index buffer
  22665. * @param indices defines the indices to store in the index buffer
  22666. * @param totalVertices defines the total number of vertices (could be null)
  22667. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22668. */
  22669. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22670. }
  22671. /**
  22672. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22673. */
  22674. export class VertexData {
  22675. /**
  22676. * Mesh side orientation : usually the external or front surface
  22677. */
  22678. static readonly FRONTSIDE: number;
  22679. /**
  22680. * Mesh side orientation : usually the internal or back surface
  22681. */
  22682. static readonly BACKSIDE: number;
  22683. /**
  22684. * Mesh side orientation : both internal and external or front and back surfaces
  22685. */
  22686. static readonly DOUBLESIDE: number;
  22687. /**
  22688. * Mesh side orientation : by default, `FRONTSIDE`
  22689. */
  22690. static readonly DEFAULTSIDE: number;
  22691. /**
  22692. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22693. */
  22694. positions: Nullable<FloatArray>;
  22695. /**
  22696. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22697. */
  22698. normals: Nullable<FloatArray>;
  22699. /**
  22700. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22701. */
  22702. tangents: Nullable<FloatArray>;
  22703. /**
  22704. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22705. */
  22706. uvs: Nullable<FloatArray>;
  22707. /**
  22708. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22709. */
  22710. uvs2: Nullable<FloatArray>;
  22711. /**
  22712. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22713. */
  22714. uvs3: Nullable<FloatArray>;
  22715. /**
  22716. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22717. */
  22718. uvs4: Nullable<FloatArray>;
  22719. /**
  22720. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22721. */
  22722. uvs5: Nullable<FloatArray>;
  22723. /**
  22724. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22725. */
  22726. uvs6: Nullable<FloatArray>;
  22727. /**
  22728. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22729. */
  22730. colors: Nullable<FloatArray>;
  22731. /**
  22732. * 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).
  22733. */
  22734. matricesIndices: Nullable<FloatArray>;
  22735. /**
  22736. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22737. */
  22738. matricesWeights: Nullable<FloatArray>;
  22739. /**
  22740. * An array extending the number of possible indices
  22741. */
  22742. matricesIndicesExtra: Nullable<FloatArray>;
  22743. /**
  22744. * An array extending the number of possible weights when the number of indices is extended
  22745. */
  22746. matricesWeightsExtra: Nullable<FloatArray>;
  22747. /**
  22748. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22749. */
  22750. indices: Nullable<IndicesArray>;
  22751. /**
  22752. * Uses the passed data array to set the set the values for the specified kind of data
  22753. * @param data a linear array of floating numbers
  22754. * @param kind the type of data that is being set, eg positions, colors etc
  22755. */
  22756. set(data: FloatArray, kind: string): void;
  22757. /**
  22758. * Associates the vertexData to the passed Mesh.
  22759. * Sets it as updatable or not (default `false`)
  22760. * @param mesh the mesh the vertexData is applied to
  22761. * @param updatable when used and having the value true allows new data to update the vertexData
  22762. * @returns the VertexData
  22763. */
  22764. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22765. /**
  22766. * Associates the vertexData to the passed Geometry.
  22767. * Sets it as updatable or not (default `false`)
  22768. * @param geometry the geometry the vertexData is applied to
  22769. * @param updatable when used and having the value true allows new data to update the vertexData
  22770. * @returns VertexData
  22771. */
  22772. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22773. /**
  22774. * Updates the associated mesh
  22775. * @param mesh the mesh to be updated
  22776. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22777. * @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
  22778. * @returns VertexData
  22779. */
  22780. updateMesh(mesh: Mesh): VertexData;
  22781. /**
  22782. * Updates the associated geometry
  22783. * @param geometry the geometry to be updated
  22784. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22785. * @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
  22786. * @returns VertexData.
  22787. */
  22788. updateGeometry(geometry: Geometry): VertexData;
  22789. private _applyTo;
  22790. private _update;
  22791. /**
  22792. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22793. * @param matrix the transforming matrix
  22794. * @returns the VertexData
  22795. */
  22796. transform(matrix: Matrix): VertexData;
  22797. /**
  22798. * Merges the passed VertexData into the current one
  22799. * @param other the VertexData to be merged into the current one
  22800. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22801. * @returns the modified VertexData
  22802. */
  22803. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22804. private _mergeElement;
  22805. private _validate;
  22806. /**
  22807. * Serializes the VertexData
  22808. * @returns a serialized object
  22809. */
  22810. serialize(): any;
  22811. /**
  22812. * Extracts the vertexData from a mesh
  22813. * @param mesh the mesh from which to extract the VertexData
  22814. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22815. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22816. * @returns the object VertexData associated to the passed mesh
  22817. */
  22818. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22819. /**
  22820. * Extracts the vertexData from the geometry
  22821. * @param geometry the geometry from which to extract the VertexData
  22822. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22823. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22824. * @returns the object VertexData associated to the passed mesh
  22825. */
  22826. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22827. private static _ExtractFrom;
  22828. /**
  22829. * Creates the VertexData for a Ribbon
  22830. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22831. * * pathArray array of paths, each of which an array of successive Vector3
  22832. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22833. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22834. * * 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
  22835. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22836. * * 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)
  22837. * * 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)
  22838. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22839. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22840. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22841. * @returns the VertexData of the ribbon
  22842. */
  22843. static CreateRibbon(options: {
  22844. pathArray: Vector3[][];
  22845. closeArray?: boolean;
  22846. closePath?: boolean;
  22847. offset?: number;
  22848. sideOrientation?: number;
  22849. frontUVs?: Vector4;
  22850. backUVs?: Vector4;
  22851. invertUV?: boolean;
  22852. uvs?: Vector2[];
  22853. colors?: Color4[];
  22854. }): VertexData;
  22855. /**
  22856. * Creates the VertexData for a box
  22857. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22858. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22859. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22860. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22861. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22862. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22863. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22864. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22865. * * 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)
  22866. * * 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)
  22867. * @returns the VertexData of the box
  22868. */
  22869. static CreateBox(options: {
  22870. size?: number;
  22871. width?: number;
  22872. height?: number;
  22873. depth?: number;
  22874. faceUV?: Vector4[];
  22875. faceColors?: Color4[];
  22876. sideOrientation?: number;
  22877. frontUVs?: Vector4;
  22878. backUVs?: Vector4;
  22879. }): VertexData;
  22880. /**
  22881. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22882. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22883. * * segments sets the number of horizontal strips optional, default 32
  22884. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22885. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22886. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22887. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22888. * * 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
  22889. * * 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
  22890. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22891. * * 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)
  22892. * * 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)
  22893. * @returns the VertexData of the ellipsoid
  22894. */
  22895. static CreateSphere(options: {
  22896. segments?: number;
  22897. diameter?: number;
  22898. diameterX?: number;
  22899. diameterY?: number;
  22900. diameterZ?: number;
  22901. arc?: number;
  22902. slice?: number;
  22903. sideOrientation?: number;
  22904. frontUVs?: Vector4;
  22905. backUVs?: Vector4;
  22906. }): VertexData;
  22907. /**
  22908. * Creates the VertexData for a cylinder, cone or prism
  22909. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22910. * * height sets the height (y direction) of the cylinder, optional, default 2
  22911. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22912. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22913. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22914. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22915. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22916. * * 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
  22917. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22918. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22919. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22920. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22921. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22922. * * 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)
  22923. * * 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)
  22924. * @returns the VertexData of the cylinder, cone or prism
  22925. */
  22926. static CreateCylinder(options: {
  22927. height?: number;
  22928. diameterTop?: number;
  22929. diameterBottom?: number;
  22930. diameter?: number;
  22931. tessellation?: number;
  22932. subdivisions?: number;
  22933. arc?: number;
  22934. faceColors?: Color4[];
  22935. faceUV?: Vector4[];
  22936. hasRings?: boolean;
  22937. enclose?: boolean;
  22938. sideOrientation?: number;
  22939. frontUVs?: Vector4;
  22940. backUVs?: Vector4;
  22941. }): VertexData;
  22942. /**
  22943. * Creates the VertexData for a torus
  22944. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22945. * * diameter the diameter of the torus, optional default 1
  22946. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22947. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22948. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22949. * * 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)
  22950. * * 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)
  22951. * @returns the VertexData of the torus
  22952. */
  22953. static CreateTorus(options: {
  22954. diameter?: number;
  22955. thickness?: number;
  22956. tessellation?: number;
  22957. sideOrientation?: number;
  22958. frontUVs?: Vector4;
  22959. backUVs?: Vector4;
  22960. }): VertexData;
  22961. /**
  22962. * Creates the VertexData of the LineSystem
  22963. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22964. * - lines an array of lines, each line being an array of successive Vector3
  22965. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22966. * @returns the VertexData of the LineSystem
  22967. */
  22968. static CreateLineSystem(options: {
  22969. lines: Vector3[][];
  22970. colors?: Nullable<Color4[][]>;
  22971. }): VertexData;
  22972. /**
  22973. * Create the VertexData for a DashedLines
  22974. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22975. * - points an array successive Vector3
  22976. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22977. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22978. * - dashNb the intended total number of dashes, optional, default 200
  22979. * @returns the VertexData for the DashedLines
  22980. */
  22981. static CreateDashedLines(options: {
  22982. points: Vector3[];
  22983. dashSize?: number;
  22984. gapSize?: number;
  22985. dashNb?: number;
  22986. }): VertexData;
  22987. /**
  22988. * Creates the VertexData for a Ground
  22989. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22990. * - width the width (x direction) of the ground, optional, default 1
  22991. * - height the height (z direction) of the ground, optional, default 1
  22992. * - subdivisions the number of subdivisions per side, optional, default 1
  22993. * @returns the VertexData of the Ground
  22994. */
  22995. static CreateGround(options: {
  22996. width?: number;
  22997. height?: number;
  22998. subdivisions?: number;
  22999. subdivisionsX?: number;
  23000. subdivisionsY?: number;
  23001. }): VertexData;
  23002. /**
  23003. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23004. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23005. * * xmin the ground minimum X coordinate, optional, default -1
  23006. * * zmin the ground minimum Z coordinate, optional, default -1
  23007. * * xmax the ground maximum X coordinate, optional, default 1
  23008. * * zmax the ground maximum Z coordinate, optional, default 1
  23009. * * 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}
  23010. * * 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}
  23011. * @returns the VertexData of the TiledGround
  23012. */
  23013. static CreateTiledGround(options: {
  23014. xmin: number;
  23015. zmin: number;
  23016. xmax: number;
  23017. zmax: number;
  23018. subdivisions?: {
  23019. w: number;
  23020. h: number;
  23021. };
  23022. precision?: {
  23023. w: number;
  23024. h: number;
  23025. };
  23026. }): VertexData;
  23027. /**
  23028. * Creates the VertexData of the Ground designed from a heightmap
  23029. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23030. * * width the width (x direction) of the ground
  23031. * * height the height (z direction) of the ground
  23032. * * subdivisions the number of subdivisions per side
  23033. * * minHeight the minimum altitude on the ground, optional, default 0
  23034. * * maxHeight the maximum altitude on the ground, optional default 1
  23035. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23036. * * buffer the array holding the image color data
  23037. * * bufferWidth the width of image
  23038. * * bufferHeight the height of image
  23039. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23040. * @returns the VertexData of the Ground designed from a heightmap
  23041. */
  23042. static CreateGroundFromHeightMap(options: {
  23043. width: number;
  23044. height: number;
  23045. subdivisions: number;
  23046. minHeight: number;
  23047. maxHeight: number;
  23048. colorFilter: Color3;
  23049. buffer: Uint8Array;
  23050. bufferWidth: number;
  23051. bufferHeight: number;
  23052. alphaFilter: number;
  23053. }): VertexData;
  23054. /**
  23055. * Creates the VertexData for a Plane
  23056. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23057. * * size sets the width and height of the plane to the value of size, optional default 1
  23058. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23059. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23060. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23061. * * 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)
  23062. * * 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)
  23063. * @returns the VertexData of the box
  23064. */
  23065. static CreatePlane(options: {
  23066. size?: number;
  23067. width?: number;
  23068. height?: number;
  23069. sideOrientation?: number;
  23070. frontUVs?: Vector4;
  23071. backUVs?: Vector4;
  23072. }): VertexData;
  23073. /**
  23074. * Creates the VertexData of the Disc or regular Polygon
  23075. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23076. * * radius the radius of the disc, optional default 0.5
  23077. * * tessellation the number of polygon sides, optional, default 64
  23078. * * 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
  23079. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23080. * * 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)
  23081. * * 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)
  23082. * @returns the VertexData of the box
  23083. */
  23084. static CreateDisc(options: {
  23085. radius?: number;
  23086. tessellation?: number;
  23087. arc?: number;
  23088. sideOrientation?: number;
  23089. frontUVs?: Vector4;
  23090. backUVs?: Vector4;
  23091. }): VertexData;
  23092. /**
  23093. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23094. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23095. * @param polygon a mesh built from polygonTriangulation.build()
  23096. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23097. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23098. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23099. * @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)
  23100. * @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)
  23101. * @returns the VertexData of the Polygon
  23102. */
  23103. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23104. /**
  23105. * Creates the VertexData of the IcoSphere
  23106. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23107. * * radius the radius of the IcoSphere, optional default 1
  23108. * * radiusX allows stretching in the x direction, optional, default radius
  23109. * * radiusY allows stretching in the y direction, optional, default radius
  23110. * * radiusZ allows stretching in the z direction, optional, default radius
  23111. * * flat when true creates a flat shaded mesh, optional, default true
  23112. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23113. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23114. * * 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)
  23115. * * 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)
  23116. * @returns the VertexData of the IcoSphere
  23117. */
  23118. static CreateIcoSphere(options: {
  23119. radius?: number;
  23120. radiusX?: number;
  23121. radiusY?: number;
  23122. radiusZ?: number;
  23123. flat?: boolean;
  23124. subdivisions?: number;
  23125. sideOrientation?: number;
  23126. frontUVs?: Vector4;
  23127. backUVs?: Vector4;
  23128. }): VertexData;
  23129. /**
  23130. * Creates the VertexData for a Polyhedron
  23131. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23132. * * type provided types are:
  23133. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23134. * * 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)
  23135. * * size the size of the IcoSphere, optional default 1
  23136. * * sizeX allows stretching in the x direction, optional, default size
  23137. * * sizeY allows stretching in the y direction, optional, default size
  23138. * * sizeZ allows stretching in the z direction, optional, default size
  23139. * * 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
  23140. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23141. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23142. * * flat when true creates a flat shaded mesh, optional, default true
  23143. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23144. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23145. * * 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)
  23146. * * 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)
  23147. * @returns the VertexData of the Polyhedron
  23148. */
  23149. static CreatePolyhedron(options: {
  23150. type?: number;
  23151. size?: number;
  23152. sizeX?: number;
  23153. sizeY?: number;
  23154. sizeZ?: number;
  23155. custom?: any;
  23156. faceUV?: Vector4[];
  23157. faceColors?: Color4[];
  23158. flat?: boolean;
  23159. sideOrientation?: number;
  23160. frontUVs?: Vector4;
  23161. backUVs?: Vector4;
  23162. }): VertexData;
  23163. /**
  23164. * Creates the VertexData for a TorusKnot
  23165. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23166. * * radius the radius of the torus knot, optional, default 2
  23167. * * tube the thickness of the tube, optional, default 0.5
  23168. * * radialSegments the number of sides on each tube segments, optional, default 32
  23169. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23170. * * p the number of windings around the z axis, optional, default 2
  23171. * * q the number of windings around the x axis, optional, default 3
  23172. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23173. * * 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)
  23174. * * 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)
  23175. * @returns the VertexData of the Torus Knot
  23176. */
  23177. static CreateTorusKnot(options: {
  23178. radius?: number;
  23179. tube?: number;
  23180. radialSegments?: number;
  23181. tubularSegments?: number;
  23182. p?: number;
  23183. q?: number;
  23184. sideOrientation?: number;
  23185. frontUVs?: Vector4;
  23186. backUVs?: Vector4;
  23187. }): VertexData;
  23188. /**
  23189. * Compute normals for given positions and indices
  23190. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23191. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23192. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23193. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23194. * * facetNormals : optional array of facet normals (vector3)
  23195. * * facetPositions : optional array of facet positions (vector3)
  23196. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23197. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23198. * * bInfo : optional bounding info, required for facetPartitioning computation
  23199. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23200. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23201. * * useRightHandedSystem: optional boolean to for right handed system computation
  23202. * * depthSort : optional boolean to enable the facet depth sort computation
  23203. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23204. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23205. */
  23206. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23207. facetNormals?: any;
  23208. facetPositions?: any;
  23209. facetPartitioning?: any;
  23210. ratio?: number;
  23211. bInfo?: any;
  23212. bbSize?: Vector3;
  23213. subDiv?: any;
  23214. useRightHandedSystem?: boolean;
  23215. depthSort?: boolean;
  23216. distanceTo?: Vector3;
  23217. depthSortedFacets?: any;
  23218. }): void;
  23219. /** @hidden */
  23220. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23221. /**
  23222. * Applies VertexData created from the imported parameters to the geometry
  23223. * @param parsedVertexData the parsed data from an imported file
  23224. * @param geometry the geometry to apply the VertexData to
  23225. */
  23226. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23227. }
  23228. }
  23229. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23230. import { Nullable } from "babylonjs/types";
  23231. import { Scene } from "babylonjs/scene";
  23232. import { Vector4 } from "babylonjs/Maths/math";
  23233. import { Mesh } from "babylonjs/Meshes/mesh";
  23234. /**
  23235. * Class containing static functions to help procedurally build meshes
  23236. */
  23237. export class DiscBuilder {
  23238. /**
  23239. * Creates a plane polygonal mesh. By default, this is a disc
  23240. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23241. * * 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
  23242. * * 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
  23243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23244. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23246. * @param name defines the name of the mesh
  23247. * @param options defines the options used to create the mesh
  23248. * @param scene defines the hosting scene
  23249. * @returns the plane polygonal mesh
  23250. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23251. */
  23252. static CreateDisc(name: string, options: {
  23253. radius?: number;
  23254. tessellation?: number;
  23255. arc?: number;
  23256. updatable?: boolean;
  23257. sideOrientation?: number;
  23258. frontUVs?: Vector4;
  23259. backUVs?: Vector4;
  23260. }, scene?: Nullable<Scene>): Mesh;
  23261. }
  23262. }
  23263. declare module "babylonjs/Particles/solidParticleSystem" {
  23264. import { Vector3 } from "babylonjs/Maths/math";
  23265. import { Mesh } from "babylonjs/Meshes/mesh";
  23266. import { Scene, IDisposable } from "babylonjs/scene";
  23267. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23268. /**
  23269. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23270. *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.
  23271. * The SPS is also a particle system. It provides some methods to manage the particles.
  23272. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23273. *
  23274. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23275. */
  23276. export class SolidParticleSystem implements IDisposable {
  23277. /**
  23278. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23279. * Example : var p = SPS.particles[i];
  23280. */
  23281. particles: SolidParticle[];
  23282. /**
  23283. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23284. */
  23285. nbParticles: number;
  23286. /**
  23287. * If the particles must ever face the camera (default false). Useful for planar particles.
  23288. */
  23289. billboard: boolean;
  23290. /**
  23291. * Recompute normals when adding a shape
  23292. */
  23293. recomputeNormals: boolean;
  23294. /**
  23295. * This a counter ofr your own usage. It's not set by any SPS functions.
  23296. */
  23297. counter: number;
  23298. /**
  23299. * The SPS name. This name is also given to the underlying mesh.
  23300. */
  23301. name: string;
  23302. /**
  23303. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23304. */
  23305. mesh: Mesh;
  23306. /**
  23307. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23308. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23309. */
  23310. vars: any;
  23311. /**
  23312. * This array is populated when the SPS is set as 'pickable'.
  23313. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23314. * Each element of this array is an object `{idx: int, faceId: int}`.
  23315. * `idx` is the picked particle index in the `SPS.particles` array
  23316. * `faceId` is the picked face index counted within this particle.
  23317. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23318. */
  23319. pickedParticles: {
  23320. idx: number;
  23321. faceId: number;
  23322. }[];
  23323. /**
  23324. * This array is populated when `enableDepthSort` is set to true.
  23325. * Each element of this array is an instance of the class DepthSortedParticle.
  23326. */
  23327. depthSortedParticles: DepthSortedParticle[];
  23328. /**
  23329. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23330. * @hidden
  23331. */
  23332. _bSphereOnly: boolean;
  23333. /**
  23334. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23335. * @hidden
  23336. */
  23337. _bSphereRadiusFactor: number;
  23338. private _scene;
  23339. private _positions;
  23340. private _indices;
  23341. private _normals;
  23342. private _colors;
  23343. private _uvs;
  23344. private _indices32;
  23345. private _positions32;
  23346. private _normals32;
  23347. private _fixedNormal32;
  23348. private _colors32;
  23349. private _uvs32;
  23350. private _index;
  23351. private _updatable;
  23352. private _pickable;
  23353. private _isVisibilityBoxLocked;
  23354. private _alwaysVisible;
  23355. private _depthSort;
  23356. private _shapeCounter;
  23357. private _copy;
  23358. private _color;
  23359. private _computeParticleColor;
  23360. private _computeParticleTexture;
  23361. private _computeParticleRotation;
  23362. private _computeParticleVertex;
  23363. private _computeBoundingBox;
  23364. private _depthSortParticles;
  23365. private _camera;
  23366. private _mustUnrotateFixedNormals;
  23367. private _particlesIntersect;
  23368. private _needs32Bits;
  23369. /**
  23370. * Creates a SPS (Solid Particle System) object.
  23371. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23372. * @param scene (Scene) is the scene in which the SPS is added.
  23373. * @param options defines the options of the sps e.g.
  23374. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23375. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23376. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23377. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23378. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23379. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23380. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23381. */
  23382. constructor(name: string, scene: Scene, options?: {
  23383. updatable?: boolean;
  23384. isPickable?: boolean;
  23385. enableDepthSort?: boolean;
  23386. particleIntersection?: boolean;
  23387. boundingSphereOnly?: boolean;
  23388. bSphereRadiusFactor?: number;
  23389. });
  23390. /**
  23391. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23392. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23393. * @returns the created mesh
  23394. */
  23395. buildMesh(): Mesh;
  23396. /**
  23397. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23398. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23399. * Thus the particles generated from `digest()` have their property `position` set yet.
  23400. * @param mesh ( Mesh ) is the mesh to be digested
  23401. * @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
  23402. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23403. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23404. * @returns the current SPS
  23405. */
  23406. digest(mesh: Mesh, options?: {
  23407. facetNb?: number;
  23408. number?: number;
  23409. delta?: number;
  23410. }): SolidParticleSystem;
  23411. private _unrotateFixedNormals;
  23412. private _resetCopy;
  23413. private _meshBuilder;
  23414. private _posToShape;
  23415. private _uvsToShapeUV;
  23416. private _addParticle;
  23417. /**
  23418. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23419. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23420. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23421. * @param nb (positive integer) the number of particles to be created from this model
  23422. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23423. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23424. * @returns the number of shapes in the system
  23425. */
  23426. addShape(mesh: Mesh, nb: number, options?: {
  23427. positionFunction?: any;
  23428. vertexFunction?: any;
  23429. }): number;
  23430. private _rebuildParticle;
  23431. /**
  23432. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23433. * @returns the SPS.
  23434. */
  23435. rebuildMesh(): SolidParticleSystem;
  23436. /**
  23437. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23438. * This method calls `updateParticle()` for each particle of the SPS.
  23439. * For an animated SPS, it is usually called within the render loop.
  23440. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23441. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23442. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23443. * @returns the SPS.
  23444. */
  23445. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23446. /**
  23447. * Disposes the SPS.
  23448. */
  23449. dispose(): void;
  23450. /**
  23451. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23452. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23453. * @returns the SPS.
  23454. */
  23455. refreshVisibleSize(): SolidParticleSystem;
  23456. /**
  23457. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23458. * @param size the size (float) of the visibility box
  23459. * note : this doesn't lock the SPS mesh bounding box.
  23460. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23461. */
  23462. setVisibilityBox(size: number): void;
  23463. /**
  23464. * Gets whether the SPS as always visible or not
  23465. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23466. */
  23467. /**
  23468. * Sets the SPS as always visible or not
  23469. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23470. */
  23471. isAlwaysVisible: boolean;
  23472. /**
  23473. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23474. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23475. */
  23476. /**
  23477. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23478. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23479. */
  23480. isVisibilityBoxLocked: boolean;
  23481. /**
  23482. * Tells to `setParticles()` to compute the particle rotations or not.
  23483. * Default value : true. The SPS is faster when it's set to false.
  23484. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23485. */
  23486. /**
  23487. * Gets if `setParticles()` computes the particle rotations or not.
  23488. * Default value : true. The SPS is faster when it's set to false.
  23489. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23490. */
  23491. computeParticleRotation: boolean;
  23492. /**
  23493. * Tells to `setParticles()` to compute the particle colors or not.
  23494. * Default value : true. The SPS is faster when it's set to false.
  23495. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23496. */
  23497. /**
  23498. * Gets if `setParticles()` computes the particle colors or not.
  23499. * Default value : true. The SPS is faster when it's set to false.
  23500. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23501. */
  23502. computeParticleColor: boolean;
  23503. /**
  23504. * Gets if `setParticles()` computes the particle textures or not.
  23505. * Default value : true. The SPS is faster when it's set to false.
  23506. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23507. */
  23508. computeParticleTexture: boolean;
  23509. /**
  23510. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23511. * Default value : false. The SPS is faster when it's set to false.
  23512. * Note : the particle custom vertex positions aren't stored values.
  23513. */
  23514. /**
  23515. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23516. * Default value : false. The SPS is faster when it's set to false.
  23517. * Note : the particle custom vertex positions aren't stored values.
  23518. */
  23519. computeParticleVertex: boolean;
  23520. /**
  23521. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23522. */
  23523. /**
  23524. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23525. */
  23526. computeBoundingBox: boolean;
  23527. /**
  23528. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23529. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23530. * Default : `true`
  23531. */
  23532. /**
  23533. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23534. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23535. * Default : `true`
  23536. */
  23537. depthSortParticles: boolean;
  23538. /**
  23539. * This function does nothing. It may be overwritten to set all the particle first values.
  23540. * The SPS doesn't call this function, you may have to call it by your own.
  23541. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23542. */
  23543. initParticles(): void;
  23544. /**
  23545. * This function does nothing. It may be overwritten to recycle a particle.
  23546. * The SPS doesn't call this function, you may have to call it by your own.
  23547. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23548. * @param particle The particle to recycle
  23549. * @returns the recycled particle
  23550. */
  23551. recycleParticle(particle: SolidParticle): SolidParticle;
  23552. /**
  23553. * Updates a particle : this function should be overwritten by the user.
  23554. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23555. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23556. * @example : just set a particle position or velocity and recycle conditions
  23557. * @param particle The particle to update
  23558. * @returns the updated particle
  23559. */
  23560. updateParticle(particle: SolidParticle): SolidParticle;
  23561. /**
  23562. * Updates a vertex of a particle : it can be overwritten by the user.
  23563. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23564. * @param particle the current particle
  23565. * @param vertex the current index of the current particle
  23566. * @param pt the index of the current vertex in the particle shape
  23567. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23568. * @example : just set a vertex particle position
  23569. * @returns the updated vertex
  23570. */
  23571. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23572. /**
  23573. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23574. * This does nothing and may be overwritten by the user.
  23575. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23576. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23577. * @param update the boolean update value actually passed to setParticles()
  23578. */
  23579. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23580. /**
  23581. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23582. * This will be passed three parameters.
  23583. * This does nothing and may be overwritten by the user.
  23584. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23585. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23586. * @param update the boolean update value actually passed to setParticles()
  23587. */
  23588. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23589. }
  23590. }
  23591. declare module "babylonjs/Particles/solidParticle" {
  23592. import { Nullable } from "babylonjs/types";
  23593. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  23594. import { Mesh } from "babylonjs/Meshes/mesh";
  23595. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23596. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  23597. /**
  23598. * Represents one particle of a solid particle system.
  23599. */
  23600. export class SolidParticle {
  23601. /**
  23602. * particle global index
  23603. */
  23604. idx: number;
  23605. /**
  23606. * The color of the particle
  23607. */
  23608. color: Nullable<Color4>;
  23609. /**
  23610. * The world space position of the particle.
  23611. */
  23612. position: Vector3;
  23613. /**
  23614. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23615. */
  23616. rotation: Vector3;
  23617. /**
  23618. * The world space rotation quaternion of the particle.
  23619. */
  23620. rotationQuaternion: Nullable<Quaternion>;
  23621. /**
  23622. * The scaling of the particle.
  23623. */
  23624. scaling: Vector3;
  23625. /**
  23626. * The uvs of the particle.
  23627. */
  23628. uvs: Vector4;
  23629. /**
  23630. * The current speed of the particle.
  23631. */
  23632. velocity: Vector3;
  23633. /**
  23634. * The pivot point in the particle local space.
  23635. */
  23636. pivot: Vector3;
  23637. /**
  23638. * Must the particle be translated from its pivot point in its local space ?
  23639. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23640. * Default : false
  23641. */
  23642. translateFromPivot: boolean;
  23643. /**
  23644. * Is the particle active or not ?
  23645. */
  23646. alive: boolean;
  23647. /**
  23648. * Is the particle visible or not ?
  23649. */
  23650. isVisible: boolean;
  23651. /**
  23652. * Index of this particle in the global "positions" array (Internal use)
  23653. * @hidden
  23654. */
  23655. _pos: number;
  23656. /**
  23657. * @hidden Index of this particle in the global "indices" array (Internal use)
  23658. */
  23659. _ind: number;
  23660. /**
  23661. * @hidden ModelShape of this particle (Internal use)
  23662. */
  23663. _model: ModelShape;
  23664. /**
  23665. * ModelShape id of this particle
  23666. */
  23667. shapeId: number;
  23668. /**
  23669. * Index of the particle in its shape id (Internal use)
  23670. */
  23671. idxInShape: number;
  23672. /**
  23673. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23674. */
  23675. _modelBoundingInfo: BoundingInfo;
  23676. /**
  23677. * @hidden Particle BoundingInfo object (Internal use)
  23678. */
  23679. _boundingInfo: BoundingInfo;
  23680. /**
  23681. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23682. */
  23683. _sps: SolidParticleSystem;
  23684. /**
  23685. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23686. */
  23687. _stillInvisible: boolean;
  23688. /**
  23689. * @hidden Last computed particle rotation matrix
  23690. */
  23691. _rotationMatrix: number[];
  23692. /**
  23693. * Parent particle Id, if any.
  23694. * Default null.
  23695. */
  23696. parentId: Nullable<number>;
  23697. /**
  23698. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23699. * The possible values are :
  23700. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23701. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23702. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23703. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23704. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23705. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23706. * */
  23707. cullingStrategy: number;
  23708. /**
  23709. * @hidden Internal global position in the SPS.
  23710. */
  23711. _globalPosition: Vector3;
  23712. /**
  23713. * Creates a Solid Particle object.
  23714. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23715. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23716. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23717. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23718. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23719. * @param shapeId (integer) is the model shape identifier in the SPS.
  23720. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23721. * @param sps defines the sps it is associated to
  23722. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23723. */
  23724. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23725. /**
  23726. * Legacy support, changed scale to scaling
  23727. */
  23728. /**
  23729. * Legacy support, changed scale to scaling
  23730. */
  23731. scale: Vector3;
  23732. /**
  23733. * Legacy support, changed quaternion to rotationQuaternion
  23734. */
  23735. /**
  23736. * Legacy support, changed quaternion to rotationQuaternion
  23737. */
  23738. quaternion: Nullable<Quaternion>;
  23739. /**
  23740. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23741. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23742. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23743. * @returns true if it intersects
  23744. */
  23745. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23746. /**
  23747. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23748. * A particle is in the frustum if its bounding box intersects the frustum
  23749. * @param frustumPlanes defines the frustum to test
  23750. * @returns true if the particle is in the frustum planes
  23751. */
  23752. isInFrustum(frustumPlanes: Plane[]): boolean;
  23753. /**
  23754. * get the rotation matrix of the particle
  23755. * @hidden
  23756. */
  23757. getRotationMatrix(m: Matrix): void;
  23758. }
  23759. /**
  23760. * Represents the shape of the model used by one particle of a solid particle system.
  23761. * SPS internal tool, don't use it manually.
  23762. */
  23763. export class ModelShape {
  23764. /**
  23765. * The shape id
  23766. * @hidden
  23767. */
  23768. shapeID: number;
  23769. /**
  23770. * flat array of model positions (internal use)
  23771. * @hidden
  23772. */
  23773. _shape: Vector3[];
  23774. /**
  23775. * flat array of model UVs (internal use)
  23776. * @hidden
  23777. */
  23778. _shapeUV: number[];
  23779. /**
  23780. * length of the shape in the model indices array (internal use)
  23781. * @hidden
  23782. */
  23783. _indicesLength: number;
  23784. /**
  23785. * Custom position function (internal use)
  23786. * @hidden
  23787. */
  23788. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23789. /**
  23790. * Custom vertex function (internal use)
  23791. * @hidden
  23792. */
  23793. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23794. /**
  23795. * 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.
  23796. * SPS internal tool, don't use it manually.
  23797. * @hidden
  23798. */
  23799. 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>);
  23800. }
  23801. /**
  23802. * Represents a Depth Sorted Particle in the solid particle system.
  23803. */
  23804. export class DepthSortedParticle {
  23805. /**
  23806. * Index of the particle in the "indices" array
  23807. */
  23808. ind: number;
  23809. /**
  23810. * Length of the particle shape in the "indices" array
  23811. */
  23812. indicesLength: number;
  23813. /**
  23814. * Squared distance from the particle to the camera
  23815. */
  23816. sqDistance: number;
  23817. }
  23818. }
  23819. declare module "babylonjs/Meshes/abstractMesh" {
  23820. import { Observable } from "babylonjs/Misc/observable";
  23821. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  23822. import { Camera } from "babylonjs/Cameras/camera";
  23823. import { Scene, IDisposable } from "babylonjs/scene";
  23824. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  23825. import { Node } from "babylonjs/node";
  23826. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23827. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23828. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23829. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  23830. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23831. import { Material } from "babylonjs/Materials/material";
  23832. import { Light } from "babylonjs/Lights/light";
  23833. import { Skeleton } from "babylonjs/Bones/skeleton";
  23834. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  23835. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  23836. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  23837. import { Ray } from "babylonjs/Culling/ray";
  23838. import { Collider } from "babylonjs/Collisions/collider";
  23839. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23840. /**
  23841. * Class used to store all common mesh properties
  23842. */
  23843. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23844. /** No occlusion */
  23845. static OCCLUSION_TYPE_NONE: number;
  23846. /** Occlusion set to optimisitic */
  23847. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23848. /** Occlusion set to strict */
  23849. static OCCLUSION_TYPE_STRICT: number;
  23850. /** Use an accurante occlusion algorithm */
  23851. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23852. /** Use a conservative occlusion algorithm */
  23853. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23854. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23855. * Test order :
  23856. * Is the bounding sphere outside the frustum ?
  23857. * If not, are the bounding box vertices outside the frustum ?
  23858. * It not, then the cullable object is in the frustum.
  23859. */
  23860. static readonly CULLINGSTRATEGY_STANDARD: number;
  23861. /** Culling strategy : Bounding Sphere Only.
  23862. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23863. * It's also less accurate than the standard because some not visible objects can still be selected.
  23864. * Test : is the bounding sphere outside the frustum ?
  23865. * If not, then the cullable object is in the frustum.
  23866. */
  23867. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23868. /** Culling strategy : Optimistic Inclusion.
  23869. * This in an inclusion test first, then the standard exclusion test.
  23870. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23871. * 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.
  23872. * Anyway, it's as accurate as the standard strategy.
  23873. * Test :
  23874. * Is the cullable object bounding sphere center in the frustum ?
  23875. * If not, apply the default culling strategy.
  23876. */
  23877. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23878. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23879. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23880. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23881. * 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.
  23882. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23883. * Test :
  23884. * Is the cullable object bounding sphere center in the frustum ?
  23885. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23886. */
  23887. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23888. /**
  23889. * No billboard
  23890. */
  23891. static readonly BILLBOARDMODE_NONE: number;
  23892. /** Billboard on X axis */
  23893. static readonly BILLBOARDMODE_X: number;
  23894. /** Billboard on Y axis */
  23895. static readonly BILLBOARDMODE_Y: number;
  23896. /** Billboard on Z axis */
  23897. static readonly BILLBOARDMODE_Z: number;
  23898. /** Billboard on all axes */
  23899. static readonly BILLBOARDMODE_ALL: number;
  23900. private _facetData;
  23901. /**
  23902. * The culling strategy to use to check whether the mesh must be rendered or not.
  23903. * This value can be changed at any time and will be used on the next render mesh selection.
  23904. * The possible values are :
  23905. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23906. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23907. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23908. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23909. * Please read each static variable documentation to get details about the culling process.
  23910. * */
  23911. cullingStrategy: number;
  23912. /**
  23913. * Gets the number of facets in the mesh
  23914. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23915. */
  23916. readonly facetNb: number;
  23917. /**
  23918. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23919. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23920. */
  23921. partitioningSubdivisions: number;
  23922. /**
  23923. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23924. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23925. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23926. */
  23927. partitioningBBoxRatio: number;
  23928. /**
  23929. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23930. * Works only for updatable meshes.
  23931. * Doesn't work with multi-materials
  23932. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23933. */
  23934. mustDepthSortFacets: boolean;
  23935. /**
  23936. * The location (Vector3) where the facet depth sort must be computed from.
  23937. * By default, the active camera position.
  23938. * Used only when facet depth sort is enabled
  23939. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23940. */
  23941. facetDepthSortFrom: Vector3;
  23942. /**
  23943. * gets a boolean indicating if facetData is enabled
  23944. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23945. */
  23946. readonly isFacetDataEnabled: boolean;
  23947. /** @hidden */
  23948. _updateNonUniformScalingState(value: boolean): boolean;
  23949. /**
  23950. * An event triggered when this mesh collides with another one
  23951. */
  23952. onCollideObservable: Observable<AbstractMesh>;
  23953. private _onCollideObserver;
  23954. /** Set a function to call when this mesh collides with another one */
  23955. onCollide: () => void;
  23956. /**
  23957. * An event triggered when the collision's position changes
  23958. */
  23959. onCollisionPositionChangeObservable: Observable<Vector3>;
  23960. private _onCollisionPositionChangeObserver;
  23961. /** Set a function to call when the collision's position changes */
  23962. onCollisionPositionChange: () => void;
  23963. /**
  23964. * An event triggered when material is changed
  23965. */
  23966. onMaterialChangedObservable: Observable<AbstractMesh>;
  23967. /**
  23968. * Gets or sets the orientation for POV movement & rotation
  23969. */
  23970. definedFacingForward: boolean;
  23971. /** @hidden */
  23972. _occlusionQuery: Nullable<WebGLQuery>;
  23973. private _visibility;
  23974. /**
  23975. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23976. */
  23977. /**
  23978. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23979. */
  23980. visibility: number;
  23981. /** Gets or sets the alpha index used to sort transparent meshes
  23982. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23983. */
  23984. alphaIndex: number;
  23985. /**
  23986. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23987. */
  23988. isVisible: boolean;
  23989. /**
  23990. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23991. */
  23992. isPickable: boolean;
  23993. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23994. showSubMeshesBoundingBox: boolean;
  23995. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23996. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23997. */
  23998. isBlocker: boolean;
  23999. /**
  24000. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24001. */
  24002. enablePointerMoveEvents: boolean;
  24003. /**
  24004. * Specifies the rendering group id for this mesh (0 by default)
  24005. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24006. */
  24007. renderingGroupId: number;
  24008. private _material;
  24009. /** Gets or sets current material */
  24010. material: Nullable<Material>;
  24011. private _receiveShadows;
  24012. /**
  24013. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24014. * @see http://doc.babylonjs.com/babylon101/shadows
  24015. */
  24016. receiveShadows: boolean;
  24017. /** Defines color to use when rendering outline */
  24018. outlineColor: Color3;
  24019. /** Define width to use when rendering outline */
  24020. outlineWidth: number;
  24021. /** Defines color to use when rendering overlay */
  24022. overlayColor: Color3;
  24023. /** Defines alpha to use when rendering overlay */
  24024. overlayAlpha: number;
  24025. private _hasVertexAlpha;
  24026. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24027. hasVertexAlpha: boolean;
  24028. private _useVertexColors;
  24029. /** 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) */
  24030. useVertexColors: boolean;
  24031. private _computeBonesUsingShaders;
  24032. /**
  24033. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24034. */
  24035. computeBonesUsingShaders: boolean;
  24036. private _numBoneInfluencers;
  24037. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24038. numBoneInfluencers: number;
  24039. private _applyFog;
  24040. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24041. applyFog: boolean;
  24042. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24043. useOctreeForRenderingSelection: boolean;
  24044. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24045. useOctreeForPicking: boolean;
  24046. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24047. useOctreeForCollisions: boolean;
  24048. private _layerMask;
  24049. /**
  24050. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24051. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24052. */
  24053. layerMask: number;
  24054. /**
  24055. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24056. */
  24057. alwaysSelectAsActiveMesh: boolean;
  24058. /**
  24059. * Gets or sets the current action manager
  24060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24061. */
  24062. actionManager: Nullable<AbstractActionManager>;
  24063. private _checkCollisions;
  24064. private _collisionMask;
  24065. private _collisionGroup;
  24066. /**
  24067. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24068. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24069. */
  24070. ellipsoid: Vector3;
  24071. /**
  24072. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24073. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24074. */
  24075. ellipsoidOffset: Vector3;
  24076. private _collider;
  24077. private _oldPositionForCollisions;
  24078. private _diffPositionForCollisions;
  24079. /**
  24080. * Gets or sets a collision mask used to mask collisions (default is -1).
  24081. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24082. */
  24083. collisionMask: number;
  24084. /**
  24085. * Gets or sets the current collision group mask (-1 by default).
  24086. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24087. */
  24088. collisionGroup: number;
  24089. /**
  24090. * Defines edge width used when edgesRenderer is enabled
  24091. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24092. */
  24093. edgesWidth: number;
  24094. /**
  24095. * Defines edge color used when edgesRenderer is enabled
  24096. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24097. */
  24098. edgesColor: Color4;
  24099. /** @hidden */
  24100. _edgesRenderer: Nullable<IEdgesRenderer>;
  24101. /** @hidden */
  24102. _masterMesh: Nullable<AbstractMesh>;
  24103. /** @hidden */
  24104. _boundingInfo: Nullable<BoundingInfo>;
  24105. /** @hidden */
  24106. _renderId: number;
  24107. /**
  24108. * Gets or sets the list of subMeshes
  24109. * @see http://doc.babylonjs.com/how_to/multi_materials
  24110. */
  24111. subMeshes: SubMesh[];
  24112. /** @hidden */
  24113. _intersectionsInProgress: AbstractMesh[];
  24114. /** @hidden */
  24115. _unIndexed: boolean;
  24116. /** @hidden */
  24117. _lightSources: Light[];
  24118. /** @hidden */
  24119. readonly _positions: Nullable<Vector3[]>;
  24120. /** @hidden */
  24121. _waitingActions: any;
  24122. /** @hidden */
  24123. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24124. private _skeleton;
  24125. /** @hidden */
  24126. _bonesTransformMatrices: Nullable<Float32Array>;
  24127. /**
  24128. * Gets or sets a skeleton to apply skining transformations
  24129. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24130. */
  24131. skeleton: Nullable<Skeleton>;
  24132. /**
  24133. * An event triggered when the mesh is rebuilt.
  24134. */
  24135. onRebuildObservable: Observable<AbstractMesh>;
  24136. /**
  24137. * Creates a new AbstractMesh
  24138. * @param name defines the name of the mesh
  24139. * @param scene defines the hosting scene
  24140. */
  24141. constructor(name: string, scene?: Nullable<Scene>);
  24142. /**
  24143. * Returns the string "AbstractMesh"
  24144. * @returns "AbstractMesh"
  24145. */
  24146. getClassName(): string;
  24147. /**
  24148. * Gets a string representation of the current mesh
  24149. * @param fullDetails defines a boolean indicating if full details must be included
  24150. * @returns a string representation of the current mesh
  24151. */
  24152. toString(fullDetails?: boolean): string;
  24153. /** @hidden */
  24154. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24155. /** @hidden */
  24156. _rebuild(): void;
  24157. /** @hidden */
  24158. _resyncLightSources(): void;
  24159. /** @hidden */
  24160. _resyncLighSource(light: Light): void;
  24161. /** @hidden */
  24162. _unBindEffect(): void;
  24163. /** @hidden */
  24164. _removeLightSource(light: Light): void;
  24165. private _markSubMeshesAsDirty;
  24166. /** @hidden */
  24167. _markSubMeshesAsLightDirty(): void;
  24168. /** @hidden */
  24169. _markSubMeshesAsAttributesDirty(): void;
  24170. /** @hidden */
  24171. _markSubMeshesAsMiscDirty(): void;
  24172. /**
  24173. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24174. */
  24175. scaling: Vector3;
  24176. /**
  24177. * Returns true if the mesh is blocked. Implemented by child classes
  24178. */
  24179. readonly isBlocked: boolean;
  24180. /**
  24181. * Returns the mesh itself by default. Implemented by child classes
  24182. * @param camera defines the camera to use to pick the right LOD level
  24183. * @returns the currentAbstractMesh
  24184. */
  24185. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24186. /**
  24187. * Returns 0 by default. Implemented by child classes
  24188. * @returns an integer
  24189. */
  24190. getTotalVertices(): number;
  24191. /**
  24192. * Returns a positive integer : the total number of indices in this mesh geometry.
  24193. * @returns the numner of indices or zero if the mesh has no geometry.
  24194. */
  24195. getTotalIndices(): number;
  24196. /**
  24197. * Returns null by default. Implemented by child classes
  24198. * @returns null
  24199. */
  24200. getIndices(): Nullable<IndicesArray>;
  24201. /**
  24202. * Returns the array of the requested vertex data kind. Implemented by child classes
  24203. * @param kind defines the vertex data kind to use
  24204. * @returns null
  24205. */
  24206. getVerticesData(kind: string): Nullable<FloatArray>;
  24207. /**
  24208. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24209. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24210. * Note that a new underlying VertexBuffer object is created each call.
  24211. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24212. * @param kind defines vertex data kind:
  24213. * * VertexBuffer.PositionKind
  24214. * * VertexBuffer.UVKind
  24215. * * VertexBuffer.UV2Kind
  24216. * * VertexBuffer.UV3Kind
  24217. * * VertexBuffer.UV4Kind
  24218. * * VertexBuffer.UV5Kind
  24219. * * VertexBuffer.UV6Kind
  24220. * * VertexBuffer.ColorKind
  24221. * * VertexBuffer.MatricesIndicesKind
  24222. * * VertexBuffer.MatricesIndicesExtraKind
  24223. * * VertexBuffer.MatricesWeightsKind
  24224. * * VertexBuffer.MatricesWeightsExtraKind
  24225. * @param data defines the data source
  24226. * @param updatable defines if the data must be flagged as updatable (or static)
  24227. * @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
  24228. * @returns the current mesh
  24229. */
  24230. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24231. /**
  24232. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24233. * If the mesh has no geometry, it is simply returned as it is.
  24234. * @param kind defines vertex data kind:
  24235. * * VertexBuffer.PositionKind
  24236. * * VertexBuffer.UVKind
  24237. * * VertexBuffer.UV2Kind
  24238. * * VertexBuffer.UV3Kind
  24239. * * VertexBuffer.UV4Kind
  24240. * * VertexBuffer.UV5Kind
  24241. * * VertexBuffer.UV6Kind
  24242. * * VertexBuffer.ColorKind
  24243. * * VertexBuffer.MatricesIndicesKind
  24244. * * VertexBuffer.MatricesIndicesExtraKind
  24245. * * VertexBuffer.MatricesWeightsKind
  24246. * * VertexBuffer.MatricesWeightsExtraKind
  24247. * @param data defines the data source
  24248. * @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
  24249. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24250. * @returns the current mesh
  24251. */
  24252. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24253. /**
  24254. * Sets the mesh indices,
  24255. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24256. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24257. * @param totalVertices Defines the total number of vertices
  24258. * @returns the current mesh
  24259. */
  24260. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24261. /**
  24262. * Gets a boolean indicating if specific vertex data is present
  24263. * @param kind defines the vertex data kind to use
  24264. * @returns true is data kind is present
  24265. */
  24266. isVerticesDataPresent(kind: string): boolean;
  24267. /**
  24268. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24269. * @returns a BoundingInfo
  24270. */
  24271. getBoundingInfo(): BoundingInfo;
  24272. /**
  24273. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24274. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24275. * @returns the current mesh
  24276. */
  24277. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24278. /**
  24279. * Overwrite the current bounding info
  24280. * @param boundingInfo defines the new bounding info
  24281. * @returns the current mesh
  24282. */
  24283. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24284. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24285. readonly useBones: boolean;
  24286. /** @hidden */
  24287. _preActivate(): void;
  24288. /** @hidden */
  24289. _preActivateForIntermediateRendering(renderId: number): void;
  24290. /** @hidden */
  24291. _activate(renderId: number): void;
  24292. /**
  24293. * Gets the current world matrix
  24294. * @returns a Matrix
  24295. */
  24296. getWorldMatrix(): Matrix;
  24297. /** @hidden */
  24298. _getWorldMatrixDeterminant(): number;
  24299. /**
  24300. * Perform relative position change from the point of view of behind the front of the mesh.
  24301. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24302. * Supports definition of mesh facing forward or backward
  24303. * @param amountRight defines the distance on the right axis
  24304. * @param amountUp defines the distance on the up axis
  24305. * @param amountForward defines the distance on the forward axis
  24306. * @returns the current mesh
  24307. */
  24308. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24309. /**
  24310. * Calculate relative position change from the point of view of behind the front of the mesh.
  24311. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24312. * Supports definition of mesh facing forward or backward
  24313. * @param amountRight defines the distance on the right axis
  24314. * @param amountUp defines the distance on the up axis
  24315. * @param amountForward defines the distance on the forward axis
  24316. * @returns the new displacement vector
  24317. */
  24318. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24319. /**
  24320. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24321. * Supports definition of mesh facing forward or backward
  24322. * @param flipBack defines the flip
  24323. * @param twirlClockwise defines the twirl
  24324. * @param tiltRight defines the tilt
  24325. * @returns the current mesh
  24326. */
  24327. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24328. /**
  24329. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24330. * Supports definition of mesh facing forward or backward.
  24331. * @param flipBack defines the flip
  24332. * @param twirlClockwise defines the twirl
  24333. * @param tiltRight defines the tilt
  24334. * @returns the new rotation vector
  24335. */
  24336. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24337. /**
  24338. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24339. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24340. * @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
  24341. * @returns the new bounding vectors
  24342. */
  24343. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24344. min: Vector3;
  24345. max: Vector3;
  24346. };
  24347. /**
  24348. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24349. * This means the mesh underlying bounding box and sphere are recomputed.
  24350. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24351. * @returns the current mesh
  24352. */
  24353. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24354. /** @hidden */
  24355. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24356. /** @hidden */
  24357. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24358. /** @hidden */
  24359. _updateBoundingInfo(): AbstractMesh;
  24360. /** @hidden */
  24361. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24362. /** @hidden */
  24363. protected _afterComputeWorldMatrix(): void;
  24364. /**
  24365. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24366. * A mesh is in the frustum if its bounding box intersects the frustum
  24367. * @param frustumPlanes defines the frustum to test
  24368. * @returns true if the mesh is in the frustum planes
  24369. */
  24370. isInFrustum(frustumPlanes: Plane[]): boolean;
  24371. /**
  24372. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24373. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24374. * @param frustumPlanes defines the frustum to test
  24375. * @returns true if the mesh is completely in the frustum planes
  24376. */
  24377. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24378. /**
  24379. * True if the mesh intersects another mesh or a SolidParticle object
  24380. * @param mesh defines a target mesh or SolidParticle to test
  24381. * @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)
  24382. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24383. * @returns true if there is an intersection
  24384. */
  24385. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24386. /**
  24387. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24388. * @param point defines the point to test
  24389. * @returns true if there is an intersection
  24390. */
  24391. intersectsPoint(point: Vector3): boolean;
  24392. /**
  24393. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24394. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24395. */
  24396. checkCollisions: boolean;
  24397. /**
  24398. * Gets Collider object used to compute collisions (not physics)
  24399. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24400. */
  24401. readonly collider: Collider;
  24402. /**
  24403. * Move the mesh using collision engine
  24404. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24405. * @param displacement defines the requested displacement vector
  24406. * @returns the current mesh
  24407. */
  24408. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24409. private _onCollisionPositionChange;
  24410. /** @hidden */
  24411. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24412. /** @hidden */
  24413. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24414. /** @hidden */
  24415. _checkCollision(collider: Collider): AbstractMesh;
  24416. /** @hidden */
  24417. _generatePointsArray(): boolean;
  24418. /**
  24419. * Checks if the passed Ray intersects with the mesh
  24420. * @param ray defines the ray to use
  24421. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24422. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24423. * @returns the picking info
  24424. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24425. */
  24426. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24427. /**
  24428. * Clones the current mesh
  24429. * @param name defines the mesh name
  24430. * @param newParent defines the new mesh parent
  24431. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24432. * @returns the new mesh
  24433. */
  24434. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24435. /**
  24436. * Disposes all the submeshes of the current meshnp
  24437. * @returns the current mesh
  24438. */
  24439. releaseSubMeshes(): AbstractMesh;
  24440. /**
  24441. * Releases resources associated with this abstract mesh.
  24442. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24443. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24444. */
  24445. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24446. /**
  24447. * Adds the passed mesh as a child to the current mesh
  24448. * @param mesh defines the child mesh
  24449. * @returns the current mesh
  24450. */
  24451. addChild(mesh: AbstractMesh): AbstractMesh;
  24452. /**
  24453. * Removes the passed mesh from the current mesh children list
  24454. * @param mesh defines the child mesh
  24455. * @returns the current mesh
  24456. */
  24457. removeChild(mesh: AbstractMesh): AbstractMesh;
  24458. /** @hidden */
  24459. private _initFacetData;
  24460. /**
  24461. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24462. * This method can be called within the render loop.
  24463. * 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
  24464. * @returns the current mesh
  24465. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24466. */
  24467. updateFacetData(): AbstractMesh;
  24468. /**
  24469. * Returns the facetLocalNormals array.
  24470. * The normals are expressed in the mesh local spac
  24471. * @returns an array of Vector3
  24472. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24473. */
  24474. getFacetLocalNormals(): Vector3[];
  24475. /**
  24476. * Returns the facetLocalPositions array.
  24477. * The facet positions are expressed in the mesh local space
  24478. * @returns an array of Vector3
  24479. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24480. */
  24481. getFacetLocalPositions(): Vector3[];
  24482. /**
  24483. * Returns the facetLocalPartioning array
  24484. * @returns an array of array of numbers
  24485. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24486. */
  24487. getFacetLocalPartitioning(): number[][];
  24488. /**
  24489. * Returns the i-th facet position in the world system.
  24490. * This method allocates a new Vector3 per call
  24491. * @param i defines the facet index
  24492. * @returns a new Vector3
  24493. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24494. */
  24495. getFacetPosition(i: number): Vector3;
  24496. /**
  24497. * Sets the reference Vector3 with the i-th facet position in the world system
  24498. * @param i defines the facet index
  24499. * @param ref defines the target vector
  24500. * @returns the current mesh
  24501. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24502. */
  24503. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24504. /**
  24505. * Returns the i-th facet normal in the world system.
  24506. * This method allocates a new Vector3 per call
  24507. * @param i defines the facet index
  24508. * @returns a new Vector3
  24509. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24510. */
  24511. getFacetNormal(i: number): Vector3;
  24512. /**
  24513. * Sets the reference Vector3 with the i-th facet normal in the world system
  24514. * @param i defines the facet index
  24515. * @param ref defines the target vector
  24516. * @returns the current mesh
  24517. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24518. */
  24519. getFacetNormalToRef(i: number, ref: Vector3): this;
  24520. /**
  24521. * 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)
  24522. * @param x defines x coordinate
  24523. * @param y defines y coordinate
  24524. * @param z defines z coordinate
  24525. * @returns the array of facet indexes
  24526. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24527. */
  24528. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24529. /**
  24530. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24531. * @param projected sets as the (x,y,z) world projection on the facet
  24532. * @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
  24533. * @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
  24534. * @param x defines x coordinate
  24535. * @param y defines y coordinate
  24536. * @param z defines z coordinate
  24537. * @returns the face index if found (or null instead)
  24538. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24539. */
  24540. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24541. /**
  24542. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24543. * @param projected sets as the (x,y,z) local projection on the facet
  24544. * @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
  24545. * @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
  24546. * @param x defines x coordinate
  24547. * @param y defines y coordinate
  24548. * @param z defines z coordinate
  24549. * @returns the face index if found (or null instead)
  24550. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24551. */
  24552. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24553. /**
  24554. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24555. * @returns the parameters
  24556. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24557. */
  24558. getFacetDataParameters(): any;
  24559. /**
  24560. * Disables the feature FacetData and frees the related memory
  24561. * @returns the current mesh
  24562. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24563. */
  24564. disableFacetData(): AbstractMesh;
  24565. /**
  24566. * Updates the AbstractMesh indices array
  24567. * @param indices defines the data source
  24568. * @returns the current mesh
  24569. */
  24570. updateIndices(indices: IndicesArray): AbstractMesh;
  24571. /**
  24572. * Creates new normals data for the mesh
  24573. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24574. * @returns the current mesh
  24575. */
  24576. createNormals(updatable: boolean): AbstractMesh;
  24577. /**
  24578. * Align the mesh with a normal
  24579. * @param normal defines the normal to use
  24580. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24581. * @returns the current mesh
  24582. */
  24583. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24584. /** @hidden */
  24585. _checkOcclusionQuery(): boolean;
  24586. }
  24587. }
  24588. declare module "babylonjs/Actions/actionEvent" {
  24589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24590. import { Nullable } from "babylonjs/types";
  24591. import { Sprite } from "babylonjs/Sprites/sprite";
  24592. import { Scene } from "babylonjs/scene";
  24593. import { Vector2 } from "babylonjs/Maths/math";
  24594. /**
  24595. * Interface used to define ActionEvent
  24596. */
  24597. export interface IActionEvent {
  24598. /** The mesh or sprite that triggered the action */
  24599. source: any;
  24600. /** The X mouse cursor position at the time of the event */
  24601. pointerX: number;
  24602. /** The Y mouse cursor position at the time of the event */
  24603. pointerY: number;
  24604. /** The mesh that is currently pointed at (can be null) */
  24605. meshUnderPointer: Nullable<AbstractMesh>;
  24606. /** the original (browser) event that triggered the ActionEvent */
  24607. sourceEvent?: any;
  24608. /** additional data for the event */
  24609. additionalData?: any;
  24610. }
  24611. /**
  24612. * ActionEvent is the event being sent when an action is triggered.
  24613. */
  24614. export class ActionEvent implements IActionEvent {
  24615. /** The mesh or sprite that triggered the action */
  24616. source: any;
  24617. /** The X mouse cursor position at the time of the event */
  24618. pointerX: number;
  24619. /** The Y mouse cursor position at the time of the event */
  24620. pointerY: number;
  24621. /** The mesh that is currently pointed at (can be null) */
  24622. meshUnderPointer: Nullable<AbstractMesh>;
  24623. /** the original (browser) event that triggered the ActionEvent */
  24624. sourceEvent?: any;
  24625. /** additional data for the event */
  24626. additionalData?: any;
  24627. /**
  24628. * Creates a new ActionEvent
  24629. * @param source The mesh or sprite that triggered the action
  24630. * @param pointerX The X mouse cursor position at the time of the event
  24631. * @param pointerY The Y mouse cursor position at the time of the event
  24632. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24633. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24634. * @param additionalData additional data for the event
  24635. */
  24636. constructor(
  24637. /** The mesh or sprite that triggered the action */
  24638. source: any,
  24639. /** The X mouse cursor position at the time of the event */
  24640. pointerX: number,
  24641. /** The Y mouse cursor position at the time of the event */
  24642. pointerY: number,
  24643. /** The mesh that is currently pointed at (can be null) */
  24644. meshUnderPointer: Nullable<AbstractMesh>,
  24645. /** the original (browser) event that triggered the ActionEvent */
  24646. sourceEvent?: any,
  24647. /** additional data for the event */
  24648. additionalData?: any);
  24649. /**
  24650. * Helper function to auto-create an ActionEvent from a source mesh.
  24651. * @param source The source mesh that triggered the event
  24652. * @param evt The original (browser) event
  24653. * @param additionalData additional data for the event
  24654. * @returns the new ActionEvent
  24655. */
  24656. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24657. /**
  24658. * Helper function to auto-create an ActionEvent from a source sprite
  24659. * @param source The source sprite that triggered the event
  24660. * @param scene Scene associated with the sprite
  24661. * @param evt The original (browser) event
  24662. * @param additionalData additional data for the event
  24663. * @returns the new ActionEvent
  24664. */
  24665. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24666. /**
  24667. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24668. * @param scene the scene where the event occurred
  24669. * @param evt The original (browser) event
  24670. * @returns the new ActionEvent
  24671. */
  24672. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24673. /**
  24674. * Helper function to auto-create an ActionEvent from a primitive
  24675. * @param prim defines the target primitive
  24676. * @param pointerPos defines the pointer position
  24677. * @param evt The original (browser) event
  24678. * @param additionalData additional data for the event
  24679. * @returns the new ActionEvent
  24680. */
  24681. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24682. }
  24683. }
  24684. declare module "babylonjs/Actions/abstractActionManager" {
  24685. import { IDisposable } from "babylonjs/scene";
  24686. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  24687. import { IAction } from "babylonjs/Actions/action";
  24688. import { Nullable } from "babylonjs/types";
  24689. /**
  24690. * Abstract class used to decouple action Manager from scene and meshes.
  24691. * Do not instantiate.
  24692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24693. */
  24694. export abstract class AbstractActionManager implements IDisposable {
  24695. /** Gets the list of active triggers */
  24696. static Triggers: {
  24697. [key: string]: number;
  24698. };
  24699. /** Gets the cursor to use when hovering items */
  24700. hoverCursor: string;
  24701. /** Gets the list of actions */
  24702. actions: IAction[];
  24703. /**
  24704. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24705. */
  24706. isRecursive: boolean;
  24707. /**
  24708. * Releases all associated resources
  24709. */
  24710. abstract dispose(): void;
  24711. /**
  24712. * Does this action manager has pointer triggers
  24713. */
  24714. abstract readonly hasPointerTriggers: boolean;
  24715. /**
  24716. * Does this action manager has pick triggers
  24717. */
  24718. abstract readonly hasPickTriggers: boolean;
  24719. /**
  24720. * Process a specific trigger
  24721. * @param trigger defines the trigger to process
  24722. * @param evt defines the event details to be processed
  24723. */
  24724. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24725. /**
  24726. * Does this action manager handles actions of any of the given triggers
  24727. * @param triggers defines the triggers to be tested
  24728. * @return a boolean indicating whether one (or more) of the triggers is handled
  24729. */
  24730. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24731. /**
  24732. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24733. * speed.
  24734. * @param triggerA defines the trigger to be tested
  24735. * @param triggerB defines the trigger to be tested
  24736. * @return a boolean indicating whether one (or more) of the triggers is handled
  24737. */
  24738. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24739. /**
  24740. * Does this action manager handles actions of a given trigger
  24741. * @param trigger defines the trigger to be tested
  24742. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24743. * @return whether the trigger is handled
  24744. */
  24745. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24746. /**
  24747. * Serialize this manager to a JSON object
  24748. * @param name defines the property name to store this manager
  24749. * @returns a JSON representation of this manager
  24750. */
  24751. abstract serialize(name: string): any;
  24752. /**
  24753. * Registers an action to this action manager
  24754. * @param action defines the action to be registered
  24755. * @return the action amended (prepared) after registration
  24756. */
  24757. abstract registerAction(action: IAction): Nullable<IAction>;
  24758. /**
  24759. * Unregisters an action to this action manager
  24760. * @param action defines the action to be unregistered
  24761. * @return a boolean indicating whether the action has been unregistered
  24762. */
  24763. abstract unregisterAction(action: IAction): Boolean;
  24764. /**
  24765. * Does exist one action manager with at least one trigger
  24766. **/
  24767. static readonly HasTriggers: boolean;
  24768. /**
  24769. * Does exist one action manager with at least one pick trigger
  24770. **/
  24771. static readonly HasPickTriggers: boolean;
  24772. /**
  24773. * Does exist one action manager that handles actions of a given trigger
  24774. * @param trigger defines the trigger to be tested
  24775. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24776. **/
  24777. static HasSpecificTrigger(trigger: number): boolean;
  24778. }
  24779. }
  24780. declare module "babylonjs/node" {
  24781. import { Scene } from "babylonjs/scene";
  24782. import { Nullable } from "babylonjs/types";
  24783. import { Matrix } from "babylonjs/Maths/math";
  24784. import { Engine } from "babylonjs/Engines/engine";
  24785. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  24786. import { Observable } from "babylonjs/Misc/observable";
  24787. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24788. import { Animatable } from "babylonjs/Animations/animatable";
  24789. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24790. import { Animation } from "babylonjs/Animations/animation";
  24791. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24793. /**
  24794. * Defines how a node can be built from a string name.
  24795. */
  24796. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24797. /**
  24798. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24799. */
  24800. export class Node implements IBehaviorAware<Node> {
  24801. /** @hidden */
  24802. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  24803. private static _NodeConstructors;
  24804. /**
  24805. * Add a new node constructor
  24806. * @param type defines the type name of the node to construct
  24807. * @param constructorFunc defines the constructor function
  24808. */
  24809. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24810. /**
  24811. * Returns a node constructor based on type name
  24812. * @param type defines the type name
  24813. * @param name defines the new node name
  24814. * @param scene defines the hosting scene
  24815. * @param options defines optional options to transmit to constructors
  24816. * @returns the new constructor or null
  24817. */
  24818. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24819. /**
  24820. * Gets or sets the name of the node
  24821. */
  24822. name: string;
  24823. /**
  24824. * Gets or sets the id of the node
  24825. */
  24826. id: string;
  24827. /**
  24828. * Gets or sets the unique id of the node
  24829. */
  24830. uniqueId: number;
  24831. /**
  24832. * Gets or sets a string used to store user defined state for the node
  24833. */
  24834. state: string;
  24835. /**
  24836. * Gets or sets an object used to store user defined information for the node
  24837. */
  24838. metadata: any;
  24839. /**
  24840. * For internal use only. Please do not use.
  24841. */
  24842. reservedDataStore: any;
  24843. /**
  24844. * Gets or sets a boolean used to define if the node must be serialized
  24845. */
  24846. doNotSerialize: boolean;
  24847. /** @hidden */
  24848. _isDisposed: boolean;
  24849. /**
  24850. * Gets a list of Animations associated with the node
  24851. */
  24852. animations: import("babylonjs/Animations/animation").Animation[];
  24853. protected _ranges: {
  24854. [name: string]: Nullable<AnimationRange>;
  24855. };
  24856. /**
  24857. * Callback raised when the node is ready to be used
  24858. */
  24859. onReady: (node: Node) => void;
  24860. private _isEnabled;
  24861. private _isParentEnabled;
  24862. private _isReady;
  24863. /** @hidden */
  24864. _currentRenderId: number;
  24865. private _parentRenderId;
  24866. protected _childRenderId: number;
  24867. /** @hidden */
  24868. _waitingParentId: Nullable<string>;
  24869. /** @hidden */
  24870. _scene: Scene;
  24871. /** @hidden */
  24872. _cache: any;
  24873. private _parentNode;
  24874. private _children;
  24875. /** @hidden */
  24876. _worldMatrix: Matrix;
  24877. /** @hidden */
  24878. _worldMatrixDeterminant: number;
  24879. /** @hidden */
  24880. private _sceneRootNodesIndex;
  24881. /**
  24882. * Gets a boolean indicating if the node has been disposed
  24883. * @returns true if the node was disposed
  24884. */
  24885. isDisposed(): boolean;
  24886. /**
  24887. * Gets or sets the parent of the node
  24888. */
  24889. parent: Nullable<Node>;
  24890. private addToSceneRootNodes;
  24891. private removeFromSceneRootNodes;
  24892. private _animationPropertiesOverride;
  24893. /**
  24894. * Gets or sets the animation properties override
  24895. */
  24896. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24897. /**
  24898. * Gets a string idenfifying the name of the class
  24899. * @returns "Node" string
  24900. */
  24901. getClassName(): string;
  24902. /** @hidden */
  24903. readonly _isNode: boolean;
  24904. /**
  24905. * An event triggered when the mesh is disposed
  24906. */
  24907. onDisposeObservable: Observable<Node>;
  24908. private _onDisposeObserver;
  24909. /**
  24910. * Sets a callback that will be raised when the node will be disposed
  24911. */
  24912. onDispose: () => void;
  24913. /**
  24914. * Creates a new Node
  24915. * @param name the name and id to be given to this node
  24916. * @param scene the scene this node will be added to
  24917. * @param addToRootNodes the node will be added to scene.rootNodes
  24918. */
  24919. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24920. /**
  24921. * Gets the scene of the node
  24922. * @returns a scene
  24923. */
  24924. getScene(): Scene;
  24925. /**
  24926. * Gets the engine of the node
  24927. * @returns a Engine
  24928. */
  24929. getEngine(): Engine;
  24930. private _behaviors;
  24931. /**
  24932. * Attach a behavior to the node
  24933. * @see http://doc.babylonjs.com/features/behaviour
  24934. * @param behavior defines the behavior to attach
  24935. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24936. * @returns the current Node
  24937. */
  24938. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24939. /**
  24940. * Remove an attached behavior
  24941. * @see http://doc.babylonjs.com/features/behaviour
  24942. * @param behavior defines the behavior to attach
  24943. * @returns the current Node
  24944. */
  24945. removeBehavior(behavior: Behavior<Node>): Node;
  24946. /**
  24947. * Gets the list of attached behaviors
  24948. * @see http://doc.babylonjs.com/features/behaviour
  24949. */
  24950. readonly behaviors: Behavior<Node>[];
  24951. /**
  24952. * Gets an attached behavior by name
  24953. * @param name defines the name of the behavior to look for
  24954. * @see http://doc.babylonjs.com/features/behaviour
  24955. * @returns null if behavior was not found else the requested behavior
  24956. */
  24957. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24958. /**
  24959. * Returns the latest update of the World matrix
  24960. * @returns a Matrix
  24961. */
  24962. getWorldMatrix(): Matrix;
  24963. /** @hidden */
  24964. _getWorldMatrixDeterminant(): number;
  24965. /**
  24966. * Returns directly the latest state of the mesh World matrix.
  24967. * A Matrix is returned.
  24968. */
  24969. readonly worldMatrixFromCache: Matrix;
  24970. /** @hidden */
  24971. _initCache(): void;
  24972. /** @hidden */
  24973. updateCache(force?: boolean): void;
  24974. /** @hidden */
  24975. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24976. /** @hidden */
  24977. _updateCache(ignoreParentClass?: boolean): void;
  24978. /** @hidden */
  24979. _isSynchronized(): boolean;
  24980. /** @hidden */
  24981. _markSyncedWithParent(): void;
  24982. /** @hidden */
  24983. isSynchronizedWithParent(): boolean;
  24984. /** @hidden */
  24985. isSynchronized(): boolean;
  24986. /**
  24987. * Is this node ready to be used/rendered
  24988. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24989. * @return true if the node is ready
  24990. */
  24991. isReady(completeCheck?: boolean): boolean;
  24992. /**
  24993. * Is this node enabled?
  24994. * 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
  24995. * @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
  24996. * @return whether this node (and its parent) is enabled
  24997. */
  24998. isEnabled(checkAncestors?: boolean): boolean;
  24999. /** @hidden */
  25000. protected _syncParentEnabledState(): void;
  25001. /**
  25002. * Set the enabled state of this node
  25003. * @param value defines the new enabled state
  25004. */
  25005. setEnabled(value: boolean): void;
  25006. /**
  25007. * Is this node a descendant of the given node?
  25008. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25009. * @param ancestor defines the parent node to inspect
  25010. * @returns a boolean indicating if this node is a descendant of the given node
  25011. */
  25012. isDescendantOf(ancestor: Node): boolean;
  25013. /** @hidden */
  25014. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25015. /**
  25016. * Will return all nodes that have this node as ascendant
  25017. * @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
  25018. * @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
  25019. * @return all children nodes of all types
  25020. */
  25021. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25022. /**
  25023. * Get all child-meshes of this node
  25024. * @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)
  25025. * @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
  25026. * @returns an array of AbstractMesh
  25027. */
  25028. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25029. /**
  25030. * Get all direct children of this node
  25031. * @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
  25032. * @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)
  25033. * @returns an array of Node
  25034. */
  25035. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25036. /** @hidden */
  25037. _setReady(state: boolean): void;
  25038. /**
  25039. * Get an animation by name
  25040. * @param name defines the name of the animation to look for
  25041. * @returns null if not found else the requested animation
  25042. */
  25043. getAnimationByName(name: string): Nullable<Animation>;
  25044. /**
  25045. * Creates an animation range for this node
  25046. * @param name defines the name of the range
  25047. * @param from defines the starting key
  25048. * @param to defines the end key
  25049. */
  25050. createAnimationRange(name: string, from: number, to: number): void;
  25051. /**
  25052. * Delete a specific animation range
  25053. * @param name defines the name of the range to delete
  25054. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25055. */
  25056. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25057. /**
  25058. * Get an animation range by name
  25059. * @param name defines the name of the animation range to look for
  25060. * @returns null if not found else the requested animation range
  25061. */
  25062. getAnimationRange(name: string): Nullable<AnimationRange>;
  25063. /**
  25064. * Gets the list of all animation ranges defined on this node
  25065. * @returns an array
  25066. */
  25067. getAnimationRanges(): Nullable<AnimationRange>[];
  25068. /**
  25069. * Will start the animation sequence
  25070. * @param name defines the range frames for animation sequence
  25071. * @param loop defines if the animation should loop (false by default)
  25072. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25073. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25074. * @returns the object created for this animation. If range does not exist, it will return null
  25075. */
  25076. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25077. /**
  25078. * Serialize animation ranges into a JSON compatible object
  25079. * @returns serialization object
  25080. */
  25081. serializeAnimationRanges(): any;
  25082. /**
  25083. * Computes the world matrix of the node
  25084. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25085. * @returns the world matrix
  25086. */
  25087. computeWorldMatrix(force?: boolean): Matrix;
  25088. /**
  25089. * Releases resources associated with this node.
  25090. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25091. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25092. */
  25093. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25094. /**
  25095. * Parse animation range data from a serialization object and store them into a given node
  25096. * @param node defines where to store the animation ranges
  25097. * @param parsedNode defines the serialization object to read data from
  25098. * @param scene defines the hosting scene
  25099. */
  25100. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25101. }
  25102. }
  25103. declare module "babylonjs/Animations/animation" {
  25104. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25105. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25106. import { Nullable } from "babylonjs/types";
  25107. import { Scene } from "babylonjs/scene";
  25108. import { IAnimatable } from "babylonjs/Misc/tools";
  25109. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25110. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25111. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25112. import { Node } from "babylonjs/node";
  25113. import { Animatable } from "babylonjs/Animations/animatable";
  25114. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25115. /**
  25116. * Class used to store any kind of animation
  25117. */
  25118. export class Animation {
  25119. /**Name of the animation */
  25120. name: string;
  25121. /**Property to animate */
  25122. targetProperty: string;
  25123. /**The frames per second of the animation */
  25124. framePerSecond: number;
  25125. /**The data type of the animation */
  25126. dataType: number;
  25127. /**The loop mode of the animation */
  25128. loopMode?: number | undefined;
  25129. /**Specifies if blending should be enabled */
  25130. enableBlending?: boolean | undefined;
  25131. /**
  25132. * Use matrix interpolation instead of using direct key value when animating matrices
  25133. */
  25134. static AllowMatricesInterpolation: boolean;
  25135. /**
  25136. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25137. */
  25138. static AllowMatrixDecomposeForInterpolation: boolean;
  25139. /**
  25140. * Stores the key frames of the animation
  25141. */
  25142. private _keys;
  25143. /**
  25144. * Stores the easing function of the animation
  25145. */
  25146. private _easingFunction;
  25147. /**
  25148. * @hidden Internal use only
  25149. */
  25150. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25151. /**
  25152. * The set of event that will be linked to this animation
  25153. */
  25154. private _events;
  25155. /**
  25156. * Stores an array of target property paths
  25157. */
  25158. targetPropertyPath: string[];
  25159. /**
  25160. * Stores the blending speed of the animation
  25161. */
  25162. blendingSpeed: number;
  25163. /**
  25164. * Stores the animation ranges for the animation
  25165. */
  25166. private _ranges;
  25167. /**
  25168. * @hidden Internal use
  25169. */
  25170. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25171. /**
  25172. * Sets up an animation
  25173. * @param property The property to animate
  25174. * @param animationType The animation type to apply
  25175. * @param framePerSecond The frames per second of the animation
  25176. * @param easingFunction The easing function used in the animation
  25177. * @returns The created animation
  25178. */
  25179. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25180. /**
  25181. * Create and start an animation on a node
  25182. * @param name defines the name of the global animation that will be run on all nodes
  25183. * @param node defines the root node where the animation will take place
  25184. * @param targetProperty defines property to animate
  25185. * @param framePerSecond defines the number of frame per second yo use
  25186. * @param totalFrame defines the number of frames in total
  25187. * @param from defines the initial value
  25188. * @param to defines the final value
  25189. * @param loopMode defines which loop mode you want to use (off by default)
  25190. * @param easingFunction defines the easing function to use (linear by default)
  25191. * @param onAnimationEnd defines the callback to call when animation end
  25192. * @returns the animatable created for this animation
  25193. */
  25194. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25195. /**
  25196. * Create and start an animation on a node and its descendants
  25197. * @param name defines the name of the global animation that will be run on all nodes
  25198. * @param node defines the root node where the animation will take place
  25199. * @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
  25200. * @param targetProperty defines property to animate
  25201. * @param framePerSecond defines the number of frame per second to use
  25202. * @param totalFrame defines the number of frames in total
  25203. * @param from defines the initial value
  25204. * @param to defines the final value
  25205. * @param loopMode defines which loop mode you want to use (off by default)
  25206. * @param easingFunction defines the easing function to use (linear by default)
  25207. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25208. * @returns the list of animatables created for all nodes
  25209. * @example https://www.babylonjs-playground.com/#MH0VLI
  25210. */
  25211. 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[]>;
  25212. /**
  25213. * Creates a new animation, merges it with the existing animations and starts it
  25214. * @param name Name of the animation
  25215. * @param node Node which contains the scene that begins the animations
  25216. * @param targetProperty Specifies which property to animate
  25217. * @param framePerSecond The frames per second of the animation
  25218. * @param totalFrame The total number of frames
  25219. * @param from The frame at the beginning of the animation
  25220. * @param to The frame at the end of the animation
  25221. * @param loopMode Specifies the loop mode of the animation
  25222. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25223. * @param onAnimationEnd Callback to run once the animation is complete
  25224. * @returns Nullable animation
  25225. */
  25226. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25227. /**
  25228. * Transition property of an host to the target Value
  25229. * @param property The property to transition
  25230. * @param targetValue The target Value of the property
  25231. * @param host The object where the property to animate belongs
  25232. * @param scene Scene used to run the animation
  25233. * @param frameRate Framerate (in frame/s) to use
  25234. * @param transition The transition type we want to use
  25235. * @param duration The duration of the animation, in milliseconds
  25236. * @param onAnimationEnd Callback trigger at the end of the animation
  25237. * @returns Nullable animation
  25238. */
  25239. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25240. /**
  25241. * Return the array of runtime animations currently using this animation
  25242. */
  25243. readonly runtimeAnimations: RuntimeAnimation[];
  25244. /**
  25245. * Specifies if any of the runtime animations are currently running
  25246. */
  25247. readonly hasRunningRuntimeAnimations: boolean;
  25248. /**
  25249. * Initializes the animation
  25250. * @param name Name of the animation
  25251. * @param targetProperty Property to animate
  25252. * @param framePerSecond The frames per second of the animation
  25253. * @param dataType The data type of the animation
  25254. * @param loopMode The loop mode of the animation
  25255. * @param enableBlending Specifies if blending should be enabled
  25256. */
  25257. constructor(
  25258. /**Name of the animation */
  25259. name: string,
  25260. /**Property to animate */
  25261. targetProperty: string,
  25262. /**The frames per second of the animation */
  25263. framePerSecond: number,
  25264. /**The data type of the animation */
  25265. dataType: number,
  25266. /**The loop mode of the animation */
  25267. loopMode?: number | undefined,
  25268. /**Specifies if blending should be enabled */
  25269. enableBlending?: boolean | undefined);
  25270. /**
  25271. * Converts the animation to a string
  25272. * @param fullDetails support for multiple levels of logging within scene loading
  25273. * @returns String form of the animation
  25274. */
  25275. toString(fullDetails?: boolean): string;
  25276. /**
  25277. * Add an event to this animation
  25278. * @param event Event to add
  25279. */
  25280. addEvent(event: AnimationEvent): void;
  25281. /**
  25282. * Remove all events found at the given frame
  25283. * @param frame The frame to remove events from
  25284. */
  25285. removeEvents(frame: number): void;
  25286. /**
  25287. * Retrieves all the events from the animation
  25288. * @returns Events from the animation
  25289. */
  25290. getEvents(): AnimationEvent[];
  25291. /**
  25292. * Creates an animation range
  25293. * @param name Name of the animation range
  25294. * @param from Starting frame of the animation range
  25295. * @param to Ending frame of the animation
  25296. */
  25297. createRange(name: string, from: number, to: number): void;
  25298. /**
  25299. * Deletes an animation range by name
  25300. * @param name Name of the animation range to delete
  25301. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25302. */
  25303. deleteRange(name: string, deleteFrames?: boolean): void;
  25304. /**
  25305. * Gets the animation range by name, or null if not defined
  25306. * @param name Name of the animation range
  25307. * @returns Nullable animation range
  25308. */
  25309. getRange(name: string): Nullable<AnimationRange>;
  25310. /**
  25311. * Gets the key frames from the animation
  25312. * @returns The key frames of the animation
  25313. */
  25314. getKeys(): Array<IAnimationKey>;
  25315. /**
  25316. * Gets the highest frame rate of the animation
  25317. * @returns Highest frame rate of the animation
  25318. */
  25319. getHighestFrame(): number;
  25320. /**
  25321. * Gets the easing function of the animation
  25322. * @returns Easing function of the animation
  25323. */
  25324. getEasingFunction(): IEasingFunction;
  25325. /**
  25326. * Sets the easing function of the animation
  25327. * @param easingFunction A custom mathematical formula for animation
  25328. */
  25329. setEasingFunction(easingFunction: EasingFunction): void;
  25330. /**
  25331. * Interpolates a scalar linearly
  25332. * @param startValue Start value of the animation curve
  25333. * @param endValue End value of the animation curve
  25334. * @param gradient Scalar amount to interpolate
  25335. * @returns Interpolated scalar value
  25336. */
  25337. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25338. /**
  25339. * Interpolates a scalar cubically
  25340. * @param startValue Start value of the animation curve
  25341. * @param outTangent End tangent of the animation
  25342. * @param endValue End value of the animation curve
  25343. * @param inTangent Start tangent of the animation curve
  25344. * @param gradient Scalar amount to interpolate
  25345. * @returns Interpolated scalar value
  25346. */
  25347. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25348. /**
  25349. * Interpolates a quaternion using a spherical linear interpolation
  25350. * @param startValue Start value of the animation curve
  25351. * @param endValue End value of the animation curve
  25352. * @param gradient Scalar amount to interpolate
  25353. * @returns Interpolated quaternion value
  25354. */
  25355. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25356. /**
  25357. * Interpolates a quaternion cubically
  25358. * @param startValue Start value of the animation curve
  25359. * @param outTangent End tangent of the animation curve
  25360. * @param endValue End value of the animation curve
  25361. * @param inTangent Start tangent of the animation curve
  25362. * @param gradient Scalar amount to interpolate
  25363. * @returns Interpolated quaternion value
  25364. */
  25365. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25366. /**
  25367. * Interpolates a Vector3 linearl
  25368. * @param startValue Start value of the animation curve
  25369. * @param endValue End value of the animation curve
  25370. * @param gradient Scalar amount to interpolate
  25371. * @returns Interpolated scalar value
  25372. */
  25373. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25374. /**
  25375. * Interpolates a Vector3 cubically
  25376. * @param startValue Start value of the animation curve
  25377. * @param outTangent End tangent of the animation
  25378. * @param endValue End value of the animation curve
  25379. * @param inTangent Start tangent of the animation curve
  25380. * @param gradient Scalar amount to interpolate
  25381. * @returns InterpolatedVector3 value
  25382. */
  25383. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25384. /**
  25385. * Interpolates a Vector2 linearly
  25386. * @param startValue Start value of the animation curve
  25387. * @param endValue End value of the animation curve
  25388. * @param gradient Scalar amount to interpolate
  25389. * @returns Interpolated Vector2 value
  25390. */
  25391. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25392. /**
  25393. * Interpolates a Vector2 cubically
  25394. * @param startValue Start value of the animation curve
  25395. * @param outTangent End tangent of the animation
  25396. * @param endValue End value of the animation curve
  25397. * @param inTangent Start tangent of the animation curve
  25398. * @param gradient Scalar amount to interpolate
  25399. * @returns Interpolated Vector2 value
  25400. */
  25401. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25402. /**
  25403. * Interpolates a size linearly
  25404. * @param startValue Start value of the animation curve
  25405. * @param endValue End value of the animation curve
  25406. * @param gradient Scalar amount to interpolate
  25407. * @returns Interpolated Size value
  25408. */
  25409. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25410. /**
  25411. * Interpolates a Color3 linearly
  25412. * @param startValue Start value of the animation curve
  25413. * @param endValue End value of the animation curve
  25414. * @param gradient Scalar amount to interpolate
  25415. * @returns Interpolated Color3 value
  25416. */
  25417. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25418. /**
  25419. * @hidden Internal use only
  25420. */
  25421. _getKeyValue(value: any): any;
  25422. /**
  25423. * @hidden Internal use only
  25424. */
  25425. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25426. /**
  25427. * Defines the function to use to interpolate matrices
  25428. * @param startValue defines the start matrix
  25429. * @param endValue defines the end matrix
  25430. * @param gradient defines the gradient between both matrices
  25431. * @param result defines an optional target matrix where to store the interpolation
  25432. * @returns the interpolated matrix
  25433. */
  25434. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25435. /**
  25436. * Makes a copy of the animation
  25437. * @returns Cloned animation
  25438. */
  25439. clone(): Animation;
  25440. /**
  25441. * Sets the key frames of the animation
  25442. * @param values The animation key frames to set
  25443. */
  25444. setKeys(values: Array<IAnimationKey>): void;
  25445. /**
  25446. * Serializes the animation to an object
  25447. * @returns Serialized object
  25448. */
  25449. serialize(): any;
  25450. /**
  25451. * Float animation type
  25452. */
  25453. private static _ANIMATIONTYPE_FLOAT;
  25454. /**
  25455. * Vector3 animation type
  25456. */
  25457. private static _ANIMATIONTYPE_VECTOR3;
  25458. /**
  25459. * Quaternion animation type
  25460. */
  25461. private static _ANIMATIONTYPE_QUATERNION;
  25462. /**
  25463. * Matrix animation type
  25464. */
  25465. private static _ANIMATIONTYPE_MATRIX;
  25466. /**
  25467. * Color3 animation type
  25468. */
  25469. private static _ANIMATIONTYPE_COLOR3;
  25470. /**
  25471. * Vector2 animation type
  25472. */
  25473. private static _ANIMATIONTYPE_VECTOR2;
  25474. /**
  25475. * Size animation type
  25476. */
  25477. private static _ANIMATIONTYPE_SIZE;
  25478. /**
  25479. * Relative Loop Mode
  25480. */
  25481. private static _ANIMATIONLOOPMODE_RELATIVE;
  25482. /**
  25483. * Cycle Loop Mode
  25484. */
  25485. private static _ANIMATIONLOOPMODE_CYCLE;
  25486. /**
  25487. * Constant Loop Mode
  25488. */
  25489. private static _ANIMATIONLOOPMODE_CONSTANT;
  25490. /**
  25491. * Get the float animation type
  25492. */
  25493. static readonly ANIMATIONTYPE_FLOAT: number;
  25494. /**
  25495. * Get the Vector3 animation type
  25496. */
  25497. static readonly ANIMATIONTYPE_VECTOR3: number;
  25498. /**
  25499. * Get the Vector2 animation type
  25500. */
  25501. static readonly ANIMATIONTYPE_VECTOR2: number;
  25502. /**
  25503. * Get the Size animation type
  25504. */
  25505. static readonly ANIMATIONTYPE_SIZE: number;
  25506. /**
  25507. * Get the Quaternion animation type
  25508. */
  25509. static readonly ANIMATIONTYPE_QUATERNION: number;
  25510. /**
  25511. * Get the Matrix animation type
  25512. */
  25513. static readonly ANIMATIONTYPE_MATRIX: number;
  25514. /**
  25515. * Get the Color3 animation type
  25516. */
  25517. static readonly ANIMATIONTYPE_COLOR3: number;
  25518. /**
  25519. * Get the Relative Loop Mode
  25520. */
  25521. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25522. /**
  25523. * Get the Cycle Loop Mode
  25524. */
  25525. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25526. /**
  25527. * Get the Constant Loop Mode
  25528. */
  25529. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25530. /** @hidden */
  25531. static _UniversalLerp(left: any, right: any, amount: number): any;
  25532. /**
  25533. * Parses an animation object and creates an animation
  25534. * @param parsedAnimation Parsed animation object
  25535. * @returns Animation object
  25536. */
  25537. static Parse(parsedAnimation: any): Animation;
  25538. /**
  25539. * Appends the serialized animations from the source animations
  25540. * @param source Source containing the animations
  25541. * @param destination Target to store the animations
  25542. */
  25543. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25544. }
  25545. }
  25546. declare module "babylonjs/Materials/Textures/baseTexture" {
  25547. import { Observable } from "babylonjs/Misc/observable";
  25548. import { IAnimatable } from "babylonjs/Misc/tools";
  25549. import { Nullable } from "babylonjs/types";
  25550. import { Scene } from "babylonjs/scene";
  25551. import { Matrix, ISize } from "babylonjs/Maths/math";
  25552. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25553. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25554. /**
  25555. * Base class of all the textures in babylon.
  25556. * It groups all the common properties the materials, post process, lights... might need
  25557. * in order to make a correct use of the texture.
  25558. */
  25559. export class BaseTexture implements IAnimatable {
  25560. /**
  25561. * Default anisotropic filtering level for the application.
  25562. * It is set to 4 as a good tradeoff between perf and quality.
  25563. */
  25564. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25565. /**
  25566. * Gets or sets the unique id of the texture
  25567. */
  25568. uniqueId: number;
  25569. /**
  25570. * Define the name of the texture.
  25571. */
  25572. name: string;
  25573. /**
  25574. * Gets or sets an object used to store user defined information.
  25575. */
  25576. metadata: any;
  25577. /**
  25578. * For internal use only. Please do not use.
  25579. */
  25580. reservedDataStore: any;
  25581. private _hasAlpha;
  25582. /**
  25583. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25584. */
  25585. hasAlpha: boolean;
  25586. /**
  25587. * Defines if the alpha value should be determined via the rgb values.
  25588. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25589. */
  25590. getAlphaFromRGB: boolean;
  25591. /**
  25592. * Intensity or strength of the texture.
  25593. * It is commonly used by materials to fine tune the intensity of the texture
  25594. */
  25595. level: number;
  25596. /**
  25597. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25598. * This is part of the texture as textures usually maps to one uv set.
  25599. */
  25600. coordinatesIndex: number;
  25601. private _coordinatesMode;
  25602. /**
  25603. * How a texture is mapped.
  25604. *
  25605. * | Value | Type | Description |
  25606. * | ----- | ----------------------------------- | ----------- |
  25607. * | 0 | EXPLICIT_MODE | |
  25608. * | 1 | SPHERICAL_MODE | |
  25609. * | 2 | PLANAR_MODE | |
  25610. * | 3 | CUBIC_MODE | |
  25611. * | 4 | PROJECTION_MODE | |
  25612. * | 5 | SKYBOX_MODE | |
  25613. * | 6 | INVCUBIC_MODE | |
  25614. * | 7 | EQUIRECTANGULAR_MODE | |
  25615. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25616. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25617. */
  25618. coordinatesMode: number;
  25619. /**
  25620. * | Value | Type | Description |
  25621. * | ----- | ------------------ | ----------- |
  25622. * | 0 | CLAMP_ADDRESSMODE | |
  25623. * | 1 | WRAP_ADDRESSMODE | |
  25624. * | 2 | MIRROR_ADDRESSMODE | |
  25625. */
  25626. wrapU: number;
  25627. /**
  25628. * | Value | Type | Description |
  25629. * | ----- | ------------------ | ----------- |
  25630. * | 0 | CLAMP_ADDRESSMODE | |
  25631. * | 1 | WRAP_ADDRESSMODE | |
  25632. * | 2 | MIRROR_ADDRESSMODE | |
  25633. */
  25634. wrapV: number;
  25635. /**
  25636. * | Value | Type | Description |
  25637. * | ----- | ------------------ | ----------- |
  25638. * | 0 | CLAMP_ADDRESSMODE | |
  25639. * | 1 | WRAP_ADDRESSMODE | |
  25640. * | 2 | MIRROR_ADDRESSMODE | |
  25641. */
  25642. wrapR: number;
  25643. /**
  25644. * With compliant hardware and browser (supporting anisotropic filtering)
  25645. * this defines the level of anisotropic filtering in the texture.
  25646. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25647. */
  25648. anisotropicFilteringLevel: number;
  25649. /**
  25650. * Define if the texture is a cube texture or if false a 2d texture.
  25651. */
  25652. isCube: boolean;
  25653. /**
  25654. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25655. */
  25656. is3D: boolean;
  25657. /**
  25658. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25659. * HDR texture are usually stored in linear space.
  25660. * This only impacts the PBR and Background materials
  25661. */
  25662. gammaSpace: boolean;
  25663. /**
  25664. * Gets whether or not the texture contains RGBD data.
  25665. */
  25666. readonly isRGBD: boolean;
  25667. /**
  25668. * Is Z inverted in the texture (useful in a cube texture).
  25669. */
  25670. invertZ: boolean;
  25671. /**
  25672. * Are mip maps generated for this texture or not.
  25673. */
  25674. readonly noMipmap: boolean;
  25675. /**
  25676. * @hidden
  25677. */
  25678. lodLevelInAlpha: boolean;
  25679. /**
  25680. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25681. */
  25682. lodGenerationOffset: number;
  25683. /**
  25684. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25685. */
  25686. lodGenerationScale: number;
  25687. /**
  25688. * Define if the texture is a render target.
  25689. */
  25690. isRenderTarget: boolean;
  25691. /**
  25692. * Define the unique id of the texture in the scene.
  25693. */
  25694. readonly uid: string;
  25695. /**
  25696. * Return a string representation of the texture.
  25697. * @returns the texture as a string
  25698. */
  25699. toString(): string;
  25700. /**
  25701. * Get the class name of the texture.
  25702. * @returns "BaseTexture"
  25703. */
  25704. getClassName(): string;
  25705. /**
  25706. * Define the list of animation attached to the texture.
  25707. */
  25708. animations: import("babylonjs/Animations/animation").Animation[];
  25709. /**
  25710. * An event triggered when the texture is disposed.
  25711. */
  25712. onDisposeObservable: Observable<BaseTexture>;
  25713. private _onDisposeObserver;
  25714. /**
  25715. * Callback triggered when the texture has been disposed.
  25716. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25717. */
  25718. onDispose: () => void;
  25719. /**
  25720. * Define the current state of the loading sequence when in delayed load mode.
  25721. */
  25722. delayLoadState: number;
  25723. private _scene;
  25724. /** @hidden */
  25725. _texture: Nullable<InternalTexture>;
  25726. private _uid;
  25727. /**
  25728. * Define if the texture is preventinga material to render or not.
  25729. * If not and the texture is not ready, the engine will use a default black texture instead.
  25730. */
  25731. readonly isBlocking: boolean;
  25732. /**
  25733. * Instantiates a new BaseTexture.
  25734. * Base class of all the textures in babylon.
  25735. * It groups all the common properties the materials, post process, lights... might need
  25736. * in order to make a correct use of the texture.
  25737. * @param scene Define the scene the texture blongs to
  25738. */
  25739. constructor(scene: Nullable<Scene>);
  25740. /**
  25741. * Get the scene the texture belongs to.
  25742. * @returns the scene or null if undefined
  25743. */
  25744. getScene(): Nullable<Scene>;
  25745. /**
  25746. * Get the texture transform matrix used to offset tile the texture for istance.
  25747. * @returns the transformation matrix
  25748. */
  25749. getTextureMatrix(): Matrix;
  25750. /**
  25751. * Get the texture reflection matrix used to rotate/transform the reflection.
  25752. * @returns the reflection matrix
  25753. */
  25754. getReflectionTextureMatrix(): Matrix;
  25755. /**
  25756. * Get the underlying lower level texture from Babylon.
  25757. * @returns the insternal texture
  25758. */
  25759. getInternalTexture(): Nullable<InternalTexture>;
  25760. /**
  25761. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25762. * @returns true if ready or not blocking
  25763. */
  25764. isReadyOrNotBlocking(): boolean;
  25765. /**
  25766. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25767. * @returns true if fully ready
  25768. */
  25769. isReady(): boolean;
  25770. private _cachedSize;
  25771. /**
  25772. * Get the size of the texture.
  25773. * @returns the texture size.
  25774. */
  25775. getSize(): ISize;
  25776. /**
  25777. * Get the base size of the texture.
  25778. * It can be different from the size if the texture has been resized for POT for instance
  25779. * @returns the base size
  25780. */
  25781. getBaseSize(): ISize;
  25782. /**
  25783. * Update the sampling mode of the texture.
  25784. * Default is Trilinear mode.
  25785. *
  25786. * | Value | Type | Description |
  25787. * | ----- | ------------------ | ----------- |
  25788. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25789. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25790. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25791. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25792. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25793. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25794. * | 7 | NEAREST_LINEAR | |
  25795. * | 8 | NEAREST_NEAREST | |
  25796. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25797. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25798. * | 11 | LINEAR_LINEAR | |
  25799. * | 12 | LINEAR_NEAREST | |
  25800. *
  25801. * > _mag_: magnification filter (close to the viewer)
  25802. * > _min_: minification filter (far from the viewer)
  25803. * > _mip_: filter used between mip map levels
  25804. *@param samplingMode Define the new sampling mode of the texture
  25805. */
  25806. updateSamplingMode(samplingMode: number): void;
  25807. /**
  25808. * Scales the texture if is `canRescale()`
  25809. * @param ratio the resize factor we want to use to rescale
  25810. */
  25811. scale(ratio: number): void;
  25812. /**
  25813. * Get if the texture can rescale.
  25814. */
  25815. readonly canRescale: boolean;
  25816. /** @hidden */
  25817. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25818. /** @hidden */
  25819. _rebuild(): void;
  25820. /**
  25821. * Triggers the load sequence in delayed load mode.
  25822. */
  25823. delayLoad(): void;
  25824. /**
  25825. * Clones the texture.
  25826. * @returns the cloned texture
  25827. */
  25828. clone(): Nullable<BaseTexture>;
  25829. /**
  25830. * Get the texture underlying type (INT, FLOAT...)
  25831. */
  25832. readonly textureType: number;
  25833. /**
  25834. * Get the texture underlying format (RGB, RGBA...)
  25835. */
  25836. readonly textureFormat: number;
  25837. /**
  25838. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25839. * This will returns an RGBA array buffer containing either in values (0-255) or
  25840. * float values (0-1) depending of the underlying buffer type.
  25841. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25842. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25843. * @param buffer defines a user defined buffer to fill with data (can be null)
  25844. * @returns The Array buffer containing the pixels data.
  25845. */
  25846. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25847. /**
  25848. * Release and destroy the underlying lower level texture aka internalTexture.
  25849. */
  25850. releaseInternalTexture(): void;
  25851. /**
  25852. * Get the polynomial representation of the texture data.
  25853. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25854. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25855. */
  25856. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25857. /** @hidden */
  25858. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25859. /** @hidden */
  25860. readonly _lodTextureMid: Nullable<BaseTexture>;
  25861. /** @hidden */
  25862. readonly _lodTextureLow: Nullable<BaseTexture>;
  25863. /**
  25864. * Dispose the texture and release its associated resources.
  25865. */
  25866. dispose(): void;
  25867. /**
  25868. * Serialize the texture into a JSON representation that can be parsed later on.
  25869. * @returns the JSON representation of the texture
  25870. */
  25871. serialize(): any;
  25872. /**
  25873. * Helper function to be called back once a list of texture contains only ready textures.
  25874. * @param textures Define the list of textures to wait for
  25875. * @param callback Define the callback triggered once the entire list will be ready
  25876. */
  25877. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25878. }
  25879. }
  25880. declare module "babylonjs/Materials/uniformBuffer" {
  25881. import { Nullable, FloatArray } from "babylonjs/types";
  25882. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  25883. import { Engine } from "babylonjs/Engines/engine";
  25884. import { Effect } from "babylonjs/Materials/effect";
  25885. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25886. /**
  25887. * Uniform buffer objects.
  25888. *
  25889. * Handles blocks of uniform on the GPU.
  25890. *
  25891. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25892. *
  25893. * For more information, please refer to :
  25894. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25895. */
  25896. export class UniformBuffer {
  25897. private _engine;
  25898. private _buffer;
  25899. private _data;
  25900. private _bufferData;
  25901. private _dynamic?;
  25902. private _uniformLocations;
  25903. private _uniformSizes;
  25904. private _uniformLocationPointer;
  25905. private _needSync;
  25906. private _noUBO;
  25907. private _currentEffect;
  25908. private static _MAX_UNIFORM_SIZE;
  25909. private static _tempBuffer;
  25910. /**
  25911. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25912. * This is dynamic to allow compat with webgl 1 and 2.
  25913. * You will need to pass the name of the uniform as well as the value.
  25914. */
  25915. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25916. /**
  25917. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25918. * This is dynamic to allow compat with webgl 1 and 2.
  25919. * You will need to pass the name of the uniform as well as the value.
  25920. */
  25921. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25922. /**
  25923. * Lambda to Update a single float in a uniform buffer.
  25924. * This is dynamic to allow compat with webgl 1 and 2.
  25925. * You will need to pass the name of the uniform as well as the value.
  25926. */
  25927. updateFloat: (name: string, x: number) => void;
  25928. /**
  25929. * Lambda to Update a vec2 of float in a uniform buffer.
  25930. * This is dynamic to allow compat with webgl 1 and 2.
  25931. * You will need to pass the name of the uniform as well as the value.
  25932. */
  25933. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25934. /**
  25935. * Lambda to Update a vec3 of float in a uniform buffer.
  25936. * This is dynamic to allow compat with webgl 1 and 2.
  25937. * You will need to pass the name of the uniform as well as the value.
  25938. */
  25939. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25940. /**
  25941. * Lambda to Update a vec4 of float in a uniform buffer.
  25942. * This is dynamic to allow compat with webgl 1 and 2.
  25943. * You will need to pass the name of the uniform as well as the value.
  25944. */
  25945. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25946. /**
  25947. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25948. * This is dynamic to allow compat with webgl 1 and 2.
  25949. * You will need to pass the name of the uniform as well as the value.
  25950. */
  25951. updateMatrix: (name: string, mat: Matrix) => void;
  25952. /**
  25953. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25954. * This is dynamic to allow compat with webgl 1 and 2.
  25955. * You will need to pass the name of the uniform as well as the value.
  25956. */
  25957. updateVector3: (name: string, vector: Vector3) => void;
  25958. /**
  25959. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25960. * This is dynamic to allow compat with webgl 1 and 2.
  25961. * You will need to pass the name of the uniform as well as the value.
  25962. */
  25963. updateVector4: (name: string, vector: Vector4) => void;
  25964. /**
  25965. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25966. * This is dynamic to allow compat with webgl 1 and 2.
  25967. * You will need to pass the name of the uniform as well as the value.
  25968. */
  25969. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25970. /**
  25971. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25972. * This is dynamic to allow compat with webgl 1 and 2.
  25973. * You will need to pass the name of the uniform as well as the value.
  25974. */
  25975. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25976. /**
  25977. * Instantiates a new Uniform buffer objects.
  25978. *
  25979. * Handles blocks of uniform on the GPU.
  25980. *
  25981. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25982. *
  25983. * For more information, please refer to :
  25984. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25985. * @param engine Define the engine the buffer is associated with
  25986. * @param data Define the data contained in the buffer
  25987. * @param dynamic Define if the buffer is updatable
  25988. */
  25989. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25990. /**
  25991. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25992. * or just falling back on setUniformXXX calls.
  25993. */
  25994. readonly useUbo: boolean;
  25995. /**
  25996. * Indicates if the WebGL underlying uniform buffer is in sync
  25997. * with the javascript cache data.
  25998. */
  25999. readonly isSync: boolean;
  26000. /**
  26001. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26002. * Also, a dynamic UniformBuffer will disable cache verification and always
  26003. * update the underlying WebGL uniform buffer to the GPU.
  26004. * @returns if Dynamic, otherwise false
  26005. */
  26006. isDynamic(): boolean;
  26007. /**
  26008. * The data cache on JS side.
  26009. * @returns the underlying data as a float array
  26010. */
  26011. getData(): Float32Array;
  26012. /**
  26013. * The underlying WebGL Uniform buffer.
  26014. * @returns the webgl buffer
  26015. */
  26016. getBuffer(): Nullable<WebGLBuffer>;
  26017. /**
  26018. * std140 layout specifies how to align data within an UBO structure.
  26019. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26020. * for specs.
  26021. */
  26022. private _fillAlignment;
  26023. /**
  26024. * Adds an uniform in the buffer.
  26025. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26026. * for the layout to be correct !
  26027. * @param name Name of the uniform, as used in the uniform block in the shader.
  26028. * @param size Data size, or data directly.
  26029. */
  26030. addUniform(name: string, size: number | number[]): void;
  26031. /**
  26032. * Adds a Matrix 4x4 to the uniform buffer.
  26033. * @param name Name of the uniform, as used in the uniform block in the shader.
  26034. * @param mat A 4x4 matrix.
  26035. */
  26036. addMatrix(name: string, mat: Matrix): void;
  26037. /**
  26038. * Adds a vec2 to the uniform buffer.
  26039. * @param name Name of the uniform, as used in the uniform block in the shader.
  26040. * @param x Define the x component value of the vec2
  26041. * @param y Define the y component value of the vec2
  26042. */
  26043. addFloat2(name: string, x: number, y: number): void;
  26044. /**
  26045. * Adds a vec3 to the uniform buffer.
  26046. * @param name Name of the uniform, as used in the uniform block in the shader.
  26047. * @param x Define the x component value of the vec3
  26048. * @param y Define the y component value of the vec3
  26049. * @param z Define the z component value of the vec3
  26050. */
  26051. addFloat3(name: string, x: number, y: number, z: number): void;
  26052. /**
  26053. * Adds a vec3 to the uniform buffer.
  26054. * @param name Name of the uniform, as used in the uniform block in the shader.
  26055. * @param color Define the vec3 from a Color
  26056. */
  26057. addColor3(name: string, color: Color3): void;
  26058. /**
  26059. * Adds a vec4 to the uniform buffer.
  26060. * @param name Name of the uniform, as used in the uniform block in the shader.
  26061. * @param color Define the rgb components from a Color
  26062. * @param alpha Define the a component of the vec4
  26063. */
  26064. addColor4(name: string, color: Color3, alpha: number): void;
  26065. /**
  26066. * Adds a vec3 to the uniform buffer.
  26067. * @param name Name of the uniform, as used in the uniform block in the shader.
  26068. * @param vector Define the vec3 components from a Vector
  26069. */
  26070. addVector3(name: string, vector: Vector3): void;
  26071. /**
  26072. * Adds a Matrix 3x3 to the uniform buffer.
  26073. * @param name Name of the uniform, as used in the uniform block in the shader.
  26074. */
  26075. addMatrix3x3(name: string): void;
  26076. /**
  26077. * Adds a Matrix 2x2 to the uniform buffer.
  26078. * @param name Name of the uniform, as used in the uniform block in the shader.
  26079. */
  26080. addMatrix2x2(name: string): void;
  26081. /**
  26082. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26083. */
  26084. create(): void;
  26085. /** @hidden */
  26086. _rebuild(): void;
  26087. /**
  26088. * Updates the WebGL Uniform Buffer on the GPU.
  26089. * If the `dynamic` flag is set to true, no cache comparison is done.
  26090. * Otherwise, the buffer will be updated only if the cache differs.
  26091. */
  26092. update(): void;
  26093. /**
  26094. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26095. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26096. * @param data Define the flattened data
  26097. * @param size Define the size of the data.
  26098. */
  26099. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26100. private _updateMatrix3x3ForUniform;
  26101. private _updateMatrix3x3ForEffect;
  26102. private _updateMatrix2x2ForEffect;
  26103. private _updateMatrix2x2ForUniform;
  26104. private _updateFloatForEffect;
  26105. private _updateFloatForUniform;
  26106. private _updateFloat2ForEffect;
  26107. private _updateFloat2ForUniform;
  26108. private _updateFloat3ForEffect;
  26109. private _updateFloat3ForUniform;
  26110. private _updateFloat4ForEffect;
  26111. private _updateFloat4ForUniform;
  26112. private _updateMatrixForEffect;
  26113. private _updateMatrixForUniform;
  26114. private _updateVector3ForEffect;
  26115. private _updateVector3ForUniform;
  26116. private _updateVector4ForEffect;
  26117. private _updateVector4ForUniform;
  26118. private _updateColor3ForEffect;
  26119. private _updateColor3ForUniform;
  26120. private _updateColor4ForEffect;
  26121. private _updateColor4ForUniform;
  26122. /**
  26123. * Sets a sampler uniform on the effect.
  26124. * @param name Define the name of the sampler.
  26125. * @param texture Define the texture to set in the sampler
  26126. */
  26127. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26128. /**
  26129. * Directly updates the value of the uniform in the cache AND on the GPU.
  26130. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26131. * @param data Define the flattened data
  26132. */
  26133. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26134. /**
  26135. * Binds this uniform buffer to an effect.
  26136. * @param effect Define the effect to bind the buffer to
  26137. * @param name Name of the uniform block in the shader.
  26138. */
  26139. bindToEffect(effect: Effect, name: string): void;
  26140. /**
  26141. * Disposes the uniform buffer.
  26142. */
  26143. dispose(): void;
  26144. }
  26145. }
  26146. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26147. import { Nullable } from "babylonjs/types";
  26148. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26149. /**
  26150. * This represents the required contract to create a new type of texture loader.
  26151. */
  26152. export interface IInternalTextureLoader {
  26153. /**
  26154. * Defines wether the loader supports cascade loading the different faces.
  26155. */
  26156. supportCascades: boolean;
  26157. /**
  26158. * This returns if the loader support the current file information.
  26159. * @param extension defines the file extension of the file being loaded
  26160. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26161. * @param fallback defines the fallback internal texture if any
  26162. * @param isBase64 defines whether the texture is encoded as a base64
  26163. * @param isBuffer defines whether the texture data are stored as a buffer
  26164. * @returns true if the loader can load the specified file
  26165. */
  26166. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26167. /**
  26168. * Transform the url before loading if required.
  26169. * @param rootUrl the url of the texture
  26170. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26171. * @returns the transformed texture
  26172. */
  26173. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26174. /**
  26175. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26176. * @param rootUrl the url of the texture
  26177. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26178. * @returns the fallback texture
  26179. */
  26180. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26181. /**
  26182. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26183. * @param data contains the texture data
  26184. * @param texture defines the BabylonJS internal texture
  26185. * @param createPolynomials will be true if polynomials have been requested
  26186. * @param onLoad defines the callback to trigger once the texture is ready
  26187. * @param onError defines the callback to trigger in case of error
  26188. */
  26189. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26190. /**
  26191. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26192. * @param data contains the texture data
  26193. * @param texture defines the BabylonJS internal texture
  26194. * @param callback defines the method to call once ready to upload
  26195. */
  26196. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26197. }
  26198. }
  26199. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26200. import { Scene } from "babylonjs/scene";
  26201. import { Engine } from "babylonjs/Engines/engine";
  26202. import { Texture } from "babylonjs/Materials/Textures/texture";
  26203. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26204. /**
  26205. * Creation options of the multi render target texture.
  26206. */
  26207. export interface IMultiRenderTargetOptions {
  26208. /**
  26209. * Define if the texture needs to create mip maps after render.
  26210. */
  26211. generateMipMaps?: boolean;
  26212. /**
  26213. * Define the types of all the draw buffers we want to create
  26214. */
  26215. types?: number[];
  26216. /**
  26217. * Define the sampling modes of all the draw buffers we want to create
  26218. */
  26219. samplingModes?: number[];
  26220. /**
  26221. * Define if a depth buffer is required
  26222. */
  26223. generateDepthBuffer?: boolean;
  26224. /**
  26225. * Define if a stencil buffer is required
  26226. */
  26227. generateStencilBuffer?: boolean;
  26228. /**
  26229. * Define if a depth texture is required instead of a depth buffer
  26230. */
  26231. generateDepthTexture?: boolean;
  26232. /**
  26233. * Define the number of desired draw buffers
  26234. */
  26235. textureCount?: number;
  26236. /**
  26237. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26238. */
  26239. doNotChangeAspectRatio?: boolean;
  26240. /**
  26241. * Define the default type of the buffers we are creating
  26242. */
  26243. defaultType?: number;
  26244. }
  26245. /**
  26246. * A multi render target, like a render target provides the ability to render to a texture.
  26247. * Unlike the render target, it can render to several draw buffers in one draw.
  26248. * This is specially interesting in deferred rendering or for any effects requiring more than
  26249. * just one color from a single pass.
  26250. */
  26251. export class MultiRenderTarget extends RenderTargetTexture {
  26252. private _internalTextures;
  26253. private _textures;
  26254. private _multiRenderTargetOptions;
  26255. /**
  26256. * Get if draw buffers are currently supported by the used hardware and browser.
  26257. */
  26258. readonly isSupported: boolean;
  26259. /**
  26260. * Get the list of textures generated by the multi render target.
  26261. */
  26262. readonly textures: Texture[];
  26263. /**
  26264. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26265. */
  26266. readonly depthTexture: Texture;
  26267. /**
  26268. * Set the wrapping mode on U of all the textures we are rendering to.
  26269. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26270. */
  26271. wrapU: number;
  26272. /**
  26273. * Set the wrapping mode on V of all the textures we are rendering to.
  26274. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26275. */
  26276. wrapV: number;
  26277. /**
  26278. * Instantiate a new multi render target texture.
  26279. * A multi render target, like a render target provides the ability to render to a texture.
  26280. * Unlike the render target, it can render to several draw buffers in one draw.
  26281. * This is specially interesting in deferred rendering or for any effects requiring more than
  26282. * just one color from a single pass.
  26283. * @param name Define the name of the texture
  26284. * @param size Define the size of the buffers to render to
  26285. * @param count Define the number of target we are rendering into
  26286. * @param scene Define the scene the texture belongs to
  26287. * @param options Define the options used to create the multi render target
  26288. */
  26289. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26290. /** @hidden */
  26291. _rebuild(): void;
  26292. private _createInternalTextures;
  26293. private _createTextures;
  26294. /**
  26295. * Define the number of samples used if MSAA is enabled.
  26296. */
  26297. samples: number;
  26298. /**
  26299. * Resize all the textures in the multi render target.
  26300. * Be carrefull as it will recreate all the data in the new texture.
  26301. * @param size Define the new size
  26302. */
  26303. resize(size: any): void;
  26304. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26305. /**
  26306. * Dispose the render targets and their associated resources
  26307. */
  26308. dispose(): void;
  26309. /**
  26310. * Release all the underlying texture used as draw buffers.
  26311. */
  26312. releaseInternalTextures(): void;
  26313. }
  26314. }
  26315. declare module "babylonjs/Audio/analyser" {
  26316. import { Scene } from "babylonjs/scene";
  26317. /**
  26318. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26319. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26320. */
  26321. export class Analyser {
  26322. /**
  26323. * Gets or sets the smoothing
  26324. * @ignorenaming
  26325. */
  26326. SMOOTHING: number;
  26327. /**
  26328. * Gets or sets the FFT table size
  26329. * @ignorenaming
  26330. */
  26331. FFT_SIZE: number;
  26332. /**
  26333. * Gets or sets the bar graph amplitude
  26334. * @ignorenaming
  26335. */
  26336. BARGRAPHAMPLITUDE: number;
  26337. /**
  26338. * Gets or sets the position of the debug canvas
  26339. * @ignorenaming
  26340. */
  26341. DEBUGCANVASPOS: {
  26342. x: number;
  26343. y: number;
  26344. };
  26345. /**
  26346. * Gets or sets the debug canvas size
  26347. * @ignorenaming
  26348. */
  26349. DEBUGCANVASSIZE: {
  26350. width: number;
  26351. height: number;
  26352. };
  26353. private _byteFreqs;
  26354. private _byteTime;
  26355. private _floatFreqs;
  26356. private _webAudioAnalyser;
  26357. private _debugCanvas;
  26358. private _debugCanvasContext;
  26359. private _scene;
  26360. private _registerFunc;
  26361. private _audioEngine;
  26362. /**
  26363. * Creates a new analyser
  26364. * @param scene defines hosting scene
  26365. */
  26366. constructor(scene: Scene);
  26367. /**
  26368. * Get the number of data values you will have to play with for the visualization
  26369. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26370. * @returns a number
  26371. */
  26372. getFrequencyBinCount(): number;
  26373. /**
  26374. * Gets the current frequency data as a byte array
  26375. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26376. * @returns a Uint8Array
  26377. */
  26378. getByteFrequencyData(): Uint8Array;
  26379. /**
  26380. * Gets the current waveform as a byte array
  26381. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26382. * @returns a Uint8Array
  26383. */
  26384. getByteTimeDomainData(): Uint8Array;
  26385. /**
  26386. * Gets the current frequency data as a float array
  26387. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26388. * @returns a Float32Array
  26389. */
  26390. getFloatFrequencyData(): Float32Array;
  26391. /**
  26392. * Renders the debug canvas
  26393. */
  26394. drawDebugCanvas(): void;
  26395. /**
  26396. * Stops rendering the debug canvas and removes it
  26397. */
  26398. stopDebugCanvas(): void;
  26399. /**
  26400. * Connects two audio nodes
  26401. * @param inputAudioNode defines first node to connect
  26402. * @param outputAudioNode defines second node to connect
  26403. */
  26404. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26405. /**
  26406. * Releases all associated resources
  26407. */
  26408. dispose(): void;
  26409. }
  26410. }
  26411. declare module "babylonjs/Audio/audioEngine" {
  26412. import { IDisposable } from "babylonjs/scene";
  26413. import { Analyser } from "babylonjs/Audio/analyser";
  26414. import { Nullable } from "babylonjs/types";
  26415. import { Observable } from "babylonjs/Misc/observable";
  26416. /**
  26417. * This represents an audio engine and it is responsible
  26418. * to play, synchronize and analyse sounds throughout the application.
  26419. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26420. */
  26421. export interface IAudioEngine extends IDisposable {
  26422. /**
  26423. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26424. */
  26425. readonly canUseWebAudio: boolean;
  26426. /**
  26427. * Gets the current AudioContext if available.
  26428. */
  26429. readonly audioContext: Nullable<AudioContext>;
  26430. /**
  26431. * The master gain node defines the global audio volume of your audio engine.
  26432. */
  26433. readonly masterGain: GainNode;
  26434. /**
  26435. * Gets whether or not mp3 are supported by your browser.
  26436. */
  26437. readonly isMP3supported: boolean;
  26438. /**
  26439. * Gets whether or not ogg are supported by your browser.
  26440. */
  26441. readonly isOGGsupported: boolean;
  26442. /**
  26443. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26444. * @ignoreNaming
  26445. */
  26446. WarnedWebAudioUnsupported: boolean;
  26447. /**
  26448. * Defines if the audio engine relies on a custom unlocked button.
  26449. * In this case, the embedded button will not be displayed.
  26450. */
  26451. useCustomUnlockedButton: boolean;
  26452. /**
  26453. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26454. */
  26455. readonly unlocked: boolean;
  26456. /**
  26457. * Event raised when audio has been unlocked on the browser.
  26458. */
  26459. onAudioUnlockedObservable: Observable<AudioEngine>;
  26460. /**
  26461. * Event raised when audio has been locked on the browser.
  26462. */
  26463. onAudioLockedObservable: Observable<AudioEngine>;
  26464. /**
  26465. * Flags the audio engine in Locked state.
  26466. * This happens due to new browser policies preventing audio to autoplay.
  26467. */
  26468. lock(): void;
  26469. /**
  26470. * Unlocks the audio engine once a user action has been done on the dom.
  26471. * This is helpful to resume play once browser policies have been satisfied.
  26472. */
  26473. unlock(): void;
  26474. }
  26475. /**
  26476. * This represents the default audio engine used in babylon.
  26477. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26478. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26479. */
  26480. export class AudioEngine implements IAudioEngine {
  26481. private _audioContext;
  26482. private _audioContextInitialized;
  26483. private _muteButton;
  26484. private _hostElement;
  26485. /**
  26486. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26487. */
  26488. canUseWebAudio: boolean;
  26489. /**
  26490. * The master gain node defines the global audio volume of your audio engine.
  26491. */
  26492. masterGain: GainNode;
  26493. /**
  26494. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26495. * @ignoreNaming
  26496. */
  26497. WarnedWebAudioUnsupported: boolean;
  26498. /**
  26499. * Gets whether or not mp3 are supported by your browser.
  26500. */
  26501. isMP3supported: boolean;
  26502. /**
  26503. * Gets whether or not ogg are supported by your browser.
  26504. */
  26505. isOGGsupported: boolean;
  26506. /**
  26507. * Gets whether audio has been unlocked on the device.
  26508. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26509. * a user interaction has happened.
  26510. */
  26511. unlocked: boolean;
  26512. /**
  26513. * Defines if the audio engine relies on a custom unlocked button.
  26514. * In this case, the embedded button will not be displayed.
  26515. */
  26516. useCustomUnlockedButton: boolean;
  26517. /**
  26518. * Event raised when audio has been unlocked on the browser.
  26519. */
  26520. onAudioUnlockedObservable: Observable<AudioEngine>;
  26521. /**
  26522. * Event raised when audio has been locked on the browser.
  26523. */
  26524. onAudioLockedObservable: Observable<AudioEngine>;
  26525. /**
  26526. * Gets the current AudioContext if available.
  26527. */
  26528. readonly audioContext: Nullable<AudioContext>;
  26529. private _connectedAnalyser;
  26530. /**
  26531. * Instantiates a new audio engine.
  26532. *
  26533. * There should be only one per page as some browsers restrict the number
  26534. * of audio contexts you can create.
  26535. * @param hostElement defines the host element where to display the mute icon if necessary
  26536. */
  26537. constructor(hostElement?: Nullable<HTMLElement>);
  26538. /**
  26539. * Flags the audio engine in Locked state.
  26540. * This happens due to new browser policies preventing audio to autoplay.
  26541. */
  26542. lock(): void;
  26543. /**
  26544. * Unlocks the audio engine once a user action has been done on the dom.
  26545. * This is helpful to resume play once browser policies have been satisfied.
  26546. */
  26547. unlock(): void;
  26548. private _resumeAudioContext;
  26549. private _initializeAudioContext;
  26550. private _tryToRun;
  26551. private _triggerRunningState;
  26552. private _triggerSuspendedState;
  26553. private _displayMuteButton;
  26554. private _moveButtonToTopLeft;
  26555. private _onResize;
  26556. private _hideMuteButton;
  26557. /**
  26558. * Destroy and release the resources associated with the audio ccontext.
  26559. */
  26560. dispose(): void;
  26561. /**
  26562. * Gets the global volume sets on the master gain.
  26563. * @returns the global volume if set or -1 otherwise
  26564. */
  26565. getGlobalVolume(): number;
  26566. /**
  26567. * Sets the global volume of your experience (sets on the master gain).
  26568. * @param newVolume Defines the new global volume of the application
  26569. */
  26570. setGlobalVolume(newVolume: number): void;
  26571. /**
  26572. * Connect the audio engine to an audio analyser allowing some amazing
  26573. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26575. * @param analyser The analyser to connect to the engine
  26576. */
  26577. connectToAnalyser(analyser: Analyser): void;
  26578. }
  26579. }
  26580. declare module "babylonjs/Loading/loadingScreen" {
  26581. /**
  26582. * Interface used to present a loading screen while loading a scene
  26583. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26584. */
  26585. export interface ILoadingScreen {
  26586. /**
  26587. * Function called to display the loading screen
  26588. */
  26589. displayLoadingUI: () => void;
  26590. /**
  26591. * Function called to hide the loading screen
  26592. */
  26593. hideLoadingUI: () => void;
  26594. /**
  26595. * Gets or sets the color to use for the background
  26596. */
  26597. loadingUIBackgroundColor: string;
  26598. /**
  26599. * Gets or sets the text to display while loading
  26600. */
  26601. loadingUIText: string;
  26602. }
  26603. /**
  26604. * Class used for the default loading screen
  26605. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26606. */
  26607. export class DefaultLoadingScreen implements ILoadingScreen {
  26608. private _renderingCanvas;
  26609. private _loadingText;
  26610. private _loadingDivBackgroundColor;
  26611. private _loadingDiv;
  26612. private _loadingTextDiv;
  26613. /**
  26614. * Creates a new default loading screen
  26615. * @param _renderingCanvas defines the canvas used to render the scene
  26616. * @param _loadingText defines the default text to display
  26617. * @param _loadingDivBackgroundColor defines the default background color
  26618. */
  26619. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26620. /**
  26621. * Function called to display the loading screen
  26622. */
  26623. displayLoadingUI(): void;
  26624. /**
  26625. * Function called to hide the loading screen
  26626. */
  26627. hideLoadingUI(): void;
  26628. /**
  26629. * Gets or sets the text to display while loading
  26630. */
  26631. loadingUIText: string;
  26632. /**
  26633. * Gets or sets the color to use for the background
  26634. */
  26635. loadingUIBackgroundColor: string;
  26636. private _resizeLoadingUI;
  26637. }
  26638. }
  26639. declare module "babylonjs/Materials/Textures/videoTexture" {
  26640. import { Observable } from "babylonjs/Misc/observable";
  26641. import { Nullable } from "babylonjs/types";
  26642. import { Scene } from "babylonjs/scene";
  26643. import { Texture } from "babylonjs/Materials/Textures/texture";
  26644. /**
  26645. * Settings for finer control over video usage
  26646. */
  26647. export interface VideoTextureSettings {
  26648. /**
  26649. * Applies `autoplay` to video, if specified
  26650. */
  26651. autoPlay?: boolean;
  26652. /**
  26653. * Applies `loop` to video, if specified
  26654. */
  26655. loop?: boolean;
  26656. /**
  26657. * Automatically updates internal texture from video at every frame in the render loop
  26658. */
  26659. autoUpdateTexture: boolean;
  26660. /**
  26661. * Image src displayed during the video loading or until the user interacts with the video.
  26662. */
  26663. poster?: string;
  26664. }
  26665. /**
  26666. * If you want to display a video in your scene, this is the special texture for that.
  26667. * This special texture works similar to other textures, with the exception of a few parameters.
  26668. * @see https://doc.babylonjs.com/how_to/video_texture
  26669. */
  26670. export class VideoTexture extends Texture {
  26671. /**
  26672. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26673. */
  26674. readonly autoUpdateTexture: boolean;
  26675. /**
  26676. * The video instance used by the texture internally
  26677. */
  26678. readonly video: HTMLVideoElement;
  26679. private _onUserActionRequestedObservable;
  26680. /**
  26681. * Event triggerd when a dom action is required by the user to play the video.
  26682. * This happens due to recent changes in browser policies preventing video to auto start.
  26683. */
  26684. readonly onUserActionRequestedObservable: Observable<Texture>;
  26685. private _generateMipMaps;
  26686. private _engine;
  26687. private _stillImageCaptured;
  26688. private _displayingPosterTexture;
  26689. private _settings;
  26690. private _createInternalTextureOnEvent;
  26691. /**
  26692. * Creates a video texture.
  26693. * If you want to display a video in your scene, this is the special texture for that.
  26694. * This special texture works similar to other textures, with the exception of a few parameters.
  26695. * @see https://doc.babylonjs.com/how_to/video_texture
  26696. * @param name optional name, will detect from video source, if not defined
  26697. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26698. * @param scene is obviously the current scene.
  26699. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26700. * @param invertY is false by default but can be used to invert video on Y axis
  26701. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26702. * @param settings allows finer control over video usage
  26703. */
  26704. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26705. private _getName;
  26706. private _getVideo;
  26707. private _createInternalTexture;
  26708. private reset;
  26709. /**
  26710. * @hidden Internal method to initiate `update`.
  26711. */
  26712. _rebuild(): void;
  26713. /**
  26714. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26715. */
  26716. update(): void;
  26717. /**
  26718. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26719. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26720. */
  26721. updateTexture(isVisible: boolean): void;
  26722. protected _updateInternalTexture: () => void;
  26723. /**
  26724. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26725. * @param url New url.
  26726. */
  26727. updateURL(url: string): void;
  26728. /**
  26729. * Dispose the texture and release its associated resources.
  26730. */
  26731. dispose(): void;
  26732. /**
  26733. * Creates a video texture straight from a stream.
  26734. * @param scene Define the scene the texture should be created in
  26735. * @param stream Define the stream the texture should be created from
  26736. * @returns The created video texture as a promise
  26737. */
  26738. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26739. /**
  26740. * Creates a video texture straight from your WebCam video feed.
  26741. * @param scene Define the scene the texture should be created in
  26742. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26743. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26744. * @returns The created video texture as a promise
  26745. */
  26746. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26747. minWidth: number;
  26748. maxWidth: number;
  26749. minHeight: number;
  26750. maxHeight: number;
  26751. deviceId: string;
  26752. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26753. /**
  26754. * Creates a video texture straight from your WebCam video feed.
  26755. * @param scene Define the scene the texture should be created in
  26756. * @param onReady Define a callback to triggered once the texture will be ready
  26757. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26758. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26759. */
  26760. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26761. minWidth: number;
  26762. maxWidth: number;
  26763. minHeight: number;
  26764. maxHeight: number;
  26765. deviceId: string;
  26766. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26767. }
  26768. }
  26769. declare module "babylonjs/Engines/engine" {
  26770. import { Observable } from "babylonjs/Misc/observable";
  26771. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  26772. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  26773. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26774. import { Camera } from "babylonjs/Cameras/camera";
  26775. import { Scene } from "babylonjs/scene";
  26776. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  26777. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  26778. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26779. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26780. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  26781. import { Material } from "babylonjs/Materials/material";
  26782. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  26783. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26784. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26785. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  26786. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  26787. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  26788. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  26789. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  26790. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  26791. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26792. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26793. /**
  26794. * Interface for attribute information associated with buffer instanciation
  26795. */
  26796. export class InstancingAttributeInfo {
  26797. /**
  26798. * Index/offset of the attribute in the vertex shader
  26799. */
  26800. index: number;
  26801. /**
  26802. * size of the attribute, 1, 2, 3 or 4
  26803. */
  26804. attributeSize: number;
  26805. /**
  26806. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26807. * default is FLOAT
  26808. */
  26809. attribyteType: number;
  26810. /**
  26811. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26812. */
  26813. normalized: boolean;
  26814. /**
  26815. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26816. */
  26817. offset: number;
  26818. /**
  26819. * Name of the GLSL attribute, for debugging purpose only
  26820. */
  26821. attributeName: string;
  26822. }
  26823. /**
  26824. * Define options used to create a depth texture
  26825. */
  26826. export class DepthTextureCreationOptions {
  26827. /** Specifies whether or not a stencil should be allocated in the texture */
  26828. generateStencil?: boolean;
  26829. /** Specifies whether or not bilinear filtering is enable on the texture */
  26830. bilinearFiltering?: boolean;
  26831. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26832. comparisonFunction?: number;
  26833. /** Specifies if the created texture is a cube texture */
  26834. isCube?: boolean;
  26835. }
  26836. /**
  26837. * Class used to describe the capabilities of the engine relatively to the current browser
  26838. */
  26839. export class EngineCapabilities {
  26840. /** Maximum textures units per fragment shader */
  26841. maxTexturesImageUnits: number;
  26842. /** Maximum texture units per vertex shader */
  26843. maxVertexTextureImageUnits: number;
  26844. /** Maximum textures units in the entire pipeline */
  26845. maxCombinedTexturesImageUnits: number;
  26846. /** Maximum texture size */
  26847. maxTextureSize: number;
  26848. /** Maximum cube texture size */
  26849. maxCubemapTextureSize: number;
  26850. /** Maximum render texture size */
  26851. maxRenderTextureSize: number;
  26852. /** Maximum number of vertex attributes */
  26853. maxVertexAttribs: number;
  26854. /** Maximum number of varyings */
  26855. maxVaryingVectors: number;
  26856. /** Maximum number of uniforms per vertex shader */
  26857. maxVertexUniformVectors: number;
  26858. /** Maximum number of uniforms per fragment shader */
  26859. maxFragmentUniformVectors: number;
  26860. /** Defines if standard derivates (dx/dy) are supported */
  26861. standardDerivatives: boolean;
  26862. /** Defines if s3tc texture compression is supported */
  26863. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26864. /** Defines if pvrtc texture compression is supported */
  26865. pvrtc: any;
  26866. /** Defines if etc1 texture compression is supported */
  26867. etc1: any;
  26868. /** Defines if etc2 texture compression is supported */
  26869. etc2: any;
  26870. /** Defines if astc texture compression is supported */
  26871. astc: any;
  26872. /** Defines if float textures are supported */
  26873. textureFloat: boolean;
  26874. /** Defines if vertex array objects are supported */
  26875. vertexArrayObject: boolean;
  26876. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26877. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26878. /** Gets the maximum level of anisotropy supported */
  26879. maxAnisotropy: number;
  26880. /** Defines if instancing is supported */
  26881. instancedArrays: boolean;
  26882. /** Defines if 32 bits indices are supported */
  26883. uintIndices: boolean;
  26884. /** Defines if high precision shaders are supported */
  26885. highPrecisionShaderSupported: boolean;
  26886. /** Defines if depth reading in the fragment shader is supported */
  26887. fragmentDepthSupported: boolean;
  26888. /** Defines if float texture linear filtering is supported*/
  26889. textureFloatLinearFiltering: boolean;
  26890. /** Defines if rendering to float textures is supported */
  26891. textureFloatRender: boolean;
  26892. /** Defines if half float textures are supported*/
  26893. textureHalfFloat: boolean;
  26894. /** Defines if half float texture linear filtering is supported*/
  26895. textureHalfFloatLinearFiltering: boolean;
  26896. /** Defines if rendering to half float textures is supported */
  26897. textureHalfFloatRender: boolean;
  26898. /** Defines if textureLOD shader command is supported */
  26899. textureLOD: boolean;
  26900. /** Defines if draw buffers extension is supported */
  26901. drawBuffersExtension: boolean;
  26902. /** Defines if depth textures are supported */
  26903. depthTextureExtension: boolean;
  26904. /** Defines if float color buffer are supported */
  26905. colorBufferFloat: boolean;
  26906. /** Gets disjoint timer query extension (null if not supported) */
  26907. timerQuery: EXT_disjoint_timer_query;
  26908. /** Defines if timestamp can be used with timer query */
  26909. canUseTimestampForTimerQuery: boolean;
  26910. /** Function used to let the system compiles shaders in background */
  26911. parallelShaderCompile: {
  26912. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26913. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26914. COMPLETION_STATUS_KHR: number;
  26915. };
  26916. }
  26917. /** Interface defining initialization parameters for Engine class */
  26918. export interface EngineOptions extends WebGLContextAttributes {
  26919. /**
  26920. * Defines if the engine should no exceed a specified device ratio
  26921. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26922. */
  26923. limitDeviceRatio?: number;
  26924. /**
  26925. * Defines if webvr should be enabled automatically
  26926. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26927. */
  26928. autoEnableWebVR?: boolean;
  26929. /**
  26930. * Defines if webgl2 should be turned off even if supported
  26931. * @see http://doc.babylonjs.com/features/webgl2
  26932. */
  26933. disableWebGL2Support?: boolean;
  26934. /**
  26935. * Defines if webaudio should be initialized as well
  26936. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26937. */
  26938. audioEngine?: boolean;
  26939. /**
  26940. * Defines if animations should run using a deterministic lock step
  26941. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26942. */
  26943. deterministicLockstep?: boolean;
  26944. /** Defines the maximum steps to use with deterministic lock step mode */
  26945. lockstepMaxSteps?: number;
  26946. /**
  26947. * Defines that engine should ignore context lost events
  26948. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26949. */
  26950. doNotHandleContextLost?: boolean;
  26951. /**
  26952. * Defines that engine should ignore modifying touch action attribute and style
  26953. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26954. */
  26955. doNotHandleTouchAction?: boolean;
  26956. }
  26957. /**
  26958. * Defines the interface used by display changed events
  26959. */
  26960. export interface IDisplayChangedEventArgs {
  26961. /** Gets the vrDisplay object (if any) */
  26962. vrDisplay: Nullable<any>;
  26963. /** Gets a boolean indicating if webVR is supported */
  26964. vrSupported: boolean;
  26965. }
  26966. /**
  26967. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26968. */
  26969. export class Engine {
  26970. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26971. static ExceptionList: ({
  26972. key: string;
  26973. capture: string;
  26974. captureConstraint: number;
  26975. targets: string[];
  26976. } | {
  26977. key: string;
  26978. capture: null;
  26979. captureConstraint: null;
  26980. targets: string[];
  26981. })[];
  26982. /** Gets the list of created engines */
  26983. static readonly Instances: Engine[];
  26984. /**
  26985. * Gets the latest created engine
  26986. */
  26987. static readonly LastCreatedEngine: Nullable<Engine>;
  26988. /**
  26989. * Gets the latest created scene
  26990. */
  26991. static readonly LastCreatedScene: Nullable<Scene>;
  26992. /**
  26993. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26994. * @param flag defines which part of the materials must be marked as dirty
  26995. * @param predicate defines a predicate used to filter which materials should be affected
  26996. */
  26997. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26998. /**
  26999. * Hidden
  27000. */
  27001. static _TextureLoaders: IInternalTextureLoader[];
  27002. /** Defines that alpha blending is disabled */
  27003. static readonly ALPHA_DISABLE: number;
  27004. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27005. static readonly ALPHA_ADD: number;
  27006. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27007. static readonly ALPHA_COMBINE: number;
  27008. /** Defines that alpha blending to DEST - SRC * DEST */
  27009. static readonly ALPHA_SUBTRACT: number;
  27010. /** Defines that alpha blending to SRC * DEST */
  27011. static readonly ALPHA_MULTIPLY: number;
  27012. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27013. static readonly ALPHA_MAXIMIZED: number;
  27014. /** Defines that alpha blending to SRC + DEST */
  27015. static readonly ALPHA_ONEONE: number;
  27016. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27017. static readonly ALPHA_PREMULTIPLIED: number;
  27018. /**
  27019. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27020. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27021. */
  27022. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27023. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27024. static readonly ALPHA_INTERPOLATE: number;
  27025. /**
  27026. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27027. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27028. */
  27029. static readonly ALPHA_SCREENMODE: number;
  27030. /** Defines that the ressource is not delayed*/
  27031. static readonly DELAYLOADSTATE_NONE: number;
  27032. /** Defines that the ressource was successfully delay loaded */
  27033. static readonly DELAYLOADSTATE_LOADED: number;
  27034. /** Defines that the ressource is currently delay loading */
  27035. static readonly DELAYLOADSTATE_LOADING: number;
  27036. /** Defines that the ressource is delayed and has not started loading */
  27037. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27038. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27039. static readonly NEVER: number;
  27040. /** 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 */
  27041. static readonly ALWAYS: number;
  27042. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27043. static readonly LESS: number;
  27044. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27045. static readonly EQUAL: number;
  27046. /** 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 */
  27047. static readonly LEQUAL: number;
  27048. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27049. static readonly GREATER: number;
  27050. /** 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 */
  27051. static readonly GEQUAL: number;
  27052. /** 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 */
  27053. static readonly NOTEQUAL: number;
  27054. /** Passed to stencilOperation to specify that stencil value must be kept */
  27055. static readonly KEEP: number;
  27056. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27057. static readonly REPLACE: number;
  27058. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27059. static readonly INCR: number;
  27060. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27061. static readonly DECR: number;
  27062. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27063. static readonly INVERT: number;
  27064. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27065. static readonly INCR_WRAP: number;
  27066. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27067. static readonly DECR_WRAP: number;
  27068. /** Texture is not repeating outside of 0..1 UVs */
  27069. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27070. /** Texture is repeating outside of 0..1 UVs */
  27071. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27072. /** Texture is repeating and mirrored */
  27073. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27074. /** ALPHA */
  27075. static readonly TEXTUREFORMAT_ALPHA: number;
  27076. /** LUMINANCE */
  27077. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27078. /** LUMINANCE_ALPHA */
  27079. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27080. /** RGB */
  27081. static readonly TEXTUREFORMAT_RGB: number;
  27082. /** RGBA */
  27083. static readonly TEXTUREFORMAT_RGBA: number;
  27084. /** RED */
  27085. static readonly TEXTUREFORMAT_RED: number;
  27086. /** RED (2nd reference) */
  27087. static readonly TEXTUREFORMAT_R: number;
  27088. /** RG */
  27089. static readonly TEXTUREFORMAT_RG: number;
  27090. /** RED_INTEGER */
  27091. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27092. /** RED_INTEGER (2nd reference) */
  27093. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27094. /** RG_INTEGER */
  27095. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27096. /** RGB_INTEGER */
  27097. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27098. /** RGBA_INTEGER */
  27099. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27100. /** UNSIGNED_BYTE */
  27101. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27102. /** UNSIGNED_BYTE (2nd reference) */
  27103. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27104. /** FLOAT */
  27105. static readonly TEXTURETYPE_FLOAT: number;
  27106. /** HALF_FLOAT */
  27107. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27108. /** BYTE */
  27109. static readonly TEXTURETYPE_BYTE: number;
  27110. /** SHORT */
  27111. static readonly TEXTURETYPE_SHORT: number;
  27112. /** UNSIGNED_SHORT */
  27113. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27114. /** INT */
  27115. static readonly TEXTURETYPE_INT: number;
  27116. /** UNSIGNED_INT */
  27117. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27118. /** UNSIGNED_SHORT_4_4_4_4 */
  27119. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27120. /** UNSIGNED_SHORT_5_5_5_1 */
  27121. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27122. /** UNSIGNED_SHORT_5_6_5 */
  27123. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27124. /** UNSIGNED_INT_2_10_10_10_REV */
  27125. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27126. /** UNSIGNED_INT_24_8 */
  27127. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27128. /** UNSIGNED_INT_10F_11F_11F_REV */
  27129. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27130. /** UNSIGNED_INT_5_9_9_9_REV */
  27131. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27132. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27133. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27134. /** nearest is mag = nearest and min = nearest and mip = linear */
  27135. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27136. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27137. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27138. /** Trilinear is mag = linear and min = linear and mip = linear */
  27139. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27140. /** nearest is mag = nearest and min = nearest and mip = linear */
  27141. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27142. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27143. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27144. /** Trilinear is mag = linear and min = linear and mip = linear */
  27145. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27146. /** mag = nearest and min = nearest and mip = nearest */
  27147. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27148. /** mag = nearest and min = linear and mip = nearest */
  27149. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27150. /** mag = nearest and min = linear and mip = linear */
  27151. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27152. /** mag = nearest and min = linear and mip = none */
  27153. static readonly TEXTURE_NEAREST_LINEAR: number;
  27154. /** mag = nearest and min = nearest and mip = none */
  27155. static readonly TEXTURE_NEAREST_NEAREST: number;
  27156. /** mag = linear and min = nearest and mip = nearest */
  27157. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27158. /** mag = linear and min = nearest and mip = linear */
  27159. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27160. /** mag = linear and min = linear and mip = none */
  27161. static readonly TEXTURE_LINEAR_LINEAR: number;
  27162. /** mag = linear and min = nearest and mip = none */
  27163. static readonly TEXTURE_LINEAR_NEAREST: number;
  27164. /** Explicit coordinates mode */
  27165. static readonly TEXTURE_EXPLICIT_MODE: number;
  27166. /** Spherical coordinates mode */
  27167. static readonly TEXTURE_SPHERICAL_MODE: number;
  27168. /** Planar coordinates mode */
  27169. static readonly TEXTURE_PLANAR_MODE: number;
  27170. /** Cubic coordinates mode */
  27171. static readonly TEXTURE_CUBIC_MODE: number;
  27172. /** Projection coordinates mode */
  27173. static readonly TEXTURE_PROJECTION_MODE: number;
  27174. /** Skybox coordinates mode */
  27175. static readonly TEXTURE_SKYBOX_MODE: number;
  27176. /** Inverse Cubic coordinates mode */
  27177. static readonly TEXTURE_INVCUBIC_MODE: number;
  27178. /** Equirectangular coordinates mode */
  27179. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27180. /** Equirectangular Fixed coordinates mode */
  27181. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27182. /** Equirectangular Fixed Mirrored coordinates mode */
  27183. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27184. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27185. static readonly SCALEMODE_FLOOR: number;
  27186. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27187. static readonly SCALEMODE_NEAREST: number;
  27188. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27189. static readonly SCALEMODE_CEILING: number;
  27190. /**
  27191. * Returns the current version of the framework
  27192. */
  27193. static readonly Version: string;
  27194. /**
  27195. * Returns a string describing the current engine
  27196. */
  27197. readonly description: string;
  27198. /**
  27199. * Gets or sets the epsilon value used by collision engine
  27200. */
  27201. static CollisionsEpsilon: number;
  27202. /**
  27203. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27204. */
  27205. static ShadersRepository: string;
  27206. /**
  27207. * Method called to create the default loading screen.
  27208. * This can be overriden in your own app.
  27209. * @param canvas The rendering canvas element
  27210. * @returns The loading screen
  27211. */
  27212. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27213. /**
  27214. * Method called to create the default rescale post process on each engine.
  27215. */
  27216. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27217. /**
  27218. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27219. */
  27220. forcePOTTextures: boolean;
  27221. /**
  27222. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27223. */
  27224. isFullscreen: boolean;
  27225. /**
  27226. * Gets a boolean indicating if the pointer is currently locked
  27227. */
  27228. isPointerLock: boolean;
  27229. /**
  27230. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27231. */
  27232. cullBackFaces: boolean;
  27233. /**
  27234. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27235. */
  27236. renderEvenInBackground: boolean;
  27237. /**
  27238. * Gets or sets a boolean indicating that cache can be kept between frames
  27239. */
  27240. preventCacheWipeBetweenFrames: boolean;
  27241. /**
  27242. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27243. **/
  27244. enableOfflineSupport: boolean;
  27245. /**
  27246. * 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)
  27247. **/
  27248. disableManifestCheck: boolean;
  27249. /**
  27250. * Gets the list of created scenes
  27251. */
  27252. scenes: Scene[];
  27253. /**
  27254. * Event raised when a new scene is created
  27255. */
  27256. onNewSceneAddedObservable: Observable<Scene>;
  27257. /**
  27258. * Gets the list of created postprocesses
  27259. */
  27260. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27261. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27262. validateShaderPrograms: boolean;
  27263. /**
  27264. * Observable event triggered each time the rendering canvas is resized
  27265. */
  27266. onResizeObservable: Observable<Engine>;
  27267. /**
  27268. * Observable event triggered each time the canvas loses focus
  27269. */
  27270. onCanvasBlurObservable: Observable<Engine>;
  27271. /**
  27272. * Observable event triggered each time the canvas gains focus
  27273. */
  27274. onCanvasFocusObservable: Observable<Engine>;
  27275. /**
  27276. * Observable event triggered each time the canvas receives pointerout event
  27277. */
  27278. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27279. /**
  27280. * Observable event triggered before each texture is initialized
  27281. */
  27282. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27283. private _vrDisplay;
  27284. private _vrSupported;
  27285. private _oldSize;
  27286. private _oldHardwareScaleFactor;
  27287. private _vrExclusivePointerMode;
  27288. private _webVRInitPromise;
  27289. /**
  27290. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27291. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27292. */
  27293. readonly isInVRExclusivePointerMode: boolean;
  27294. /**
  27295. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27296. */
  27297. disableUniformBuffers: boolean;
  27298. /** @hidden */
  27299. _uniformBuffers: UniformBuffer[];
  27300. /**
  27301. * Gets a boolean indicating that the engine supports uniform buffers
  27302. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27303. */
  27304. readonly supportsUniformBuffers: boolean;
  27305. /**
  27306. * Observable raised when the engine begins a new frame
  27307. */
  27308. onBeginFrameObservable: Observable<Engine>;
  27309. /**
  27310. * If set, will be used to request the next animation frame for the render loop
  27311. */
  27312. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27313. /**
  27314. * Observable raised when the engine ends the current frame
  27315. */
  27316. onEndFrameObservable: Observable<Engine>;
  27317. /**
  27318. * Observable raised when the engine is about to compile a shader
  27319. */
  27320. onBeforeShaderCompilationObservable: Observable<Engine>;
  27321. /**
  27322. * Observable raised when the engine has jsut compiled a shader
  27323. */
  27324. onAfterShaderCompilationObservable: Observable<Engine>;
  27325. /** @hidden */
  27326. _gl: WebGLRenderingContext;
  27327. private _renderingCanvas;
  27328. private _windowIsBackground;
  27329. private _webGLVersion;
  27330. /**
  27331. * Gets a boolean indicating that only power of 2 textures are supported
  27332. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27333. */
  27334. readonly needPOTTextures: boolean;
  27335. /** @hidden */
  27336. _badOS: boolean;
  27337. /** @hidden */
  27338. _badDesktopOS: boolean;
  27339. /**
  27340. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27341. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27342. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27343. */
  27344. disableTextureBindingOptimization: boolean;
  27345. /**
  27346. * Gets the audio engine
  27347. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27348. * @ignorenaming
  27349. */
  27350. static audioEngine: IAudioEngine;
  27351. /**
  27352. * Default AudioEngine factory responsible of creating the Audio Engine.
  27353. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27354. */
  27355. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27356. /**
  27357. * Default offline support factory responsible of creating a tool used to store data locally.
  27358. * By default, this will create a Database object if the workload has been embedded.
  27359. */
  27360. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27361. private _onFocus;
  27362. private _onBlur;
  27363. private _onCanvasPointerOut;
  27364. private _onCanvasBlur;
  27365. private _onCanvasFocus;
  27366. private _onFullscreenChange;
  27367. private _onPointerLockChange;
  27368. private _onVRDisplayPointerRestricted;
  27369. private _onVRDisplayPointerUnrestricted;
  27370. private _onVrDisplayConnect;
  27371. private _onVrDisplayDisconnect;
  27372. private _onVrDisplayPresentChange;
  27373. /**
  27374. * Observable signaled when VR display mode changes
  27375. */
  27376. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27377. /**
  27378. * Observable signaled when VR request present is complete
  27379. */
  27380. onVRRequestPresentComplete: Observable<boolean>;
  27381. /**
  27382. * Observable signaled when VR request present starts
  27383. */
  27384. onVRRequestPresentStart: Observable<Engine>;
  27385. private _hardwareScalingLevel;
  27386. /** @hidden */
  27387. protected _caps: EngineCapabilities;
  27388. private _pointerLockRequested;
  27389. private _isStencilEnable;
  27390. private _colorWrite;
  27391. private _loadingScreen;
  27392. /** @hidden */
  27393. _drawCalls: PerfCounter;
  27394. /** @hidden */
  27395. _textureCollisions: PerfCounter;
  27396. private _glVersion;
  27397. private _glRenderer;
  27398. private _glVendor;
  27399. private _videoTextureSupported;
  27400. private _renderingQueueLaunched;
  27401. private _activeRenderLoops;
  27402. private _deterministicLockstep;
  27403. private _lockstepMaxSteps;
  27404. /**
  27405. * Observable signaled when a context lost event is raised
  27406. */
  27407. onContextLostObservable: Observable<Engine>;
  27408. /**
  27409. * Observable signaled when a context restored event is raised
  27410. */
  27411. onContextRestoredObservable: Observable<Engine>;
  27412. private _onContextLost;
  27413. private _onContextRestored;
  27414. private _contextWasLost;
  27415. private _doNotHandleContextLost;
  27416. /**
  27417. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27418. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27419. */
  27420. doNotHandleContextLost: boolean;
  27421. private _performanceMonitor;
  27422. private _fps;
  27423. private _deltaTime;
  27424. /**
  27425. * Turn this value on if you want to pause FPS computation when in background
  27426. */
  27427. disablePerformanceMonitorInBackground: boolean;
  27428. /**
  27429. * Gets the performance monitor attached to this engine
  27430. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27431. */
  27432. readonly performanceMonitor: PerformanceMonitor;
  27433. /** @hidden */
  27434. protected _depthCullingState: _DepthCullingState;
  27435. /** @hidden */
  27436. protected _stencilState: _StencilState;
  27437. /** @hidden */
  27438. protected _alphaState: _AlphaState;
  27439. /** @hidden */
  27440. protected _alphaMode: number;
  27441. protected _internalTexturesCache: InternalTexture[];
  27442. /** @hidden */
  27443. protected _activeChannel: number;
  27444. private _currentTextureChannel;
  27445. /** @hidden */
  27446. protected _boundTexturesCache: {
  27447. [key: string]: Nullable<InternalTexture>;
  27448. };
  27449. /** @hidden */
  27450. protected _currentEffect: Nullable<Effect>;
  27451. /** @hidden */
  27452. protected _currentProgram: Nullable<WebGLProgram>;
  27453. private _compiledEffects;
  27454. private _vertexAttribArraysEnabled;
  27455. /** @hidden */
  27456. protected _cachedViewport: Nullable<Viewport>;
  27457. private _cachedVertexArrayObject;
  27458. /** @hidden */
  27459. protected _cachedVertexBuffers: any;
  27460. /** @hidden */
  27461. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27462. /** @hidden */
  27463. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27464. /** @hidden */
  27465. protected _currentRenderTarget: Nullable<InternalTexture>;
  27466. private _uintIndicesCurrentlySet;
  27467. private _currentBoundBuffer;
  27468. /** @hidden */
  27469. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27470. private _currentBufferPointers;
  27471. private _currentInstanceLocations;
  27472. private _currentInstanceBuffers;
  27473. private _textureUnits;
  27474. private _firstBoundInternalTextureTracker;
  27475. private _lastBoundInternalTextureTracker;
  27476. private _workingCanvas;
  27477. private _workingContext;
  27478. private _rescalePostProcess;
  27479. private _dummyFramebuffer;
  27480. private _externalData;
  27481. private _bindedRenderFunction;
  27482. private _vaoRecordInProgress;
  27483. private _mustWipeVertexAttributes;
  27484. private _emptyTexture;
  27485. private _emptyCubeTexture;
  27486. private _emptyTexture3D;
  27487. /** @hidden */
  27488. _frameHandler: number;
  27489. private _nextFreeTextureSlots;
  27490. private _maxSimultaneousTextures;
  27491. private _activeRequests;
  27492. private _texturesSupported;
  27493. private _textureFormatInUse;
  27494. /**
  27495. * Gets the list of texture formats supported
  27496. */
  27497. readonly texturesSupported: Array<string>;
  27498. /**
  27499. * Gets the list of texture formats in use
  27500. */
  27501. readonly textureFormatInUse: Nullable<string>;
  27502. /**
  27503. * Gets the current viewport
  27504. */
  27505. readonly currentViewport: Nullable<Viewport>;
  27506. /**
  27507. * Gets the default empty texture
  27508. */
  27509. readonly emptyTexture: InternalTexture;
  27510. /**
  27511. * Gets the default empty 3D texture
  27512. */
  27513. readonly emptyTexture3D: InternalTexture;
  27514. /**
  27515. * Gets the default empty cube texture
  27516. */
  27517. readonly emptyCubeTexture: InternalTexture;
  27518. /**
  27519. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27520. */
  27521. readonly premultipliedAlpha: boolean;
  27522. /**
  27523. * Creates a new engine
  27524. * @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
  27525. * @param antialias defines enable antialiasing (default: false)
  27526. * @param options defines further options to be sent to the getContext() function
  27527. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27528. */
  27529. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27530. private _disableTouchAction;
  27531. private _rebuildInternalTextures;
  27532. private _rebuildEffects;
  27533. /**
  27534. * Gets a boolean indicating if all created effects are ready
  27535. * @returns true if all effects are ready
  27536. */
  27537. areAllEffectsReady(): boolean;
  27538. private _rebuildBuffers;
  27539. private _initGLContext;
  27540. /**
  27541. * Gets version of the current webGL context
  27542. */
  27543. readonly webGLVersion: number;
  27544. /**
  27545. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27546. */
  27547. readonly isStencilEnable: boolean;
  27548. private _prepareWorkingCanvas;
  27549. /**
  27550. * Reset the texture cache to empty state
  27551. */
  27552. resetTextureCache(): void;
  27553. /**
  27554. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27555. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27556. * @returns true if engine is in deterministic lock step mode
  27557. */
  27558. isDeterministicLockStep(): boolean;
  27559. /**
  27560. * Gets the max steps when engine is running in deterministic lock step
  27561. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27562. * @returns the max steps
  27563. */
  27564. getLockstepMaxSteps(): number;
  27565. /**
  27566. * Gets an object containing information about the current webGL context
  27567. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27568. */
  27569. getGlInfo(): {
  27570. vendor: string;
  27571. renderer: string;
  27572. version: string;
  27573. };
  27574. /**
  27575. * Gets current aspect ratio
  27576. * @param camera defines the camera to use to get the aspect ratio
  27577. * @param useScreen defines if screen size must be used (or the current render target if any)
  27578. * @returns a number defining the aspect ratio
  27579. */
  27580. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27581. /**
  27582. * Gets current screen aspect ratio
  27583. * @returns a number defining the aspect ratio
  27584. */
  27585. getScreenAspectRatio(): number;
  27586. /**
  27587. * Gets the current render width
  27588. * @param useScreen defines if screen size must be used (or the current render target if any)
  27589. * @returns a number defining the current render width
  27590. */
  27591. getRenderWidth(useScreen?: boolean): number;
  27592. /**
  27593. * Gets the current render height
  27594. * @param useScreen defines if screen size must be used (or the current render target if any)
  27595. * @returns a number defining the current render height
  27596. */
  27597. getRenderHeight(useScreen?: boolean): number;
  27598. /**
  27599. * Gets the HTML canvas attached with the current webGL context
  27600. * @returns a HTML canvas
  27601. */
  27602. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27603. /**
  27604. * Gets the client rect of the HTML canvas attached with the current webGL context
  27605. * @returns a client rectanglee
  27606. */
  27607. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27608. /**
  27609. * Defines the hardware scaling level.
  27610. * By default the hardware scaling level is computed from the window device ratio.
  27611. * 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.
  27612. * @param level defines the level to use
  27613. */
  27614. setHardwareScalingLevel(level: number): void;
  27615. /**
  27616. * Gets the current hardware scaling level.
  27617. * By default the hardware scaling level is computed from the window device ratio.
  27618. * 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.
  27619. * @returns a number indicating the current hardware scaling level
  27620. */
  27621. getHardwareScalingLevel(): number;
  27622. /**
  27623. * Gets the list of loaded textures
  27624. * @returns an array containing all loaded textures
  27625. */
  27626. getLoadedTexturesCache(): InternalTexture[];
  27627. /**
  27628. * Gets the object containing all engine capabilities
  27629. * @returns the EngineCapabilities object
  27630. */
  27631. getCaps(): EngineCapabilities;
  27632. /**
  27633. * Gets the current depth function
  27634. * @returns a number defining the depth function
  27635. */
  27636. getDepthFunction(): Nullable<number>;
  27637. /**
  27638. * Sets the current depth function
  27639. * @param depthFunc defines the function to use
  27640. */
  27641. setDepthFunction(depthFunc: number): void;
  27642. /**
  27643. * Sets the current depth function to GREATER
  27644. */
  27645. setDepthFunctionToGreater(): void;
  27646. /**
  27647. * Sets the current depth function to GEQUAL
  27648. */
  27649. setDepthFunctionToGreaterOrEqual(): void;
  27650. /**
  27651. * Sets the current depth function to LESS
  27652. */
  27653. setDepthFunctionToLess(): void;
  27654. /**
  27655. * Sets the current depth function to LEQUAL
  27656. */
  27657. setDepthFunctionToLessOrEqual(): void;
  27658. /**
  27659. * Gets a boolean indicating if stencil buffer is enabled
  27660. * @returns the current stencil buffer state
  27661. */
  27662. getStencilBuffer(): boolean;
  27663. /**
  27664. * Enable or disable the stencil buffer
  27665. * @param enable defines if the stencil buffer must be enabled or disabled
  27666. */
  27667. setStencilBuffer(enable: boolean): void;
  27668. /**
  27669. * Gets the current stencil mask
  27670. * @returns a number defining the new stencil mask to use
  27671. */
  27672. getStencilMask(): number;
  27673. /**
  27674. * Sets the current stencil mask
  27675. * @param mask defines the new stencil mask to use
  27676. */
  27677. setStencilMask(mask: number): void;
  27678. /**
  27679. * Gets the current stencil function
  27680. * @returns a number defining the stencil function to use
  27681. */
  27682. getStencilFunction(): number;
  27683. /**
  27684. * Gets the current stencil reference value
  27685. * @returns a number defining the stencil reference value to use
  27686. */
  27687. getStencilFunctionReference(): number;
  27688. /**
  27689. * Gets the current stencil mask
  27690. * @returns a number defining the stencil mask to use
  27691. */
  27692. getStencilFunctionMask(): number;
  27693. /**
  27694. * Sets the current stencil function
  27695. * @param stencilFunc defines the new stencil function to use
  27696. */
  27697. setStencilFunction(stencilFunc: number): void;
  27698. /**
  27699. * Sets the current stencil reference
  27700. * @param reference defines the new stencil reference to use
  27701. */
  27702. setStencilFunctionReference(reference: number): void;
  27703. /**
  27704. * Sets the current stencil mask
  27705. * @param mask defines the new stencil mask to use
  27706. */
  27707. setStencilFunctionMask(mask: number): void;
  27708. /**
  27709. * Gets the current stencil operation when stencil fails
  27710. * @returns a number defining stencil operation to use when stencil fails
  27711. */
  27712. getStencilOperationFail(): number;
  27713. /**
  27714. * Gets the current stencil operation when depth fails
  27715. * @returns a number defining stencil operation to use when depth fails
  27716. */
  27717. getStencilOperationDepthFail(): number;
  27718. /**
  27719. * Gets the current stencil operation when stencil passes
  27720. * @returns a number defining stencil operation to use when stencil passes
  27721. */
  27722. getStencilOperationPass(): number;
  27723. /**
  27724. * Sets the stencil operation to use when stencil fails
  27725. * @param operation defines the stencil operation to use when stencil fails
  27726. */
  27727. setStencilOperationFail(operation: number): void;
  27728. /**
  27729. * Sets the stencil operation to use when depth fails
  27730. * @param operation defines the stencil operation to use when depth fails
  27731. */
  27732. setStencilOperationDepthFail(operation: number): void;
  27733. /**
  27734. * Sets the stencil operation to use when stencil passes
  27735. * @param operation defines the stencil operation to use when stencil passes
  27736. */
  27737. setStencilOperationPass(operation: number): void;
  27738. /**
  27739. * Sets a boolean indicating if the dithering state is enabled or disabled
  27740. * @param value defines the dithering state
  27741. */
  27742. setDitheringState(value: boolean): void;
  27743. /**
  27744. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27745. * @param value defines the rasterizer state
  27746. */
  27747. setRasterizerState(value: boolean): void;
  27748. /**
  27749. * stop executing a render loop function and remove it from the execution array
  27750. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27751. */
  27752. stopRenderLoop(renderFunction?: () => void): void;
  27753. /** @hidden */
  27754. _renderLoop(): void;
  27755. /**
  27756. * Register and execute a render loop. The engine can have more than one render function
  27757. * @param renderFunction defines the function to continuously execute
  27758. */
  27759. runRenderLoop(renderFunction: () => void): void;
  27760. /**
  27761. * Toggle full screen mode
  27762. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27763. */
  27764. switchFullscreen(requestPointerLock: boolean): void;
  27765. /**
  27766. * Enters full screen mode
  27767. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27768. */
  27769. enterFullscreen(requestPointerLock: boolean): void;
  27770. /**
  27771. * Exits full screen mode
  27772. */
  27773. exitFullscreen(): void;
  27774. /**
  27775. * Clear the current render buffer or the current render target (if any is set up)
  27776. * @param color defines the color to use
  27777. * @param backBuffer defines if the back buffer must be cleared
  27778. * @param depth defines if the depth buffer must be cleared
  27779. * @param stencil defines if the stencil buffer must be cleared
  27780. */
  27781. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27782. /**
  27783. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27784. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27785. * @param y defines the y-coordinate of the corner of the clear rectangle
  27786. * @param width defines the width of the clear rectangle
  27787. * @param height defines the height of the clear rectangle
  27788. * @param clearColor defines the clear color
  27789. */
  27790. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27791. /**
  27792. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27793. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27794. * @param y defines the y-coordinate of the corner of the clear rectangle
  27795. * @param width defines the width of the clear rectangle
  27796. * @param height defines the height of the clear rectangle
  27797. */
  27798. enableScissor(x: number, y: number, width: number, height: number): void;
  27799. /**
  27800. * Disable previously set scissor test rectangle
  27801. */
  27802. disableScissor(): void;
  27803. private _viewportCached;
  27804. /** @hidden */
  27805. _viewport(x: number, y: number, width: number, height: number): void;
  27806. /**
  27807. * Set the WebGL's viewport
  27808. * @param viewport defines the viewport element to be used
  27809. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27810. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27811. */
  27812. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27813. /**
  27814. * Directly set the WebGL Viewport
  27815. * @param x defines the x coordinate of the viewport (in screen space)
  27816. * @param y defines the y coordinate of the viewport (in screen space)
  27817. * @param width defines the width of the viewport (in screen space)
  27818. * @param height defines the height of the viewport (in screen space)
  27819. * @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
  27820. */
  27821. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27822. /**
  27823. * Begin a new frame
  27824. */
  27825. beginFrame(): void;
  27826. /**
  27827. * Enf the current frame
  27828. */
  27829. endFrame(): void;
  27830. /**
  27831. * Resize the view according to the canvas' size
  27832. */
  27833. resize(): void;
  27834. /**
  27835. * Force a specific size of the canvas
  27836. * @param width defines the new canvas' width
  27837. * @param height defines the new canvas' height
  27838. */
  27839. setSize(width: number, height: number): void;
  27840. /**
  27841. * Gets a boolean indicating if a webVR device was detected
  27842. * @returns true if a webVR device was detected
  27843. */
  27844. isVRDevicePresent(): boolean;
  27845. /**
  27846. * Gets the current webVR device
  27847. * @returns the current webVR device (or null)
  27848. */
  27849. getVRDevice(): any;
  27850. /**
  27851. * Initializes a webVR display and starts listening to display change events
  27852. * The onVRDisplayChangedObservable will be notified upon these changes
  27853. * @returns The onVRDisplayChangedObservable
  27854. */
  27855. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27856. /**
  27857. * Initializes a webVR display and starts listening to display change events
  27858. * The onVRDisplayChangedObservable will be notified upon these changes
  27859. * @returns A promise containing a VRDisplay and if vr is supported
  27860. */
  27861. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27862. /**
  27863. * Call this function to switch to webVR mode
  27864. * Will do nothing if webVR is not supported or if there is no webVR device
  27865. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27866. */
  27867. enableVR(): void;
  27868. /**
  27869. * Call this function to leave webVR mode
  27870. * Will do nothing if webVR is not supported or if there is no webVR device
  27871. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27872. */
  27873. disableVR(): void;
  27874. private _onVRFullScreenTriggered;
  27875. private _getVRDisplaysAsync;
  27876. /**
  27877. * Binds the frame buffer to the specified texture.
  27878. * @param texture The texture to render to or null for the default canvas
  27879. * @param faceIndex The face of the texture to render to in case of cube texture
  27880. * @param requiredWidth The width of the target to render to
  27881. * @param requiredHeight The height of the target to render to
  27882. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27883. * @param depthStencilTexture The depth stencil texture to use to render
  27884. * @param lodLevel defines le lod level to bind to the frame buffer
  27885. */
  27886. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27887. private bindUnboundFramebuffer;
  27888. /**
  27889. * Unbind the current render target texture from the webGL context
  27890. * @param texture defines the render target texture to unbind
  27891. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27892. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27893. */
  27894. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27895. /**
  27896. * Unbind a list of render target textures from the webGL context
  27897. * This is used only when drawBuffer extension or webGL2 are active
  27898. * @param textures defines the render target textures to unbind
  27899. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27900. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27901. */
  27902. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27903. /**
  27904. * Force the mipmap generation for the given render target texture
  27905. * @param texture defines the render target texture to use
  27906. */
  27907. generateMipMapsForCubemap(texture: InternalTexture): void;
  27908. /**
  27909. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27910. */
  27911. flushFramebuffer(): void;
  27912. /**
  27913. * Unbind the current render target and bind the default framebuffer
  27914. */
  27915. restoreDefaultFramebuffer(): void;
  27916. /**
  27917. * Create an uniform buffer
  27918. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27919. * @param elements defines the content of the uniform buffer
  27920. * @returns the webGL uniform buffer
  27921. */
  27922. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27923. /**
  27924. * Create a dynamic uniform buffer
  27925. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27926. * @param elements defines the content of the uniform buffer
  27927. * @returns the webGL uniform buffer
  27928. */
  27929. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27930. /**
  27931. * Update an existing uniform buffer
  27932. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27933. * @param uniformBuffer defines the target uniform buffer
  27934. * @param elements defines the content to update
  27935. * @param offset defines the offset in the uniform buffer where update should start
  27936. * @param count defines the size of the data to update
  27937. */
  27938. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27939. private _resetVertexBufferBinding;
  27940. /**
  27941. * Creates a vertex buffer
  27942. * @param data the data for the vertex buffer
  27943. * @returns the new WebGL static buffer
  27944. */
  27945. createVertexBuffer(data: DataArray): WebGLBuffer;
  27946. /**
  27947. * Creates a dynamic vertex buffer
  27948. * @param data the data for the dynamic vertex buffer
  27949. * @returns the new WebGL dynamic buffer
  27950. */
  27951. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27952. /**
  27953. * Update a dynamic index buffer
  27954. * @param indexBuffer defines the target index buffer
  27955. * @param indices defines the data to update
  27956. * @param offset defines the offset in the target index buffer where update should start
  27957. */
  27958. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27959. /**
  27960. * Updates a dynamic vertex buffer.
  27961. * @param vertexBuffer the vertex buffer to update
  27962. * @param data the data used to update the vertex buffer
  27963. * @param byteOffset the byte offset of the data
  27964. * @param byteLength the byte length of the data
  27965. */
  27966. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27967. private _resetIndexBufferBinding;
  27968. /**
  27969. * Creates a new index buffer
  27970. * @param indices defines the content of the index buffer
  27971. * @param updatable defines if the index buffer must be updatable
  27972. * @returns a new webGL buffer
  27973. */
  27974. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27975. /**
  27976. * Bind a webGL buffer to the webGL context
  27977. * @param buffer defines the buffer to bind
  27978. */
  27979. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27980. /**
  27981. * Bind an uniform buffer to the current webGL context
  27982. * @param buffer defines the buffer to bind
  27983. */
  27984. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27985. /**
  27986. * Bind a buffer to the current webGL context at a given location
  27987. * @param buffer defines the buffer to bind
  27988. * @param location defines the index where to bind the buffer
  27989. */
  27990. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27991. /**
  27992. * Bind a specific block at a given index in a specific shader program
  27993. * @param shaderProgram defines the shader program
  27994. * @param blockName defines the block name
  27995. * @param index defines the index where to bind the block
  27996. */
  27997. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27998. private bindIndexBuffer;
  27999. private bindBuffer;
  28000. /**
  28001. * update the bound buffer with the given data
  28002. * @param data defines the data to update
  28003. */
  28004. updateArrayBuffer(data: Float32Array): void;
  28005. private _vertexAttribPointer;
  28006. private _bindIndexBufferWithCache;
  28007. private _bindVertexBuffersAttributes;
  28008. /**
  28009. * Records a vertex array object
  28010. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28011. * @param vertexBuffers defines the list of vertex buffers to store
  28012. * @param indexBuffer defines the index buffer to store
  28013. * @param effect defines the effect to store
  28014. * @returns the new vertex array object
  28015. */
  28016. recordVertexArrayObject(vertexBuffers: {
  28017. [key: string]: VertexBuffer;
  28018. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28019. /**
  28020. * Bind a specific vertex array object
  28021. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28022. * @param vertexArrayObject defines the vertex array object to bind
  28023. * @param indexBuffer defines the index buffer to bind
  28024. */
  28025. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28026. /**
  28027. * Bind webGl buffers directly to the webGL context
  28028. * @param vertexBuffer defines the vertex buffer to bind
  28029. * @param indexBuffer defines the index buffer to bind
  28030. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28031. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28032. * @param effect defines the effect associated with the vertex buffer
  28033. */
  28034. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28035. private _unbindVertexArrayObject;
  28036. /**
  28037. * Bind a list of vertex buffers to the webGL context
  28038. * @param vertexBuffers defines the list of vertex buffers to bind
  28039. * @param indexBuffer defines the index buffer to bind
  28040. * @param effect defines the effect associated with the vertex buffers
  28041. */
  28042. bindBuffers(vertexBuffers: {
  28043. [key: string]: Nullable<VertexBuffer>;
  28044. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28045. /**
  28046. * Unbind all instance attributes
  28047. */
  28048. unbindInstanceAttributes(): void;
  28049. /**
  28050. * Release and free the memory of a vertex array object
  28051. * @param vao defines the vertex array object to delete
  28052. */
  28053. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28054. /** @hidden */
  28055. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28056. /**
  28057. * Creates a webGL buffer to use with instanciation
  28058. * @param capacity defines the size of the buffer
  28059. * @returns the webGL buffer
  28060. */
  28061. createInstancesBuffer(capacity: number): WebGLBuffer;
  28062. /**
  28063. * Delete a webGL buffer used with instanciation
  28064. * @param buffer defines the webGL buffer to delete
  28065. */
  28066. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28067. /**
  28068. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28069. * @param instancesBuffer defines the webGL buffer to update and bind
  28070. * @param data defines the data to store in the buffer
  28071. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28072. */
  28073. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28074. /**
  28075. * Apply all cached states (depth, culling, stencil and alpha)
  28076. */
  28077. applyStates(): void;
  28078. /**
  28079. * Send a draw order
  28080. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28081. * @param indexStart defines the starting index
  28082. * @param indexCount defines the number of index to draw
  28083. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28084. */
  28085. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28086. /**
  28087. * Draw a list of points
  28088. * @param verticesStart defines the index of first vertex to draw
  28089. * @param verticesCount defines the count of vertices to draw
  28090. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28091. */
  28092. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28093. /**
  28094. * Draw a list of unindexed primitives
  28095. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28096. * @param verticesStart defines the index of first vertex to draw
  28097. * @param verticesCount defines the count of vertices to draw
  28098. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28099. */
  28100. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28101. /**
  28102. * Draw a list of indexed primitives
  28103. * @param fillMode defines the primitive to use
  28104. * @param indexStart defines the starting index
  28105. * @param indexCount defines the number of index to draw
  28106. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28107. */
  28108. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28109. /**
  28110. * Draw a list of unindexed primitives
  28111. * @param fillMode defines the primitive to use
  28112. * @param verticesStart defines the index of first vertex to draw
  28113. * @param verticesCount defines the count of vertices to draw
  28114. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28115. */
  28116. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28117. private _drawMode;
  28118. /** @hidden */
  28119. _releaseEffect(effect: Effect): void;
  28120. /** @hidden */
  28121. _deleteProgram(program: WebGLProgram): void;
  28122. /**
  28123. * Create a new effect (used to store vertex/fragment shaders)
  28124. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28125. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28126. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28127. * @param samplers defines an array of string used to represent textures
  28128. * @param defines defines the string containing the defines to use to compile the shaders
  28129. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28130. * @param onCompiled defines a function to call when the effect creation is successful
  28131. * @param onError defines a function to call when the effect creation has failed
  28132. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28133. * @returns the new Effect
  28134. */
  28135. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  28136. private _compileShader;
  28137. private _compileRawShader;
  28138. /**
  28139. * Directly creates a webGL program
  28140. * @param vertexCode defines the vertex shader code to use
  28141. * @param fragmentCode defines the fragment shader code to use
  28142. * @param context defines the webGL context to use (if not set, the current one will be used)
  28143. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28144. * @returns the new webGL program
  28145. */
  28146. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28147. /**
  28148. * Creates a webGL program
  28149. * @param vertexCode defines the vertex shader code to use
  28150. * @param fragmentCode defines the fragment shader code to use
  28151. * @param defines defines the string containing the defines to use to compile the shaders
  28152. * @param context defines the webGL context to use (if not set, the current one will be used)
  28153. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28154. * @returns the new webGL program
  28155. */
  28156. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28157. private _createShaderProgram;
  28158. private _finalizeProgram;
  28159. /** @hidden */
  28160. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28161. /** @hidden */
  28162. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28163. /**
  28164. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28165. * @param shaderProgram defines the webGL program to use
  28166. * @param uniformsNames defines the list of uniform names
  28167. * @returns an array of webGL uniform locations
  28168. */
  28169. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28170. /**
  28171. * Gets the lsit of active attributes for a given webGL program
  28172. * @param shaderProgram defines the webGL program to use
  28173. * @param attributesNames defines the list of attribute names to get
  28174. * @returns an array of indices indicating the offset of each attribute
  28175. */
  28176. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28177. /**
  28178. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28179. * @param effect defines the effect to activate
  28180. */
  28181. enableEffect(effect: Nullable<Effect>): void;
  28182. /**
  28183. * Set the value of an uniform to an array of int32
  28184. * @param uniform defines the webGL uniform location where to store the value
  28185. * @param array defines the array of int32 to store
  28186. */
  28187. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28188. /**
  28189. * Set the value of an uniform to an array of int32 (stored as vec2)
  28190. * @param uniform defines the webGL uniform location where to store the value
  28191. * @param array defines the array of int32 to store
  28192. */
  28193. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28194. /**
  28195. * Set the value of an uniform to an array of int32 (stored as vec3)
  28196. * @param uniform defines the webGL uniform location where to store the value
  28197. * @param array defines the array of int32 to store
  28198. */
  28199. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28200. /**
  28201. * Set the value of an uniform to an array of int32 (stored as vec4)
  28202. * @param uniform defines the webGL uniform location where to store the value
  28203. * @param array defines the array of int32 to store
  28204. */
  28205. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28206. /**
  28207. * Set the value of an uniform to an array of float32
  28208. * @param uniform defines the webGL uniform location where to store the value
  28209. * @param array defines the array of float32 to store
  28210. */
  28211. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28212. /**
  28213. * Set the value of an uniform to an array of float32 (stored as vec2)
  28214. * @param uniform defines the webGL uniform location where to store the value
  28215. * @param array defines the array of float32 to store
  28216. */
  28217. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28218. /**
  28219. * Set the value of an uniform to an array of float32 (stored as vec3)
  28220. * @param uniform defines the webGL uniform location where to store the value
  28221. * @param array defines the array of float32 to store
  28222. */
  28223. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28224. /**
  28225. * Set the value of an uniform to an array of float32 (stored as vec4)
  28226. * @param uniform defines the webGL uniform location where to store the value
  28227. * @param array defines the array of float32 to store
  28228. */
  28229. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28230. /**
  28231. * Set the value of an uniform to an array of number
  28232. * @param uniform defines the webGL uniform location where to store the value
  28233. * @param array defines the array of number to store
  28234. */
  28235. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28236. /**
  28237. * Set the value of an uniform to an array of number (stored as vec2)
  28238. * @param uniform defines the webGL uniform location where to store the value
  28239. * @param array defines the array of number to store
  28240. */
  28241. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28242. /**
  28243. * Set the value of an uniform to an array of number (stored as vec3)
  28244. * @param uniform defines the webGL uniform location where to store the value
  28245. * @param array defines the array of number to store
  28246. */
  28247. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28248. /**
  28249. * Set the value of an uniform to an array of number (stored as vec4)
  28250. * @param uniform defines the webGL uniform location where to store the value
  28251. * @param array defines the array of number to store
  28252. */
  28253. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28254. /**
  28255. * Set the value of an uniform to an array of float32 (stored as matrices)
  28256. * @param uniform defines the webGL uniform location where to store the value
  28257. * @param matrices defines the array of float32 to store
  28258. */
  28259. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28260. /**
  28261. * Set the value of an uniform to a matrix
  28262. * @param uniform defines the webGL uniform location where to store the value
  28263. * @param matrix defines the matrix to store
  28264. */
  28265. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28266. /**
  28267. * Set the value of an uniform to a matrix (3x3)
  28268. * @param uniform defines the webGL uniform location where to store the value
  28269. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28270. */
  28271. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28272. /**
  28273. * Set the value of an uniform to a matrix (2x2)
  28274. * @param uniform defines the webGL uniform location where to store the value
  28275. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28276. */
  28277. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28278. /**
  28279. * Set the value of an uniform to a number (int)
  28280. * @param uniform defines the webGL uniform location where to store the value
  28281. * @param value defines the int number to store
  28282. */
  28283. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28284. /**
  28285. * Set the value of an uniform to a number (float)
  28286. * @param uniform defines the webGL uniform location where to store the value
  28287. * @param value defines the float number to store
  28288. */
  28289. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28290. /**
  28291. * Set the value of an uniform to a vec2
  28292. * @param uniform defines the webGL uniform location where to store the value
  28293. * @param x defines the 1st component of the value
  28294. * @param y defines the 2nd component of the value
  28295. */
  28296. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28297. /**
  28298. * Set the value of an uniform to a vec3
  28299. * @param uniform defines the webGL uniform location where to store the value
  28300. * @param x defines the 1st component of the value
  28301. * @param y defines the 2nd component of the value
  28302. * @param z defines the 3rd component of the value
  28303. */
  28304. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28305. /**
  28306. * Set the value of an uniform to a boolean
  28307. * @param uniform defines the webGL uniform location where to store the value
  28308. * @param bool defines the boolean to store
  28309. */
  28310. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28311. /**
  28312. * Set the value of an uniform to a vec4
  28313. * @param uniform defines the webGL uniform location where to store the value
  28314. * @param x defines the 1st component of the value
  28315. * @param y defines the 2nd component of the value
  28316. * @param z defines the 3rd component of the value
  28317. * @param w defines the 4th component of the value
  28318. */
  28319. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28320. /**
  28321. * Set the value of an uniform to a Color3
  28322. * @param uniform defines the webGL uniform location where to store the value
  28323. * @param color3 defines the color to store
  28324. */
  28325. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28326. /**
  28327. * Set the value of an uniform to a Color3 and an alpha value
  28328. * @param uniform defines the webGL uniform location where to store the value
  28329. * @param color3 defines the color to store
  28330. * @param alpha defines the alpha component to store
  28331. */
  28332. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28333. /**
  28334. * Sets a Color4 on a uniform variable
  28335. * @param uniform defines the uniform location
  28336. * @param color4 defines the value to be set
  28337. */
  28338. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28339. /**
  28340. * Set various states to the webGL context
  28341. * @param culling defines backface culling state
  28342. * @param zOffset defines the value to apply to zOffset (0 by default)
  28343. * @param force defines if states must be applied even if cache is up to date
  28344. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28345. */
  28346. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28347. /**
  28348. * Set the z offset to apply to current rendering
  28349. * @param value defines the offset to apply
  28350. */
  28351. setZOffset(value: number): void;
  28352. /**
  28353. * Gets the current value of the zOffset
  28354. * @returns the current zOffset state
  28355. */
  28356. getZOffset(): number;
  28357. /**
  28358. * Enable or disable depth buffering
  28359. * @param enable defines the state to set
  28360. */
  28361. setDepthBuffer(enable: boolean): void;
  28362. /**
  28363. * Gets a boolean indicating if depth writing is enabled
  28364. * @returns the current depth writing state
  28365. */
  28366. getDepthWrite(): boolean;
  28367. /**
  28368. * Enable or disable depth writing
  28369. * @param enable defines the state to set
  28370. */
  28371. setDepthWrite(enable: boolean): void;
  28372. /**
  28373. * Enable or disable color writing
  28374. * @param enable defines the state to set
  28375. */
  28376. setColorWrite(enable: boolean): void;
  28377. /**
  28378. * Gets a boolean indicating if color writing is enabled
  28379. * @returns the current color writing state
  28380. */
  28381. getColorWrite(): boolean;
  28382. /**
  28383. * Sets alpha constants used by some alpha blending modes
  28384. * @param r defines the red component
  28385. * @param g defines the green component
  28386. * @param b defines the blue component
  28387. * @param a defines the alpha component
  28388. */
  28389. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28390. /**
  28391. * Sets the current alpha mode
  28392. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28393. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28394. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28395. */
  28396. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28397. /**
  28398. * Gets the current alpha mode
  28399. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28400. * @returns the current alpha mode
  28401. */
  28402. getAlphaMode(): number;
  28403. /**
  28404. * Clears the list of texture accessible through engine.
  28405. * This can help preventing texture load conflict due to name collision.
  28406. */
  28407. clearInternalTexturesCache(): void;
  28408. /**
  28409. * Force the entire cache to be cleared
  28410. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28411. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28412. */
  28413. wipeCaches(bruteForce?: boolean): void;
  28414. /**
  28415. * Set the compressed texture format to use, based on the formats you have, and the formats
  28416. * supported by the hardware / browser.
  28417. *
  28418. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28419. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28420. * to API arguments needed to compressed textures. This puts the burden on the container
  28421. * generator to house the arcane code for determining these for current & future formats.
  28422. *
  28423. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28424. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28425. *
  28426. * Note: The result of this call is not taken into account when a texture is base64.
  28427. *
  28428. * @param formatsAvailable defines the list of those format families you have created
  28429. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28430. *
  28431. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28432. * @returns The extension selected.
  28433. */
  28434. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28435. private _getSamplingParameters;
  28436. private _partialLoadImg;
  28437. private _cascadeLoadImgs;
  28438. /** @hidden */
  28439. _createTexture(): WebGLTexture;
  28440. /**
  28441. * Usually called from Texture.ts.
  28442. * Passed information to create a WebGLTexture
  28443. * @param urlArg defines a value which contains one of the following:
  28444. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28445. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28446. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28447. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28448. * @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)
  28449. * @param scene needed for loading to the correct scene
  28450. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28451. * @param onLoad optional callback to be called upon successful completion
  28452. * @param onError optional callback to be called upon failure
  28453. * @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
  28454. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28455. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28456. * @param forcedExtension defines the extension to use to pick the right loader
  28457. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28458. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28459. */
  28460. 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;
  28461. private _rescaleTexture;
  28462. /**
  28463. * Update a raw texture
  28464. * @param texture defines the texture to update
  28465. * @param data defines the data to store in the texture
  28466. * @param format defines the format of the data
  28467. * @param invertY defines if data must be stored with Y axis inverted
  28468. * @param compression defines the compression used (null by default)
  28469. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28470. */
  28471. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28472. /**
  28473. * Creates a raw texture
  28474. * @param data defines the data to store in the texture
  28475. * @param width defines the width of the texture
  28476. * @param height defines the height of the texture
  28477. * @param format defines the format of the data
  28478. * @param generateMipMaps defines if the engine should generate the mip levels
  28479. * @param invertY defines if data must be stored with Y axis inverted
  28480. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28481. * @param compression defines the compression used (null by default)
  28482. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28483. * @returns the raw texture inside an InternalTexture
  28484. */
  28485. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28486. private _unpackFlipYCached;
  28487. /**
  28488. * In case you are sharing the context with other applications, it might
  28489. * be interested to not cache the unpack flip y state to ensure a consistent
  28490. * value would be set.
  28491. */
  28492. enableUnpackFlipYCached: boolean;
  28493. /** @hidden */
  28494. _unpackFlipY(value: boolean): void;
  28495. /** @hidden */
  28496. _getUnpackAlignement(): number;
  28497. /**
  28498. * Creates a dynamic texture
  28499. * @param width defines the width of the texture
  28500. * @param height defines the height of the texture
  28501. * @param generateMipMaps defines if the engine should generate the mip levels
  28502. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28503. * @returns the dynamic texture inside an InternalTexture
  28504. */
  28505. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28506. /**
  28507. * Update the sampling mode of a given texture
  28508. * @param samplingMode defines the required sampling mode
  28509. * @param texture defines the texture to update
  28510. */
  28511. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28512. /**
  28513. * Update the content of a dynamic texture
  28514. * @param texture defines the texture to update
  28515. * @param canvas defines the canvas containing the source
  28516. * @param invertY defines if data must be stored with Y axis inverted
  28517. * @param premulAlpha defines if alpha is stored as premultiplied
  28518. * @param format defines the format of the data
  28519. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28520. */
  28521. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28522. /**
  28523. * Update a video texture
  28524. * @param texture defines the texture to update
  28525. * @param video defines the video element to use
  28526. * @param invertY defines if data must be stored with Y axis inverted
  28527. */
  28528. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28529. /**
  28530. * Updates a depth texture Comparison Mode and Function.
  28531. * If the comparison Function is equal to 0, the mode will be set to none.
  28532. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28533. * @param texture The texture to set the comparison function for
  28534. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28535. */
  28536. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28537. private _setupDepthStencilTexture;
  28538. /**
  28539. * Creates a depth stencil texture.
  28540. * This is only available in WebGL 2 or with the depth texture extension available.
  28541. * @param size The size of face edge in the texture.
  28542. * @param options The options defining the texture.
  28543. * @returns The texture
  28544. */
  28545. createDepthStencilTexture(size: number | {
  28546. width: number;
  28547. height: number;
  28548. }, options: DepthTextureCreationOptions): InternalTexture;
  28549. /**
  28550. * Creates a depth stencil texture.
  28551. * This is only available in WebGL 2 or with the depth texture extension available.
  28552. * @param size The size of face edge in the texture.
  28553. * @param options The options defining the texture.
  28554. * @returns The texture
  28555. */
  28556. private _createDepthStencilTexture;
  28557. /**
  28558. * Creates a depth stencil cube texture.
  28559. * This is only available in WebGL 2.
  28560. * @param size The size of face edge in the cube texture.
  28561. * @param options The options defining the cube texture.
  28562. * @returns The cube texture
  28563. */
  28564. private _createDepthStencilCubeTexture;
  28565. /**
  28566. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28567. * @param renderTarget The render target to set the frame buffer for
  28568. */
  28569. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28570. /**
  28571. * Creates a new render target texture
  28572. * @param size defines the size of the texture
  28573. * @param options defines the options used to create the texture
  28574. * @returns a new render target texture stored in an InternalTexture
  28575. */
  28576. createRenderTargetTexture(size: number | {
  28577. width: number;
  28578. height: number;
  28579. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28580. /**
  28581. * Create a multi render target texture
  28582. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28583. * @param size defines the size of the texture
  28584. * @param options defines the creation options
  28585. * @returns the cube texture as an InternalTexture
  28586. */
  28587. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28588. private _setupFramebufferDepthAttachments;
  28589. /**
  28590. * Updates the sample count of a render target texture
  28591. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28592. * @param texture defines the texture to update
  28593. * @param samples defines the sample count to set
  28594. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28595. */
  28596. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28597. /**
  28598. * Update the sample count for a given multiple render target texture
  28599. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28600. * @param textures defines the textures to update
  28601. * @param samples defines the sample count to set
  28602. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28603. */
  28604. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28605. /** @hidden */
  28606. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28607. /** @hidden */
  28608. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28609. /** @hidden */
  28610. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28611. /** @hidden */
  28612. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28613. /**
  28614. * Creates a new render target cube texture
  28615. * @param size defines the size of the texture
  28616. * @param options defines the options used to create the texture
  28617. * @returns a new render target cube texture stored in an InternalTexture
  28618. */
  28619. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28620. /**
  28621. * Creates a cube texture
  28622. * @param rootUrl defines the url where the files to load is located
  28623. * @param scene defines the current scene
  28624. * @param files defines the list of files to load (1 per face)
  28625. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28626. * @param onLoad defines an optional callback raised when the texture is loaded
  28627. * @param onError defines an optional callback raised if there is an issue to load the texture
  28628. * @param format defines the format of the data
  28629. * @param forcedExtension defines the extension to use to pick the right loader
  28630. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28631. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28632. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28633. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28634. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28635. * @returns the cube texture as an InternalTexture
  28636. */
  28637. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  28638. /**
  28639. * @hidden
  28640. */
  28641. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28642. /**
  28643. * Update a raw cube texture
  28644. * @param texture defines the texture to udpdate
  28645. * @param data defines the data to store
  28646. * @param format defines the data format
  28647. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28648. * @param invertY defines if data must be stored with Y axis inverted
  28649. * @param compression defines the compression used (null by default)
  28650. * @param level defines which level of the texture to update
  28651. */
  28652. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28653. /**
  28654. * Creates a new raw cube texture
  28655. * @param data defines the array of data to use to create each face
  28656. * @param size defines the size of the textures
  28657. * @param format defines the format of the data
  28658. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28659. * @param generateMipMaps defines if the engine should generate the mip levels
  28660. * @param invertY defines if data must be stored with Y axis inverted
  28661. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28662. * @param compression defines the compression used (null by default)
  28663. * @returns the cube texture as an InternalTexture
  28664. */
  28665. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28666. /**
  28667. * Creates a new raw cube texture from a specified url
  28668. * @param url defines the url where the data is located
  28669. * @param scene defines the current scene
  28670. * @param size defines the size of the textures
  28671. * @param format defines the format of the data
  28672. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28673. * @param noMipmap defines if the engine should avoid generating the mip levels
  28674. * @param callback defines a callback used to extract texture data from loaded data
  28675. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28676. * @param onLoad defines a callback called when texture is loaded
  28677. * @param onError defines a callback called if there is an error
  28678. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28679. * @param invertY defines if data must be stored with Y axis inverted
  28680. * @returns the cube texture as an InternalTexture
  28681. */
  28682. 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;
  28683. /**
  28684. * Update a raw 3D texture
  28685. * @param texture defines the texture to update
  28686. * @param data defines the data to store
  28687. * @param format defines the data format
  28688. * @param invertY defines if data must be stored with Y axis inverted
  28689. * @param compression defines the used compression (can be null)
  28690. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28691. */
  28692. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28693. /**
  28694. * Creates a new raw 3D texture
  28695. * @param data defines the data used to create the texture
  28696. * @param width defines the width of the texture
  28697. * @param height defines the height of the texture
  28698. * @param depth defines the depth of the texture
  28699. * @param format defines the format of the texture
  28700. * @param generateMipMaps defines if the engine must generate mip levels
  28701. * @param invertY defines if data must be stored with Y axis inverted
  28702. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28703. * @param compression defines the compressed used (can be null)
  28704. * @param textureType defines the compressed used (can be null)
  28705. * @returns a new raw 3D texture (stored in an InternalTexture)
  28706. */
  28707. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28708. private _prepareWebGLTextureContinuation;
  28709. private _prepareWebGLTexture;
  28710. private _convertRGBtoRGBATextureData;
  28711. /** @hidden */
  28712. _releaseFramebufferObjects(texture: InternalTexture): void;
  28713. /** @hidden */
  28714. _releaseTexture(texture: InternalTexture): void;
  28715. private setProgram;
  28716. private _boundUniforms;
  28717. /**
  28718. * Binds an effect to the webGL context
  28719. * @param effect defines the effect to bind
  28720. */
  28721. bindSamplers(effect: Effect): void;
  28722. private _moveBoundTextureOnTop;
  28723. private _getCorrectTextureChannel;
  28724. private _linkTrackers;
  28725. private _removeDesignatedSlot;
  28726. private _activateCurrentTexture;
  28727. /** @hidden */
  28728. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28729. /** @hidden */
  28730. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28731. /**
  28732. * Sets a texture to the webGL context from a postprocess
  28733. * @param channel defines the channel to use
  28734. * @param postProcess defines the source postprocess
  28735. */
  28736. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28737. /**
  28738. * Binds the output of the passed in post process to the texture channel specified
  28739. * @param channel The channel the texture should be bound to
  28740. * @param postProcess The post process which's output should be bound
  28741. */
  28742. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28743. /**
  28744. * Unbind all textures from the webGL context
  28745. */
  28746. unbindAllTextures(): void;
  28747. /**
  28748. * Sets a texture to the according uniform.
  28749. * @param channel The texture channel
  28750. * @param uniform The uniform to set
  28751. * @param texture The texture to apply
  28752. */
  28753. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28754. /**
  28755. * Sets a depth stencil texture from a render target to the according uniform.
  28756. * @param channel The texture channel
  28757. * @param uniform The uniform to set
  28758. * @param texture The render target texture containing the depth stencil texture to apply
  28759. */
  28760. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28761. private _bindSamplerUniformToChannel;
  28762. private _getTextureWrapMode;
  28763. private _setTexture;
  28764. /**
  28765. * Sets an array of texture to the webGL context
  28766. * @param channel defines the channel where the texture array must be set
  28767. * @param uniform defines the associated uniform location
  28768. * @param textures defines the array of textures to bind
  28769. */
  28770. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28771. /** @hidden */
  28772. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28773. private _setTextureParameterFloat;
  28774. private _setTextureParameterInteger;
  28775. /**
  28776. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28777. * @param x defines the x coordinate of the rectangle where pixels must be read
  28778. * @param y defines the y coordinate of the rectangle where pixels must be read
  28779. * @param width defines the width of the rectangle where pixels must be read
  28780. * @param height defines the height of the rectangle where pixels must be read
  28781. * @returns a Uint8Array containing RGBA colors
  28782. */
  28783. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28784. /**
  28785. * Add an externaly attached data from its key.
  28786. * This method call will fail and return false, if such key already exists.
  28787. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28788. * @param key the unique key that identifies the data
  28789. * @param data the data object to associate to the key for this Engine instance
  28790. * @return true if no such key were already present and the data was added successfully, false otherwise
  28791. */
  28792. addExternalData<T>(key: string, data: T): boolean;
  28793. /**
  28794. * Get an externaly attached data from its key
  28795. * @param key the unique key that identifies the data
  28796. * @return the associated data, if present (can be null), or undefined if not present
  28797. */
  28798. getExternalData<T>(key: string): T;
  28799. /**
  28800. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28801. * @param key the unique key that identifies the data
  28802. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28803. * @return the associated data, can be null if the factory returned null.
  28804. */
  28805. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28806. /**
  28807. * Remove an externaly attached data from the Engine instance
  28808. * @param key the unique key that identifies the data
  28809. * @return true if the data was successfully removed, false if it doesn't exist
  28810. */
  28811. removeExternalData(key: string): boolean;
  28812. /**
  28813. * Unbind all vertex attributes from the webGL context
  28814. */
  28815. unbindAllAttributes(): void;
  28816. /**
  28817. * 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
  28818. */
  28819. releaseEffects(): void;
  28820. /**
  28821. * Dispose and release all associated resources
  28822. */
  28823. dispose(): void;
  28824. /**
  28825. * Display the loading screen
  28826. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28827. */
  28828. displayLoadingUI(): void;
  28829. /**
  28830. * Hide the loading screen
  28831. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28832. */
  28833. hideLoadingUI(): void;
  28834. /**
  28835. * Gets the current loading screen object
  28836. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28837. */
  28838. /**
  28839. * Sets the current loading screen object
  28840. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28841. */
  28842. loadingScreen: ILoadingScreen;
  28843. /**
  28844. * Sets the current loading screen text
  28845. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28846. */
  28847. loadingUIText: string;
  28848. /**
  28849. * Sets the current loading screen background color
  28850. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28851. */
  28852. loadingUIBackgroundColor: string;
  28853. /**
  28854. * Attach a new callback raised when context lost event is fired
  28855. * @param callback defines the callback to call
  28856. */
  28857. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28858. /**
  28859. * Attach a new callback raised when context restored event is fired
  28860. * @param callback defines the callback to call
  28861. */
  28862. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28863. /**
  28864. * Gets the source code of the vertex shader associated with a specific webGL program
  28865. * @param program defines the program to use
  28866. * @returns a string containing the source code of the vertex shader associated with the program
  28867. */
  28868. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28869. /**
  28870. * Gets the source code of the fragment shader associated with a specific webGL program
  28871. * @param program defines the program to use
  28872. * @returns a string containing the source code of the fragment shader associated with the program
  28873. */
  28874. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28875. /**
  28876. * Get the current error code of the webGL context
  28877. * @returns the error code
  28878. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28879. */
  28880. getError(): number;
  28881. /**
  28882. * Gets the current framerate
  28883. * @returns a number representing the framerate
  28884. */
  28885. getFps(): number;
  28886. /**
  28887. * Gets the time spent between current and previous frame
  28888. * @returns a number representing the delta time in ms
  28889. */
  28890. getDeltaTime(): number;
  28891. private _measureFps;
  28892. /** @hidden */
  28893. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28894. private _canRenderToFloatFramebuffer;
  28895. private _canRenderToHalfFloatFramebuffer;
  28896. private _canRenderToFramebuffer;
  28897. /** @hidden */
  28898. _getWebGLTextureType(type: number): number;
  28899. private _getInternalFormat;
  28900. /** @hidden */
  28901. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28902. /** @hidden */
  28903. _getRGBAMultiSampleBufferFormat(type: number): number;
  28904. /** @hidden */
  28905. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  28906. /** @hidden */
  28907. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28908. private _partialLoadFile;
  28909. private _cascadeLoadFiles;
  28910. /**
  28911. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28912. * @returns true if the engine can be created
  28913. * @ignorenaming
  28914. */
  28915. static isSupported(): boolean;
  28916. }
  28917. }
  28918. declare module "babylonjs/Materials/effect" {
  28919. import { Observable } from "babylonjs/Misc/observable";
  28920. import { Nullable } from "babylonjs/types";
  28921. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  28922. import { Engine } from "babylonjs/Engines/engine";
  28923. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28924. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28925. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28926. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28928. /**
  28929. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28930. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28931. */
  28932. export class EffectFallbacks {
  28933. private _defines;
  28934. private _currentRank;
  28935. private _maxRank;
  28936. private _mesh;
  28937. /**
  28938. * Removes the fallback from the bound mesh.
  28939. */
  28940. unBindMesh(): void;
  28941. /**
  28942. * Adds a fallback on the specified property.
  28943. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28944. * @param define The name of the define in the shader
  28945. */
  28946. addFallback(rank: number, define: string): void;
  28947. /**
  28948. * Sets the mesh to use CPU skinning when needing to fallback.
  28949. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28950. * @param mesh The mesh to use the fallbacks.
  28951. */
  28952. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28953. /**
  28954. * Checks to see if more fallbacks are still availible.
  28955. */
  28956. readonly isMoreFallbacks: boolean;
  28957. /**
  28958. * Removes the defines that shoould be removed when falling back.
  28959. * @param currentDefines defines the current define statements for the shader.
  28960. * @param effect defines the current effect we try to compile
  28961. * @returns The resulting defines with defines of the current rank removed.
  28962. */
  28963. reduce(currentDefines: string, effect: Effect): string;
  28964. }
  28965. /**
  28966. * Options to be used when creating an effect.
  28967. */
  28968. export class EffectCreationOptions {
  28969. /**
  28970. * Atrributes that will be used in the shader.
  28971. */
  28972. attributes: string[];
  28973. /**
  28974. * Uniform varible names that will be set in the shader.
  28975. */
  28976. uniformsNames: string[];
  28977. /**
  28978. * Uniform buffer varible names that will be set in the shader.
  28979. */
  28980. uniformBuffersNames: string[];
  28981. /**
  28982. * Sampler texture variable names that will be set in the shader.
  28983. */
  28984. samplers: string[];
  28985. /**
  28986. * Define statements that will be set in the shader.
  28987. */
  28988. defines: any;
  28989. /**
  28990. * Possible fallbacks for this effect to improve performance when needed.
  28991. */
  28992. fallbacks: Nullable<EffectFallbacks>;
  28993. /**
  28994. * Callback that will be called when the shader is compiled.
  28995. */
  28996. onCompiled: Nullable<(effect: Effect) => void>;
  28997. /**
  28998. * Callback that will be called if an error occurs during shader compilation.
  28999. */
  29000. onError: Nullable<(effect: Effect, errors: string) => void>;
  29001. /**
  29002. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29003. */
  29004. indexParameters: any;
  29005. /**
  29006. * Max number of lights that can be used in the shader.
  29007. */
  29008. maxSimultaneousLights: number;
  29009. /**
  29010. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29011. */
  29012. transformFeedbackVaryings: Nullable<string[]>;
  29013. }
  29014. /**
  29015. * Effect containing vertex and fragment shader that can be executed on an object.
  29016. */
  29017. export class Effect {
  29018. /**
  29019. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29020. */
  29021. static ShadersRepository: string;
  29022. /**
  29023. * Name of the effect.
  29024. */
  29025. name: any;
  29026. /**
  29027. * String container all the define statements that should be set on the shader.
  29028. */
  29029. defines: string;
  29030. /**
  29031. * Callback that will be called when the shader is compiled.
  29032. */
  29033. onCompiled: Nullable<(effect: Effect) => void>;
  29034. /**
  29035. * Callback that will be called if an error occurs during shader compilation.
  29036. */
  29037. onError: Nullable<(effect: Effect, errors: string) => void>;
  29038. /**
  29039. * Callback that will be called when effect is bound.
  29040. */
  29041. onBind: Nullable<(effect: Effect) => void>;
  29042. /**
  29043. * Unique ID of the effect.
  29044. */
  29045. uniqueId: number;
  29046. /**
  29047. * Observable that will be called when the shader is compiled.
  29048. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29049. */
  29050. onCompileObservable: Observable<Effect>;
  29051. /**
  29052. * Observable that will be called if an error occurs during shader compilation.
  29053. */
  29054. onErrorObservable: Observable<Effect>;
  29055. /** @hidden */
  29056. _onBindObservable: Nullable<Observable<Effect>>;
  29057. /**
  29058. * Observable that will be called when effect is bound.
  29059. */
  29060. readonly onBindObservable: Observable<Effect>;
  29061. /** @hidden */
  29062. _bonesComputationForcedToCPU: boolean;
  29063. private static _uniqueIdSeed;
  29064. private _engine;
  29065. private _uniformBuffersNames;
  29066. private _uniformsNames;
  29067. private _samplers;
  29068. private _isReady;
  29069. private _compilationError;
  29070. private _attributesNames;
  29071. private _attributes;
  29072. private _uniforms;
  29073. /**
  29074. * Key for the effect.
  29075. * @hidden
  29076. */
  29077. _key: string;
  29078. private _indexParameters;
  29079. private _fallbacks;
  29080. private _vertexSourceCode;
  29081. private _fragmentSourceCode;
  29082. private _vertexSourceCodeOverride;
  29083. private _fragmentSourceCodeOverride;
  29084. private _transformFeedbackVaryings;
  29085. /**
  29086. * Compiled shader to webGL program.
  29087. * @hidden
  29088. */
  29089. _program: WebGLProgram;
  29090. private _valueCache;
  29091. private static _baseCache;
  29092. /**
  29093. * Instantiates an effect.
  29094. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29095. * @param baseName Name of the effect.
  29096. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29097. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29098. * @param samplers List of sampler variables that will be passed to the shader.
  29099. * @param engine Engine to be used to render the effect
  29100. * @param defines Define statements to be added to the shader.
  29101. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29102. * @param onCompiled Callback that will be called when the shader is compiled.
  29103. * @param onError Callback that will be called if an error occurs during shader compilation.
  29104. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29105. */
  29106. 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);
  29107. /**
  29108. * Unique key for this effect
  29109. */
  29110. readonly key: string;
  29111. /**
  29112. * If the effect has been compiled and prepared.
  29113. * @returns if the effect is compiled and prepared.
  29114. */
  29115. isReady(): boolean;
  29116. /**
  29117. * The engine the effect was initialized with.
  29118. * @returns the engine.
  29119. */
  29120. getEngine(): Engine;
  29121. /**
  29122. * The compiled webGL program for the effect
  29123. * @returns the webGL program.
  29124. */
  29125. getProgram(): WebGLProgram;
  29126. /**
  29127. * The set of names of attribute variables for the shader.
  29128. * @returns An array of attribute names.
  29129. */
  29130. getAttributesNames(): string[];
  29131. /**
  29132. * Returns the attribute at the given index.
  29133. * @param index The index of the attribute.
  29134. * @returns The location of the attribute.
  29135. */
  29136. getAttributeLocation(index: number): number;
  29137. /**
  29138. * Returns the attribute based on the name of the variable.
  29139. * @param name of the attribute to look up.
  29140. * @returns the attribute location.
  29141. */
  29142. getAttributeLocationByName(name: string): number;
  29143. /**
  29144. * The number of attributes.
  29145. * @returns the numnber of attributes.
  29146. */
  29147. getAttributesCount(): number;
  29148. /**
  29149. * Gets the index of a uniform variable.
  29150. * @param uniformName of the uniform to look up.
  29151. * @returns the index.
  29152. */
  29153. getUniformIndex(uniformName: string): number;
  29154. /**
  29155. * Returns the attribute based on the name of the variable.
  29156. * @param uniformName of the uniform to look up.
  29157. * @returns the location of the uniform.
  29158. */
  29159. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29160. /**
  29161. * Returns an array of sampler variable names
  29162. * @returns The array of sampler variable neames.
  29163. */
  29164. getSamplers(): string[];
  29165. /**
  29166. * The error from the last compilation.
  29167. * @returns the error string.
  29168. */
  29169. getCompilationError(): string;
  29170. /**
  29171. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29172. * @param func The callback to be used.
  29173. */
  29174. executeWhenCompiled(func: (effect: Effect) => void): void;
  29175. private _checkIsReady;
  29176. /** @hidden */
  29177. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29178. /** @hidden */
  29179. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29180. /** @hidden */
  29181. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29182. private _processShaderConversion;
  29183. private _processIncludes;
  29184. private _processPrecision;
  29185. /**
  29186. * Recompiles the webGL program
  29187. * @param vertexSourceCode The source code for the vertex shader.
  29188. * @param fragmentSourceCode The source code for the fragment shader.
  29189. * @param onCompiled Callback called when completed.
  29190. * @param onError Callback called on error.
  29191. * @hidden
  29192. */
  29193. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29194. /**
  29195. * Gets the uniform locations of the the specified variable names
  29196. * @param names THe names of the variables to lookup.
  29197. * @returns Array of locations in the same order as variable names.
  29198. */
  29199. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29200. /**
  29201. * Prepares the effect
  29202. * @hidden
  29203. */
  29204. _prepareEffect(): void;
  29205. /**
  29206. * Checks if the effect is supported. (Must be called after compilation)
  29207. */
  29208. readonly isSupported: boolean;
  29209. /**
  29210. * Binds a texture to the engine to be used as output of the shader.
  29211. * @param channel Name of the output variable.
  29212. * @param texture Texture to bind.
  29213. * @hidden
  29214. */
  29215. _bindTexture(channel: string, texture: InternalTexture): void;
  29216. /**
  29217. * Sets a texture on the engine to be used in the shader.
  29218. * @param channel Name of the sampler variable.
  29219. * @param texture Texture to set.
  29220. */
  29221. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29222. /**
  29223. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29224. * @param channel Name of the sampler variable.
  29225. * @param texture Texture to set.
  29226. */
  29227. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29228. /**
  29229. * Sets an array of textures on the engine to be used in the shader.
  29230. * @param channel Name of the variable.
  29231. * @param textures Textures to set.
  29232. */
  29233. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29234. /**
  29235. * 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)
  29236. * @param channel Name of the sampler variable.
  29237. * @param postProcess Post process to get the input texture from.
  29238. */
  29239. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29240. /**
  29241. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29242. * 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)
  29243. * @param channel Name of the sampler variable.
  29244. * @param postProcess Post process to get the output texture from.
  29245. */
  29246. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29247. /** @hidden */
  29248. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29249. /** @hidden */
  29250. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29251. /** @hidden */
  29252. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29253. /** @hidden */
  29254. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29255. /**
  29256. * Binds a buffer to a uniform.
  29257. * @param buffer Buffer to bind.
  29258. * @param name Name of the uniform variable to bind to.
  29259. */
  29260. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29261. /**
  29262. * Binds block to a uniform.
  29263. * @param blockName Name of the block to bind.
  29264. * @param index Index to bind.
  29265. */
  29266. bindUniformBlock(blockName: string, index: number): void;
  29267. /**
  29268. * Sets an interger value on a uniform variable.
  29269. * @param uniformName Name of the variable.
  29270. * @param value Value to be set.
  29271. * @returns this effect.
  29272. */
  29273. setInt(uniformName: string, value: number): Effect;
  29274. /**
  29275. * Sets an int array on a uniform variable.
  29276. * @param uniformName Name of the variable.
  29277. * @param array array to be set.
  29278. * @returns this effect.
  29279. */
  29280. setIntArray(uniformName: string, array: Int32Array): Effect;
  29281. /**
  29282. * 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)
  29283. * @param uniformName Name of the variable.
  29284. * @param array array to be set.
  29285. * @returns this effect.
  29286. */
  29287. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29288. /**
  29289. * 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)
  29290. * @param uniformName Name of the variable.
  29291. * @param array array to be set.
  29292. * @returns this effect.
  29293. */
  29294. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29295. /**
  29296. * 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)
  29297. * @param uniformName Name of the variable.
  29298. * @param array array to be set.
  29299. * @returns this effect.
  29300. */
  29301. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29302. /**
  29303. * Sets an float array on a uniform variable.
  29304. * @param uniformName Name of the variable.
  29305. * @param array array to be set.
  29306. * @returns this effect.
  29307. */
  29308. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29309. /**
  29310. * 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)
  29311. * @param uniformName Name of the variable.
  29312. * @param array array to be set.
  29313. * @returns this effect.
  29314. */
  29315. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29316. /**
  29317. * 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)
  29318. * @param uniformName Name of the variable.
  29319. * @param array array to be set.
  29320. * @returns this effect.
  29321. */
  29322. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29323. /**
  29324. * 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)
  29325. * @param uniformName Name of the variable.
  29326. * @param array array to be set.
  29327. * @returns this effect.
  29328. */
  29329. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29330. /**
  29331. * Sets an array on a uniform variable.
  29332. * @param uniformName Name of the variable.
  29333. * @param array array to be set.
  29334. * @returns this effect.
  29335. */
  29336. setArray(uniformName: string, array: number[]): Effect;
  29337. /**
  29338. * 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)
  29339. * @param uniformName Name of the variable.
  29340. * @param array array to be set.
  29341. * @returns this effect.
  29342. */
  29343. setArray2(uniformName: string, array: number[]): Effect;
  29344. /**
  29345. * 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)
  29346. * @param uniformName Name of the variable.
  29347. * @param array array to be set.
  29348. * @returns this effect.
  29349. */
  29350. setArray3(uniformName: string, array: number[]): Effect;
  29351. /**
  29352. * 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)
  29353. * @param uniformName Name of the variable.
  29354. * @param array array to be set.
  29355. * @returns this effect.
  29356. */
  29357. setArray4(uniformName: string, array: number[]): Effect;
  29358. /**
  29359. * Sets matrices on a uniform variable.
  29360. * @param uniformName Name of the variable.
  29361. * @param matrices matrices to be set.
  29362. * @returns this effect.
  29363. */
  29364. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29365. /**
  29366. * Sets matrix on a uniform variable.
  29367. * @param uniformName Name of the variable.
  29368. * @param matrix matrix to be set.
  29369. * @returns this effect.
  29370. */
  29371. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29372. /**
  29373. * 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)
  29374. * @param uniformName Name of the variable.
  29375. * @param matrix matrix to be set.
  29376. * @returns this effect.
  29377. */
  29378. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29379. /**
  29380. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29381. * @param uniformName Name of the variable.
  29382. * @param matrix matrix to be set.
  29383. * @returns this effect.
  29384. */
  29385. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29386. /**
  29387. * Sets a float on a uniform variable.
  29388. * @param uniformName Name of the variable.
  29389. * @param value value to be set.
  29390. * @returns this effect.
  29391. */
  29392. setFloat(uniformName: string, value: number): Effect;
  29393. /**
  29394. * Sets a boolean on a uniform variable.
  29395. * @param uniformName Name of the variable.
  29396. * @param bool value to be set.
  29397. * @returns this effect.
  29398. */
  29399. setBool(uniformName: string, bool: boolean): Effect;
  29400. /**
  29401. * Sets a Vector2 on a uniform variable.
  29402. * @param uniformName Name of the variable.
  29403. * @param vector2 vector2 to be set.
  29404. * @returns this effect.
  29405. */
  29406. setVector2(uniformName: string, vector2: Vector2): Effect;
  29407. /**
  29408. * Sets a float2 on a uniform variable.
  29409. * @param uniformName Name of the variable.
  29410. * @param x First float in float2.
  29411. * @param y Second float in float2.
  29412. * @returns this effect.
  29413. */
  29414. setFloat2(uniformName: string, x: number, y: number): Effect;
  29415. /**
  29416. * Sets a Vector3 on a uniform variable.
  29417. * @param uniformName Name of the variable.
  29418. * @param vector3 Value to be set.
  29419. * @returns this effect.
  29420. */
  29421. setVector3(uniformName: string, vector3: Vector3): Effect;
  29422. /**
  29423. * Sets a float3 on a uniform variable.
  29424. * @param uniformName Name of the variable.
  29425. * @param x First float in float3.
  29426. * @param y Second float in float3.
  29427. * @param z Third float in float3.
  29428. * @returns this effect.
  29429. */
  29430. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29431. /**
  29432. * Sets a Vector4 on a uniform variable.
  29433. * @param uniformName Name of the variable.
  29434. * @param vector4 Value to be set.
  29435. * @returns this effect.
  29436. */
  29437. setVector4(uniformName: string, vector4: Vector4): Effect;
  29438. /**
  29439. * Sets a float4 on a uniform variable.
  29440. * @param uniformName Name of the variable.
  29441. * @param x First float in float4.
  29442. * @param y Second float in float4.
  29443. * @param z Third float in float4.
  29444. * @param w Fourth float in float4.
  29445. * @returns this effect.
  29446. */
  29447. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29448. /**
  29449. * Sets a Color3 on a uniform variable.
  29450. * @param uniformName Name of the variable.
  29451. * @param color3 Value to be set.
  29452. * @returns this effect.
  29453. */
  29454. setColor3(uniformName: string, color3: Color3): Effect;
  29455. /**
  29456. * Sets a Color4 on a uniform variable.
  29457. * @param uniformName Name of the variable.
  29458. * @param color3 Value to be set.
  29459. * @param alpha Alpha value to be set.
  29460. * @returns this effect.
  29461. */
  29462. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29463. /**
  29464. * Sets a Color4 on a uniform variable
  29465. * @param uniformName defines the name of the variable
  29466. * @param color4 defines the value to be set
  29467. * @returns this effect.
  29468. */
  29469. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29470. /**
  29471. * This function will add a new shader to the shader store
  29472. * @param name the name of the shader
  29473. * @param pixelShader optional pixel shader content
  29474. * @param vertexShader optional vertex shader content
  29475. */
  29476. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29477. /**
  29478. * Store of each shader (The can be looked up using effect.key)
  29479. */
  29480. static ShadersStore: {
  29481. [key: string]: string;
  29482. };
  29483. /**
  29484. * Store of each included file for a shader (The can be looked up using effect.key)
  29485. */
  29486. static IncludesShadersStore: {
  29487. [key: string]: string;
  29488. };
  29489. /**
  29490. * Resets the cache of effects.
  29491. */
  29492. static ResetCache(): void;
  29493. }
  29494. }
  29495. declare module "babylonjs/Materials/colorCurves" {
  29496. import { Effect } from "babylonjs/Materials/effect";
  29497. /**
  29498. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29499. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29500. * 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;
  29501. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29502. */
  29503. export class ColorCurves {
  29504. private _dirty;
  29505. private _tempColor;
  29506. private _globalCurve;
  29507. private _highlightsCurve;
  29508. private _midtonesCurve;
  29509. private _shadowsCurve;
  29510. private _positiveCurve;
  29511. private _negativeCurve;
  29512. private _globalHue;
  29513. private _globalDensity;
  29514. private _globalSaturation;
  29515. private _globalExposure;
  29516. /**
  29517. * Gets the global Hue value.
  29518. * 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).
  29519. */
  29520. /**
  29521. * Sets the global Hue value.
  29522. * 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).
  29523. */
  29524. globalHue: number;
  29525. /**
  29526. * Gets the global Density value.
  29527. * 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.
  29528. * Values less than zero provide a filter of opposite hue.
  29529. */
  29530. /**
  29531. * Sets the global Density value.
  29532. * 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.
  29533. * Values less than zero provide a filter of opposite hue.
  29534. */
  29535. globalDensity: number;
  29536. /**
  29537. * Gets the global Saturation value.
  29538. * 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.
  29539. */
  29540. /**
  29541. * Sets the global Saturation value.
  29542. * 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.
  29543. */
  29544. globalSaturation: number;
  29545. /**
  29546. * Gets the global Exposure value.
  29547. * 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.
  29548. */
  29549. /**
  29550. * Sets the global Exposure value.
  29551. * 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.
  29552. */
  29553. globalExposure: number;
  29554. private _highlightsHue;
  29555. private _highlightsDensity;
  29556. private _highlightsSaturation;
  29557. private _highlightsExposure;
  29558. /**
  29559. * Gets the highlights Hue value.
  29560. * 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).
  29561. */
  29562. /**
  29563. * Sets the highlights Hue value.
  29564. * 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).
  29565. */
  29566. highlightsHue: number;
  29567. /**
  29568. * Gets the highlights Density value.
  29569. * 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.
  29570. * Values less than zero provide a filter of opposite hue.
  29571. */
  29572. /**
  29573. * Sets the highlights Density value.
  29574. * 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.
  29575. * Values less than zero provide a filter of opposite hue.
  29576. */
  29577. highlightsDensity: number;
  29578. /**
  29579. * Gets the highlights Saturation value.
  29580. * 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.
  29581. */
  29582. /**
  29583. * Sets the highlights Saturation value.
  29584. * 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.
  29585. */
  29586. highlightsSaturation: number;
  29587. /**
  29588. * Gets the highlights Exposure value.
  29589. * 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.
  29590. */
  29591. /**
  29592. * Sets the highlights Exposure value.
  29593. * 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.
  29594. */
  29595. highlightsExposure: number;
  29596. private _midtonesHue;
  29597. private _midtonesDensity;
  29598. private _midtonesSaturation;
  29599. private _midtonesExposure;
  29600. /**
  29601. * Gets the midtones Hue value.
  29602. * 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).
  29603. */
  29604. /**
  29605. * Sets the midtones Hue value.
  29606. * 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).
  29607. */
  29608. midtonesHue: number;
  29609. /**
  29610. * Gets the midtones Density value.
  29611. * 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.
  29612. * Values less than zero provide a filter of opposite hue.
  29613. */
  29614. /**
  29615. * Sets the midtones Density value.
  29616. * 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.
  29617. * Values less than zero provide a filter of opposite hue.
  29618. */
  29619. midtonesDensity: number;
  29620. /**
  29621. * Gets the midtones Saturation value.
  29622. * 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.
  29623. */
  29624. /**
  29625. * Sets the midtones Saturation value.
  29626. * 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.
  29627. */
  29628. midtonesSaturation: number;
  29629. /**
  29630. * Gets the midtones Exposure value.
  29631. * 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.
  29632. */
  29633. /**
  29634. * Sets the midtones Exposure value.
  29635. * 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.
  29636. */
  29637. midtonesExposure: number;
  29638. private _shadowsHue;
  29639. private _shadowsDensity;
  29640. private _shadowsSaturation;
  29641. private _shadowsExposure;
  29642. /**
  29643. * Gets the shadows Hue value.
  29644. * 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).
  29645. */
  29646. /**
  29647. * Sets the shadows Hue value.
  29648. * 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).
  29649. */
  29650. shadowsHue: number;
  29651. /**
  29652. * Gets the shadows Density value.
  29653. * 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.
  29654. * Values less than zero provide a filter of opposite hue.
  29655. */
  29656. /**
  29657. * Sets the shadows Density value.
  29658. * 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.
  29659. * Values less than zero provide a filter of opposite hue.
  29660. */
  29661. shadowsDensity: number;
  29662. /**
  29663. * Gets the shadows Saturation value.
  29664. * 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.
  29665. */
  29666. /**
  29667. * Sets the shadows Saturation value.
  29668. * 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.
  29669. */
  29670. shadowsSaturation: number;
  29671. /**
  29672. * Gets the shadows Exposure value.
  29673. * 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.
  29674. */
  29675. /**
  29676. * Sets the shadows Exposure value.
  29677. * 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.
  29678. */
  29679. shadowsExposure: number;
  29680. /**
  29681. * Returns the class name
  29682. * @returns The class name
  29683. */
  29684. getClassName(): string;
  29685. /**
  29686. * Binds the color curves to the shader.
  29687. * @param colorCurves The color curve to bind
  29688. * @param effect The effect to bind to
  29689. * @param positiveUniform The positive uniform shader parameter
  29690. * @param neutralUniform The neutral uniform shader parameter
  29691. * @param negativeUniform The negative uniform shader parameter
  29692. */
  29693. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29694. /**
  29695. * Prepare the list of uniforms associated with the ColorCurves effects.
  29696. * @param uniformsList The list of uniforms used in the effect
  29697. */
  29698. static PrepareUniforms(uniformsList: string[]): void;
  29699. /**
  29700. * Returns color grading data based on a hue, density, saturation and exposure value.
  29701. * @param filterHue The hue of the color filter.
  29702. * @param filterDensity The density of the color filter.
  29703. * @param saturation The saturation.
  29704. * @param exposure The exposure.
  29705. * @param result The result data container.
  29706. */
  29707. private getColorGradingDataToRef;
  29708. /**
  29709. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29710. * @param value The input slider value in range [-100,100].
  29711. * @returns Adjusted value.
  29712. */
  29713. private static applyColorGradingSliderNonlinear;
  29714. /**
  29715. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29716. * @param hue The hue (H) input.
  29717. * @param saturation The saturation (S) input.
  29718. * @param brightness The brightness (B) input.
  29719. * @result An RGBA color represented as Vector4.
  29720. */
  29721. private static fromHSBToRef;
  29722. /**
  29723. * Returns a value clamped between min and max
  29724. * @param value The value to clamp
  29725. * @param min The minimum of value
  29726. * @param max The maximum of value
  29727. * @returns The clamped value.
  29728. */
  29729. private static clamp;
  29730. /**
  29731. * Clones the current color curve instance.
  29732. * @return The cloned curves
  29733. */
  29734. clone(): ColorCurves;
  29735. /**
  29736. * Serializes the current color curve instance to a json representation.
  29737. * @return a JSON representation
  29738. */
  29739. serialize(): any;
  29740. /**
  29741. * Parses the color curve from a json representation.
  29742. * @param source the JSON source to parse
  29743. * @return The parsed curves
  29744. */
  29745. static Parse(source: any): ColorCurves;
  29746. }
  29747. }
  29748. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  29749. import { Observable } from "babylonjs/Misc/observable";
  29750. import { Nullable } from "babylonjs/types";
  29751. import { Color4 } from "babylonjs/Maths/math";
  29752. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29753. import { Effect } from "babylonjs/Materials/effect";
  29754. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29755. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  29756. /**
  29757. * Interface to follow in your material defines to integrate easily the
  29758. * Image proccessing functions.
  29759. * @hidden
  29760. */
  29761. export interface IImageProcessingConfigurationDefines {
  29762. IMAGEPROCESSING: boolean;
  29763. VIGNETTE: boolean;
  29764. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29765. VIGNETTEBLENDMODEOPAQUE: boolean;
  29766. TONEMAPPING: boolean;
  29767. TONEMAPPING_ACES: boolean;
  29768. CONTRAST: boolean;
  29769. EXPOSURE: boolean;
  29770. COLORCURVES: boolean;
  29771. COLORGRADING: boolean;
  29772. COLORGRADING3D: boolean;
  29773. SAMPLER3DGREENDEPTH: boolean;
  29774. SAMPLER3DBGRMAP: boolean;
  29775. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29776. }
  29777. /**
  29778. * @hidden
  29779. */
  29780. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29781. IMAGEPROCESSING: boolean;
  29782. VIGNETTE: boolean;
  29783. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29784. VIGNETTEBLENDMODEOPAQUE: boolean;
  29785. TONEMAPPING: boolean;
  29786. TONEMAPPING_ACES: boolean;
  29787. CONTRAST: boolean;
  29788. COLORCURVES: boolean;
  29789. COLORGRADING: boolean;
  29790. COLORGRADING3D: boolean;
  29791. SAMPLER3DGREENDEPTH: boolean;
  29792. SAMPLER3DBGRMAP: boolean;
  29793. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29794. EXPOSURE: boolean;
  29795. constructor();
  29796. }
  29797. /**
  29798. * This groups together the common properties used for image processing either in direct forward pass
  29799. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29800. * or not.
  29801. */
  29802. export class ImageProcessingConfiguration {
  29803. /**
  29804. * Default tone mapping applied in BabylonJS.
  29805. */
  29806. static readonly TONEMAPPING_STANDARD: number;
  29807. /**
  29808. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29809. * to other engines rendering to increase portability.
  29810. */
  29811. static readonly TONEMAPPING_ACES: number;
  29812. /**
  29813. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29814. */
  29815. colorCurves: Nullable<ColorCurves>;
  29816. private _colorCurvesEnabled;
  29817. /**
  29818. * Gets wether the color curves effect is enabled.
  29819. */
  29820. /**
  29821. * Sets wether the color curves effect is enabled.
  29822. */
  29823. colorCurvesEnabled: boolean;
  29824. private _colorGradingTexture;
  29825. /**
  29826. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29827. */
  29828. /**
  29829. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29830. */
  29831. colorGradingTexture: Nullable<BaseTexture>;
  29832. private _colorGradingEnabled;
  29833. /**
  29834. * Gets wether the color grading effect is enabled.
  29835. */
  29836. /**
  29837. * Sets wether the color grading effect is enabled.
  29838. */
  29839. colorGradingEnabled: boolean;
  29840. private _colorGradingWithGreenDepth;
  29841. /**
  29842. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29843. */
  29844. /**
  29845. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29846. */
  29847. colorGradingWithGreenDepth: boolean;
  29848. private _colorGradingBGR;
  29849. /**
  29850. * Gets wether the color grading texture contains BGR values.
  29851. */
  29852. /**
  29853. * Sets wether the color grading texture contains BGR values.
  29854. */
  29855. colorGradingBGR: boolean;
  29856. /** @hidden */
  29857. _exposure: number;
  29858. /**
  29859. * Gets the Exposure used in the effect.
  29860. */
  29861. /**
  29862. * Sets the Exposure used in the effect.
  29863. */
  29864. exposure: number;
  29865. private _toneMappingEnabled;
  29866. /**
  29867. * Gets wether the tone mapping effect is enabled.
  29868. */
  29869. /**
  29870. * Sets wether the tone mapping effect is enabled.
  29871. */
  29872. toneMappingEnabled: boolean;
  29873. private _toneMappingType;
  29874. /**
  29875. * Gets the type of tone mapping effect.
  29876. */
  29877. /**
  29878. * Sets the type of tone mapping effect used in BabylonJS.
  29879. */
  29880. toneMappingType: number;
  29881. protected _contrast: number;
  29882. /**
  29883. * Gets the contrast used in the effect.
  29884. */
  29885. /**
  29886. * Sets the contrast used in the effect.
  29887. */
  29888. contrast: number;
  29889. /**
  29890. * Vignette stretch size.
  29891. */
  29892. vignetteStretch: number;
  29893. /**
  29894. * Vignette centre X Offset.
  29895. */
  29896. vignetteCentreX: number;
  29897. /**
  29898. * Vignette centre Y Offset.
  29899. */
  29900. vignetteCentreY: number;
  29901. /**
  29902. * Vignette weight or intensity of the vignette effect.
  29903. */
  29904. vignetteWeight: number;
  29905. /**
  29906. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29907. * if vignetteEnabled is set to true.
  29908. */
  29909. vignetteColor: Color4;
  29910. /**
  29911. * Camera field of view used by the Vignette effect.
  29912. */
  29913. vignetteCameraFov: number;
  29914. private _vignetteBlendMode;
  29915. /**
  29916. * Gets the vignette blend mode allowing different kind of effect.
  29917. */
  29918. /**
  29919. * Sets the vignette blend mode allowing different kind of effect.
  29920. */
  29921. vignetteBlendMode: number;
  29922. private _vignetteEnabled;
  29923. /**
  29924. * Gets wether the vignette effect is enabled.
  29925. */
  29926. /**
  29927. * Sets wether the vignette effect is enabled.
  29928. */
  29929. vignetteEnabled: boolean;
  29930. private _applyByPostProcess;
  29931. /**
  29932. * Gets wether the image processing is applied through a post process or not.
  29933. */
  29934. /**
  29935. * Sets wether the image processing is applied through a post process or not.
  29936. */
  29937. applyByPostProcess: boolean;
  29938. private _isEnabled;
  29939. /**
  29940. * Gets wether the image processing is enabled or not.
  29941. */
  29942. /**
  29943. * Sets wether the image processing is enabled or not.
  29944. */
  29945. isEnabled: boolean;
  29946. /**
  29947. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29948. */
  29949. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29950. /**
  29951. * Method called each time the image processing information changes requires to recompile the effect.
  29952. */
  29953. protected _updateParameters(): void;
  29954. /**
  29955. * Gets the current class name.
  29956. * @return "ImageProcessingConfiguration"
  29957. */
  29958. getClassName(): string;
  29959. /**
  29960. * Prepare the list of uniforms associated with the Image Processing effects.
  29961. * @param uniforms The list of uniforms used in the effect
  29962. * @param defines the list of defines currently in use
  29963. */
  29964. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29965. /**
  29966. * Prepare the list of samplers associated with the Image Processing effects.
  29967. * @param samplersList The list of uniforms used in the effect
  29968. * @param defines the list of defines currently in use
  29969. */
  29970. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29971. /**
  29972. * Prepare the list of defines associated to the shader.
  29973. * @param defines the list of defines to complete
  29974. * @param forPostProcess Define if we are currently in post process mode or not
  29975. */
  29976. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29977. /**
  29978. * Returns true if all the image processing information are ready.
  29979. * @returns True if ready, otherwise, false
  29980. */
  29981. isReady(): boolean;
  29982. /**
  29983. * Binds the image processing to the shader.
  29984. * @param effect The effect to bind to
  29985. * @param aspectRatio Define the current aspect ratio of the effect
  29986. */
  29987. bind(effect: Effect, aspectRatio?: number): void;
  29988. /**
  29989. * Clones the current image processing instance.
  29990. * @return The cloned image processing
  29991. */
  29992. clone(): ImageProcessingConfiguration;
  29993. /**
  29994. * Serializes the current image processing instance to a json representation.
  29995. * @return a JSON representation
  29996. */
  29997. serialize(): any;
  29998. /**
  29999. * Parses the image processing from a json representation.
  30000. * @param source the JSON source to parse
  30001. * @return The parsed image processing
  30002. */
  30003. static Parse(source: any): ImageProcessingConfiguration;
  30004. private static _VIGNETTEMODE_MULTIPLY;
  30005. private static _VIGNETTEMODE_OPAQUE;
  30006. /**
  30007. * Used to apply the vignette as a mix with the pixel color.
  30008. */
  30009. static readonly VIGNETTEMODE_MULTIPLY: number;
  30010. /**
  30011. * Used to apply the vignette as a replacement of the pixel color.
  30012. */
  30013. static readonly VIGNETTEMODE_OPAQUE: number;
  30014. }
  30015. }
  30016. declare module "babylonjs/Materials/fresnelParameters" {
  30017. import { Color3 } from "babylonjs/Maths/math";
  30018. /**
  30019. * This represents all the required information to add a fresnel effect on a material:
  30020. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30021. */
  30022. export class FresnelParameters {
  30023. private _isEnabled;
  30024. /**
  30025. * Define if the fresnel effect is enable or not.
  30026. */
  30027. isEnabled: boolean;
  30028. /**
  30029. * Define the color used on edges (grazing angle)
  30030. */
  30031. leftColor: Color3;
  30032. /**
  30033. * Define the color used on center
  30034. */
  30035. rightColor: Color3;
  30036. /**
  30037. * Define bias applied to computed fresnel term
  30038. */
  30039. bias: number;
  30040. /**
  30041. * Defined the power exponent applied to fresnel term
  30042. */
  30043. power: number;
  30044. /**
  30045. * Clones the current fresnel and its valuues
  30046. * @returns a clone fresnel configuration
  30047. */
  30048. clone(): FresnelParameters;
  30049. /**
  30050. * Serializes the current fresnel parameters to a JSON representation.
  30051. * @return the JSON serialization
  30052. */
  30053. serialize(): any;
  30054. /**
  30055. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30056. * @param parsedFresnelParameters Define the JSON representation
  30057. * @returns the parsed parameters
  30058. */
  30059. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30060. }
  30061. }
  30062. declare module "babylonjs/Misc/decorators" {
  30063. import { Nullable } from "babylonjs/types";
  30064. import { Scene } from "babylonjs/scene";
  30065. import { IAnimatable } from "babylonjs/Misc/tools";
  30066. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30067. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30068. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30069. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30070. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30071. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30072. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30073. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30074. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30075. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30076. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30077. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30078. /**
  30079. * Decorator used to define property that can be serialized as reference to a camera
  30080. * @param sourceName defines the name of the property to decorate
  30081. */
  30082. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30083. /**
  30084. * Class used to help serialization objects
  30085. */
  30086. export class SerializationHelper {
  30087. /** hidden */
  30088. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30089. /** hidden */
  30090. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30091. /** hidden */
  30092. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30093. /** hidden */
  30094. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30095. /**
  30096. * Appends the serialized animations from the source animations
  30097. * @param source Source containing the animations
  30098. * @param destination Target to store the animations
  30099. */
  30100. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30101. /**
  30102. * Static function used to serialized a specific entity
  30103. * @param entity defines the entity to serialize
  30104. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30105. * @returns a JSON compatible object representing the serialization of the entity
  30106. */
  30107. static Serialize<T>(entity: T, serializationObject?: any): any;
  30108. /**
  30109. * Creates a new entity from a serialization data object
  30110. * @param creationFunction defines a function used to instanciated the new entity
  30111. * @param source defines the source serialization data
  30112. * @param scene defines the hosting scene
  30113. * @param rootUrl defines the root url for resources
  30114. * @returns a new entity
  30115. */
  30116. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30117. /**
  30118. * Clones an object
  30119. * @param creationFunction defines the function used to instanciate the new object
  30120. * @param source defines the source object
  30121. * @returns the cloned object
  30122. */
  30123. static Clone<T>(creationFunction: () => T, source: T): T;
  30124. /**
  30125. * Instanciates a new object based on a source one (some data will be shared between both object)
  30126. * @param creationFunction defines the function used to instanciate the new object
  30127. * @param source defines the source object
  30128. * @returns the new object
  30129. */
  30130. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30131. }
  30132. }
  30133. declare module "babylonjs/Cameras/camera" {
  30134. import { SmartArray } from "babylonjs/Misc/smartArray";
  30135. import { Observable } from "babylonjs/Misc/observable";
  30136. import { Nullable } from "babylonjs/types";
  30137. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30138. import { Scene } from "babylonjs/scene";
  30139. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30140. import { Node } from "babylonjs/node";
  30141. import { Mesh } from "babylonjs/Meshes/mesh";
  30142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30143. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30144. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30145. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30146. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30147. import { Ray } from "babylonjs/Culling/ray";
  30148. /**
  30149. * This is the base class of all the camera used in the application.
  30150. * @see http://doc.babylonjs.com/features/cameras
  30151. */
  30152. export class Camera extends Node {
  30153. /** @hidden */
  30154. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30155. /**
  30156. * This is the default projection mode used by the cameras.
  30157. * It helps recreating a feeling of perspective and better appreciate depth.
  30158. * This is the best way to simulate real life cameras.
  30159. */
  30160. static readonly PERSPECTIVE_CAMERA: number;
  30161. /**
  30162. * This helps creating camera with an orthographic mode.
  30163. * 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.
  30164. */
  30165. static readonly ORTHOGRAPHIC_CAMERA: number;
  30166. /**
  30167. * This is the default FOV mode for perspective cameras.
  30168. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30169. */
  30170. static readonly FOVMODE_VERTICAL_FIXED: number;
  30171. /**
  30172. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30173. */
  30174. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30175. /**
  30176. * This specifies ther is no need for a camera rig.
  30177. * Basically only one eye is rendered corresponding to the camera.
  30178. */
  30179. static readonly RIG_MODE_NONE: number;
  30180. /**
  30181. * Simulates a camera Rig with one blue eye and one red eye.
  30182. * This can be use with 3d blue and red glasses.
  30183. */
  30184. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30185. /**
  30186. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30187. */
  30188. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30189. /**
  30190. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30191. */
  30192. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30193. /**
  30194. * Defines that both eyes of the camera will be rendered over under each other.
  30195. */
  30196. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30197. /**
  30198. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30199. */
  30200. static readonly RIG_MODE_VR: number;
  30201. /**
  30202. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30203. */
  30204. static readonly RIG_MODE_WEBVR: number;
  30205. /**
  30206. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30207. */
  30208. static readonly RIG_MODE_CUSTOM: number;
  30209. /**
  30210. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30211. */
  30212. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30213. /**
  30214. * @hidden
  30215. * Might be removed once multiview will be a thing
  30216. */
  30217. static UseAlternateWebVRRendering: boolean;
  30218. /**
  30219. * Define the input manager associated with the camera.
  30220. */
  30221. inputs: CameraInputsManager<Camera>;
  30222. /** @hidden */
  30223. _position: Vector3;
  30224. /**
  30225. * Define the current local position of the camera in the scene
  30226. */
  30227. position: Vector3;
  30228. /**
  30229. * The vector the camera should consider as up.
  30230. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30231. */
  30232. upVector: Vector3;
  30233. /**
  30234. * Define the current limit on the left side for an orthographic camera
  30235. * In scene unit
  30236. */
  30237. orthoLeft: Nullable<number>;
  30238. /**
  30239. * Define the current limit on the right side for an orthographic camera
  30240. * In scene unit
  30241. */
  30242. orthoRight: Nullable<number>;
  30243. /**
  30244. * Define the current limit on the bottom side for an orthographic camera
  30245. * In scene unit
  30246. */
  30247. orthoBottom: Nullable<number>;
  30248. /**
  30249. * Define the current limit on the top side for an orthographic camera
  30250. * In scene unit
  30251. */
  30252. orthoTop: Nullable<number>;
  30253. /**
  30254. * Field Of View is set in Radians. (default is 0.8)
  30255. */
  30256. fov: number;
  30257. /**
  30258. * Define the minimum distance the camera can see from.
  30259. * This is important to note that the depth buffer are not infinite and the closer it starts
  30260. * the more your scene might encounter depth fighting issue.
  30261. */
  30262. minZ: number;
  30263. /**
  30264. * Define the maximum distance the camera can see to.
  30265. * This is important to note that the depth buffer are not infinite and the further it end
  30266. * the more your scene might encounter depth fighting issue.
  30267. */
  30268. maxZ: number;
  30269. /**
  30270. * Define the default inertia of the camera.
  30271. * This helps giving a smooth feeling to the camera movement.
  30272. */
  30273. inertia: number;
  30274. /**
  30275. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30276. */
  30277. mode: number;
  30278. /**
  30279. * Define wether the camera is intermediate.
  30280. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30281. */
  30282. isIntermediate: boolean;
  30283. /**
  30284. * Define the viewport of the camera.
  30285. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30286. */
  30287. viewport: Viewport;
  30288. /**
  30289. * Restricts the camera to viewing objects with the same layerMask.
  30290. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30291. */
  30292. layerMask: number;
  30293. /**
  30294. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30295. */
  30296. fovMode: number;
  30297. /**
  30298. * Rig mode of the camera.
  30299. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30300. * This is normally controlled byt the camera themselves as internal use.
  30301. */
  30302. cameraRigMode: number;
  30303. /**
  30304. * Defines the distance between both "eyes" in case of a RIG
  30305. */
  30306. interaxialDistance: number;
  30307. /**
  30308. * Defines if stereoscopic rendering is done side by side or over under.
  30309. */
  30310. isStereoscopicSideBySide: boolean;
  30311. /**
  30312. * 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
  30313. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30314. * else in the scene.
  30315. */
  30316. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30317. /**
  30318. * When set, the camera will render to this render target instead of the default canvas
  30319. */
  30320. outputRenderTarget: Nullable<RenderTargetTexture>;
  30321. /**
  30322. * Observable triggered when the camera view matrix has changed.
  30323. */
  30324. onViewMatrixChangedObservable: Observable<Camera>;
  30325. /**
  30326. * Observable triggered when the camera Projection matrix has changed.
  30327. */
  30328. onProjectionMatrixChangedObservable: Observable<Camera>;
  30329. /**
  30330. * Observable triggered when the inputs have been processed.
  30331. */
  30332. onAfterCheckInputsObservable: Observable<Camera>;
  30333. /**
  30334. * Observable triggered when reset has been called and applied to the camera.
  30335. */
  30336. onRestoreStateObservable: Observable<Camera>;
  30337. /** @hidden */
  30338. _cameraRigParams: any;
  30339. /** @hidden */
  30340. _rigCameras: Camera[];
  30341. /** @hidden */
  30342. _rigPostProcess: Nullable<PostProcess>;
  30343. protected _webvrViewMatrix: Matrix;
  30344. /** @hidden */
  30345. _skipRendering: boolean;
  30346. /** @hidden */
  30347. _alternateCamera: Camera;
  30348. /** @hidden */
  30349. _projectionMatrix: Matrix;
  30350. /** @hidden */
  30351. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30352. /** @hidden */
  30353. _activeMeshes: SmartArray<AbstractMesh>;
  30354. protected _globalPosition: Vector3;
  30355. /** hidden */
  30356. _computedViewMatrix: Matrix;
  30357. private _doNotComputeProjectionMatrix;
  30358. private _transformMatrix;
  30359. private _frustumPlanes;
  30360. private _refreshFrustumPlanes;
  30361. private _storedFov;
  30362. private _stateStored;
  30363. /**
  30364. * Instantiates a new camera object.
  30365. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30366. * @see http://doc.babylonjs.com/features/cameras
  30367. * @param name Defines the name of the camera in the scene
  30368. * @param position Defines the position of the camera
  30369. * @param scene Defines the scene the camera belongs too
  30370. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30371. */
  30372. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30373. /**
  30374. * Store current camera state (fov, position, etc..)
  30375. * @returns the camera
  30376. */
  30377. storeState(): Camera;
  30378. /**
  30379. * Restores the camera state values if it has been stored. You must call storeState() first
  30380. */
  30381. protected _restoreStateValues(): boolean;
  30382. /**
  30383. * Restored camera state. You must call storeState() first.
  30384. * @returns true if restored and false otherwise
  30385. */
  30386. restoreState(): boolean;
  30387. /**
  30388. * Gets the class name of the camera.
  30389. * @returns the class name
  30390. */
  30391. getClassName(): string;
  30392. /** @hidden */
  30393. readonly _isCamera: boolean;
  30394. /**
  30395. * Gets a string representation of the camera useful for debug purpose.
  30396. * @param fullDetails Defines that a more verboe level of logging is required
  30397. * @returns the string representation
  30398. */
  30399. toString(fullDetails?: boolean): string;
  30400. /**
  30401. * Gets the current world space position of the camera.
  30402. */
  30403. readonly globalPosition: Vector3;
  30404. /**
  30405. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30406. * @returns the active meshe list
  30407. */
  30408. getActiveMeshes(): SmartArray<AbstractMesh>;
  30409. /**
  30410. * Check wether a mesh is part of the current active mesh list of the camera
  30411. * @param mesh Defines the mesh to check
  30412. * @returns true if active, false otherwise
  30413. */
  30414. isActiveMesh(mesh: Mesh): boolean;
  30415. /**
  30416. * Is this camera ready to be used/rendered
  30417. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30418. * @return true if the camera is ready
  30419. */
  30420. isReady(completeCheck?: boolean): boolean;
  30421. /** @hidden */
  30422. _initCache(): void;
  30423. /** @hidden */
  30424. _updateCache(ignoreParentClass?: boolean): void;
  30425. /** @hidden */
  30426. _isSynchronized(): boolean;
  30427. /** @hidden */
  30428. _isSynchronizedViewMatrix(): boolean;
  30429. /** @hidden */
  30430. _isSynchronizedProjectionMatrix(): boolean;
  30431. /**
  30432. * Attach the input controls to a specific dom element to get the input from.
  30433. * @param element Defines the element the controls should be listened from
  30434. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30435. */
  30436. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30437. /**
  30438. * Detach the current controls from the specified dom element.
  30439. * @param element Defines the element to stop listening the inputs from
  30440. */
  30441. detachControl(element: HTMLElement): void;
  30442. /**
  30443. * Update the camera state according to the different inputs gathered during the frame.
  30444. */
  30445. update(): void;
  30446. /** @hidden */
  30447. _checkInputs(): void;
  30448. /** @hidden */
  30449. readonly rigCameras: Camera[];
  30450. /**
  30451. * Gets the post process used by the rig cameras
  30452. */
  30453. readonly rigPostProcess: Nullable<PostProcess>;
  30454. /**
  30455. * Internal, gets the first post proces.
  30456. * @returns the first post process to be run on this camera.
  30457. */
  30458. _getFirstPostProcess(): Nullable<PostProcess>;
  30459. private _cascadePostProcessesToRigCams;
  30460. /**
  30461. * Attach a post process to the camera.
  30462. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30463. * @param postProcess The post process to attach to the camera
  30464. * @param insertAt The position of the post process in case several of them are in use in the scene
  30465. * @returns the position the post process has been inserted at
  30466. */
  30467. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30468. /**
  30469. * Detach a post process to the camera.
  30470. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30471. * @param postProcess The post process to detach from the camera
  30472. */
  30473. detachPostProcess(postProcess: PostProcess): void;
  30474. /**
  30475. * Gets the current world matrix of the camera
  30476. */
  30477. getWorldMatrix(): Matrix;
  30478. /** @hidden */
  30479. _getViewMatrix(): Matrix;
  30480. /**
  30481. * Gets the current view matrix of the camera.
  30482. * @param force forces the camera to recompute the matrix without looking at the cached state
  30483. * @returns the view matrix
  30484. */
  30485. getViewMatrix(force?: boolean): Matrix;
  30486. /**
  30487. * Freeze the projection matrix.
  30488. * It will prevent the cache check of the camera projection compute and can speed up perf
  30489. * if no parameter of the camera are meant to change
  30490. * @param projection Defines manually a projection if necessary
  30491. */
  30492. freezeProjectionMatrix(projection?: Matrix): void;
  30493. /**
  30494. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30495. */
  30496. unfreezeProjectionMatrix(): void;
  30497. /**
  30498. * Gets the current projection matrix of the camera.
  30499. * @param force forces the camera to recompute the matrix without looking at the cached state
  30500. * @returns the projection matrix
  30501. */
  30502. getProjectionMatrix(force?: boolean): Matrix;
  30503. /**
  30504. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30505. * @returns a Matrix
  30506. */
  30507. getTransformationMatrix(): Matrix;
  30508. private _updateFrustumPlanes;
  30509. /**
  30510. * Checks if a cullable object (mesh...) is in the camera frustum
  30511. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30512. * @param target The object to check
  30513. * @returns true if the object is in frustum otherwise false
  30514. */
  30515. isInFrustum(target: ICullable): boolean;
  30516. /**
  30517. * Checks if a cullable object (mesh...) is in the camera frustum
  30518. * Unlike isInFrustum this cheks the full bounding box
  30519. * @param target The object to check
  30520. * @returns true if the object is in frustum otherwise false
  30521. */
  30522. isCompletelyInFrustum(target: ICullable): boolean;
  30523. /**
  30524. * Gets a ray in the forward direction from the camera.
  30525. * @param length Defines the length of the ray to create
  30526. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30527. * @param origin Defines the start point of the ray which defaults to the camera position
  30528. * @returns the forward ray
  30529. */
  30530. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30531. /**
  30532. * Releases resources associated with this node.
  30533. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30534. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30535. */
  30536. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30537. /** @hidden */
  30538. _isLeftCamera: boolean;
  30539. /**
  30540. * Gets the left camera of a rig setup in case of Rigged Camera
  30541. */
  30542. readonly isLeftCamera: boolean;
  30543. /** @hidden */
  30544. _isRightCamera: boolean;
  30545. /**
  30546. * Gets the right camera of a rig setup in case of Rigged Camera
  30547. */
  30548. readonly isRightCamera: boolean;
  30549. /**
  30550. * Gets the left camera of a rig setup in case of Rigged Camera
  30551. */
  30552. readonly leftCamera: Nullable<FreeCamera>;
  30553. /**
  30554. * Gets the right camera of a rig setup in case of Rigged Camera
  30555. */
  30556. readonly rightCamera: Nullable<FreeCamera>;
  30557. /**
  30558. * Gets the left camera target of a rig setup in case of Rigged Camera
  30559. * @returns the target position
  30560. */
  30561. getLeftTarget(): Nullable<Vector3>;
  30562. /**
  30563. * Gets the right camera target of a rig setup in case of Rigged Camera
  30564. * @returns the target position
  30565. */
  30566. getRightTarget(): Nullable<Vector3>;
  30567. /**
  30568. * @hidden
  30569. */
  30570. setCameraRigMode(mode: number, rigParams: any): void;
  30571. /** @hidden */
  30572. static _setStereoscopicRigMode(camera: Camera): void;
  30573. /** @hidden */
  30574. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30575. /** @hidden */
  30576. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30577. /** @hidden */
  30578. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30579. /** @hidden */
  30580. _getVRProjectionMatrix(): Matrix;
  30581. protected _updateCameraRotationMatrix(): void;
  30582. protected _updateWebVRCameraRotationMatrix(): void;
  30583. /**
  30584. * This function MUST be overwritten by the different WebVR cameras available.
  30585. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30586. * @hidden
  30587. */
  30588. _getWebVRProjectionMatrix(): Matrix;
  30589. /**
  30590. * This function MUST be overwritten by the different WebVR cameras available.
  30591. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30592. * @hidden
  30593. */
  30594. _getWebVRViewMatrix(): Matrix;
  30595. /** @hidden */
  30596. setCameraRigParameter(name: string, value: any): void;
  30597. /**
  30598. * needs to be overridden by children so sub has required properties to be copied
  30599. * @hidden
  30600. */
  30601. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30602. /**
  30603. * May need to be overridden by children
  30604. * @hidden
  30605. */
  30606. _updateRigCameras(): void;
  30607. /** @hidden */
  30608. _setupInputs(): void;
  30609. /**
  30610. * Serialiaze the camera setup to a json represention
  30611. * @returns the JSON representation
  30612. */
  30613. serialize(): any;
  30614. /**
  30615. * Clones the current camera.
  30616. * @param name The cloned camera name
  30617. * @returns the cloned camera
  30618. */
  30619. clone(name: string): Camera;
  30620. /**
  30621. * Gets the direction of the camera relative to a given local axis.
  30622. * @param localAxis Defines the reference axis to provide a relative direction.
  30623. * @return the direction
  30624. */
  30625. getDirection(localAxis: Vector3): Vector3;
  30626. /**
  30627. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30628. * @param localAxis Defines the reference axis to provide a relative direction.
  30629. * @param result Defines the vector to store the result in
  30630. */
  30631. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30632. /**
  30633. * Gets a camera constructor for a given camera type
  30634. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30635. * @param name The name of the camera the result will be able to instantiate
  30636. * @param scene The scene the result will construct the camera in
  30637. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30638. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30639. * @returns a factory method to construc the camera
  30640. */
  30641. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30642. /**
  30643. * Compute the world matrix of the camera.
  30644. * @returns the camera workd matrix
  30645. */
  30646. computeWorldMatrix(): Matrix;
  30647. /**
  30648. * Parse a JSON and creates the camera from the parsed information
  30649. * @param parsedCamera The JSON to parse
  30650. * @param scene The scene to instantiate the camera in
  30651. * @returns the newly constructed camera
  30652. */
  30653. static Parse(parsedCamera: any, scene: Scene): Camera;
  30654. }
  30655. }
  30656. declare module "babylonjs/Misc/tools" {
  30657. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  30658. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  30659. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30660. import { Observable } from "babylonjs/Misc/observable";
  30661. import { DomManagement } from "babylonjs/Misc/domManagement";
  30662. import { Camera } from "babylonjs/Cameras/camera";
  30663. import { Engine } from "babylonjs/Engines/engine";
  30664. import { Animation } from "babylonjs/Animations/animation";
  30665. /**
  30666. * Interface for any object that can request an animation frame
  30667. */
  30668. export interface ICustomAnimationFrameRequester {
  30669. /**
  30670. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30671. */
  30672. renderFunction?: Function;
  30673. /**
  30674. * Called to request the next frame to render to
  30675. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30676. */
  30677. requestAnimationFrame: Function;
  30678. /**
  30679. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30680. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30681. */
  30682. requestID?: number;
  30683. }
  30684. /**
  30685. * Interface containing an array of animations
  30686. */
  30687. export interface IAnimatable {
  30688. /**
  30689. * Array of animations
  30690. */
  30691. animations: Array<Animation>;
  30692. }
  30693. /** Interface used by value gradients (color, factor, ...) */
  30694. export interface IValueGradient {
  30695. /**
  30696. * Gets or sets the gradient value (between 0 and 1)
  30697. */
  30698. gradient: number;
  30699. }
  30700. /** Class used to store color4 gradient */
  30701. export class ColorGradient implements IValueGradient {
  30702. /**
  30703. * Gets or sets the gradient value (between 0 and 1)
  30704. */
  30705. gradient: number;
  30706. /**
  30707. * Gets or sets first associated color
  30708. */
  30709. color1: Color4;
  30710. /**
  30711. * Gets or sets second associated color
  30712. */
  30713. color2?: Color4;
  30714. /**
  30715. * Will get a color picked randomly between color1 and color2.
  30716. * If color2 is undefined then color1 will be used
  30717. * @param result defines the target Color4 to store the result in
  30718. */
  30719. getColorToRef(result: Color4): void;
  30720. }
  30721. /** Class used to store color 3 gradient */
  30722. export class Color3Gradient implements IValueGradient {
  30723. /**
  30724. * Gets or sets the gradient value (between 0 and 1)
  30725. */
  30726. gradient: number;
  30727. /**
  30728. * Gets or sets the associated color
  30729. */
  30730. color: Color3;
  30731. }
  30732. /** Class used to store factor gradient */
  30733. export class FactorGradient implements IValueGradient {
  30734. /**
  30735. * Gets or sets the gradient value (between 0 and 1)
  30736. */
  30737. gradient: number;
  30738. /**
  30739. * Gets or sets first associated factor
  30740. */
  30741. factor1: number;
  30742. /**
  30743. * Gets or sets second associated factor
  30744. */
  30745. factor2?: number;
  30746. /**
  30747. * Will get a number picked randomly between factor1 and factor2.
  30748. * If factor2 is undefined then factor1 will be used
  30749. * @returns the picked number
  30750. */
  30751. getFactor(): number;
  30752. }
  30753. /**
  30754. * @ignore
  30755. * Application error to support additional information when loading a file
  30756. */
  30757. export class LoadFileError extends Error {
  30758. /** defines the optional XHR request */
  30759. request?: XMLHttpRequest | undefined;
  30760. private static _setPrototypeOf;
  30761. /**
  30762. * Creates a new LoadFileError
  30763. * @param message defines the message of the error
  30764. * @param request defines the optional XHR request
  30765. */
  30766. constructor(message: string,
  30767. /** defines the optional XHR request */
  30768. request?: XMLHttpRequest | undefined);
  30769. }
  30770. /**
  30771. * Class used to define a retry strategy when error happens while loading assets
  30772. */
  30773. export class RetryStrategy {
  30774. /**
  30775. * Function used to defines an exponential back off strategy
  30776. * @param maxRetries defines the maximum number of retries (3 by default)
  30777. * @param baseInterval defines the interval between retries
  30778. * @returns the strategy function to use
  30779. */
  30780. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30781. }
  30782. /**
  30783. * File request interface
  30784. */
  30785. export interface IFileRequest {
  30786. /**
  30787. * Raised when the request is complete (success or error).
  30788. */
  30789. onCompleteObservable: Observable<IFileRequest>;
  30790. /**
  30791. * Aborts the request for a file.
  30792. */
  30793. abort: () => void;
  30794. }
  30795. /**
  30796. * Class containing a set of static utilities functions
  30797. */
  30798. export class Tools {
  30799. /**
  30800. * Gets or sets the base URL to use to load assets
  30801. */
  30802. static BaseUrl: string;
  30803. /**
  30804. * Enable/Disable Custom HTTP Request Headers globally.
  30805. * default = false
  30806. * @see CustomRequestHeaders
  30807. */
  30808. static UseCustomRequestHeaders: boolean;
  30809. /**
  30810. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30811. * i.e. when loading files, where the server/service expects an Authorization header.
  30812. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  30813. */
  30814. static CustomRequestHeaders: {
  30815. [key: string]: string;
  30816. };
  30817. /**
  30818. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30819. */
  30820. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30821. /**
  30822. * Default behaviour for cors in the application.
  30823. * It can be a string if the expected behavior is identical in the entire app.
  30824. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30825. */
  30826. static CorsBehavior: string | ((url: string | string[]) => string);
  30827. /**
  30828. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30829. * @ignorenaming
  30830. */
  30831. static UseFallbackTexture: boolean;
  30832. /**
  30833. * Use this object to register external classes like custom textures or material
  30834. * to allow the laoders to instantiate them
  30835. */
  30836. static RegisteredExternalClasses: {
  30837. [key: string]: Object;
  30838. };
  30839. /**
  30840. * Texture content used if a texture cannot loaded
  30841. * @ignorenaming
  30842. */
  30843. static fallbackTexture: string;
  30844. /**
  30845. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30846. * @param u defines the coordinate on X axis
  30847. * @param v defines the coordinate on Y axis
  30848. * @param width defines the width of the source data
  30849. * @param height defines the height of the source data
  30850. * @param pixels defines the source byte array
  30851. * @param color defines the output color
  30852. */
  30853. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30854. /**
  30855. * Interpolates between a and b via alpha
  30856. * @param a The lower value (returned when alpha = 0)
  30857. * @param b The upper value (returned when alpha = 1)
  30858. * @param alpha The interpolation-factor
  30859. * @return The mixed value
  30860. */
  30861. static Mix(a: number, b: number, alpha: number): number;
  30862. /**
  30863. * Tries to instantiate a new object from a given class name
  30864. * @param className defines the class name to instantiate
  30865. * @returns the new object or null if the system was not able to do the instantiation
  30866. */
  30867. static Instantiate(className: string): any;
  30868. /**
  30869. * Provides a slice function that will work even on IE
  30870. * @param data defines the array to slice
  30871. * @param start defines the start of the data (optional)
  30872. * @param end defines the end of the data (optional)
  30873. * @returns the new sliced array
  30874. */
  30875. static Slice<T>(data: T, start?: number, end?: number): T;
  30876. /**
  30877. * Polyfill for setImmediate
  30878. * @param action defines the action to execute after the current execution block
  30879. */
  30880. static SetImmediate(action: () => void): void;
  30881. /**
  30882. * Function indicating if a number is an exponent of 2
  30883. * @param value defines the value to test
  30884. * @returns true if the value is an exponent of 2
  30885. */
  30886. static IsExponentOfTwo(value: number): boolean;
  30887. private static _tmpFloatArray;
  30888. /**
  30889. * Returns the nearest 32-bit single precision float representation of a Number
  30890. * @param value A Number. If the parameter is of a different type, it will get converted
  30891. * to a number or to NaN if it cannot be converted
  30892. * @returns number
  30893. */
  30894. static FloatRound(value: number): number;
  30895. /**
  30896. * Find the next highest power of two.
  30897. * @param x Number to start search from.
  30898. * @return Next highest power of two.
  30899. */
  30900. static CeilingPOT(x: number): number;
  30901. /**
  30902. * Find the next lowest power of two.
  30903. * @param x Number to start search from.
  30904. * @return Next lowest power of two.
  30905. */
  30906. static FloorPOT(x: number): number;
  30907. /**
  30908. * Find the nearest power of two.
  30909. * @param x Number to start search from.
  30910. * @return Next nearest power of two.
  30911. */
  30912. static NearestPOT(x: number): number;
  30913. /**
  30914. * Get the closest exponent of two
  30915. * @param value defines the value to approximate
  30916. * @param max defines the maximum value to return
  30917. * @param mode defines how to define the closest value
  30918. * @returns closest exponent of two of the given value
  30919. */
  30920. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30921. /**
  30922. * Extracts the filename from a path
  30923. * @param path defines the path to use
  30924. * @returns the filename
  30925. */
  30926. static GetFilename(path: string): string;
  30927. /**
  30928. * Extracts the "folder" part of a path (everything before the filename).
  30929. * @param uri The URI to extract the info from
  30930. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30931. * @returns The "folder" part of the path
  30932. */
  30933. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30934. /**
  30935. * Extracts text content from a DOM element hierarchy
  30936. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30937. */
  30938. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30939. /**
  30940. * Convert an angle in radians to degrees
  30941. * @param angle defines the angle to convert
  30942. * @returns the angle in degrees
  30943. */
  30944. static ToDegrees(angle: number): number;
  30945. /**
  30946. * Convert an angle in degrees to radians
  30947. * @param angle defines the angle to convert
  30948. * @returns the angle in radians
  30949. */
  30950. static ToRadians(angle: number): number;
  30951. /**
  30952. * Encode a buffer to a base64 string
  30953. * @param buffer defines the buffer to encode
  30954. * @returns the encoded string
  30955. */
  30956. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30957. /**
  30958. * Extracts minimum and maximum values from a list of indexed positions
  30959. * @param positions defines the positions to use
  30960. * @param indices defines the indices to the positions
  30961. * @param indexStart defines the start index
  30962. * @param indexCount defines the end index
  30963. * @param bias defines bias value to add to the result
  30964. * @return minimum and maximum values
  30965. */
  30966. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30967. minimum: Vector3;
  30968. maximum: Vector3;
  30969. };
  30970. /**
  30971. * Extracts minimum and maximum values from a list of positions
  30972. * @param positions defines the positions to use
  30973. * @param start defines the start index in the positions array
  30974. * @param count defines the number of positions to handle
  30975. * @param bias defines bias value to add to the result
  30976. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30977. * @return minimum and maximum values
  30978. */
  30979. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30980. minimum: Vector3;
  30981. maximum: Vector3;
  30982. };
  30983. /**
  30984. * Returns an array if obj is not an array
  30985. * @param obj defines the object to evaluate as an array
  30986. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30987. * @returns either obj directly if obj is an array or a new array containing obj
  30988. */
  30989. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30990. /**
  30991. * Gets the pointer prefix to use
  30992. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30993. */
  30994. static GetPointerPrefix(): string;
  30995. /**
  30996. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30997. * @param func - the function to be called
  30998. * @param requester - the object that will request the next frame. Falls back to window.
  30999. * @returns frame number
  31000. */
  31001. static QueueNewFrame(func: () => void, requester?: any): number;
  31002. /**
  31003. * Ask the browser to promote the current element to fullscreen rendering mode
  31004. * @param element defines the DOM element to promote
  31005. */
  31006. static RequestFullscreen(element: HTMLElement): void;
  31007. /**
  31008. * Asks the browser to exit fullscreen mode
  31009. */
  31010. static ExitFullscreen(): void;
  31011. /**
  31012. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31013. * @param url define the url we are trying
  31014. * @param element define the dom element where to configure the cors policy
  31015. */
  31016. static SetCorsBehavior(url: string | string[], element: {
  31017. crossOrigin: string | null;
  31018. }): void;
  31019. /**
  31020. * Removes unwanted characters from an url
  31021. * @param url defines the url to clean
  31022. * @returns the cleaned url
  31023. */
  31024. static CleanUrl(url: string): string;
  31025. /**
  31026. * Gets or sets a function used to pre-process url before using them to load assets
  31027. */
  31028. static PreprocessUrl: (url: string) => string;
  31029. /**
  31030. * Loads an image as an HTMLImageElement.
  31031. * @param input url string, ArrayBuffer, or Blob to load
  31032. * @param onLoad callback called when the image successfully loads
  31033. * @param onError callback called when the image fails to load
  31034. * @param offlineProvider offline provider for caching
  31035. * @returns the HTMLImageElement of the loaded image
  31036. */
  31037. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31038. /**
  31039. * Loads a file
  31040. * @param url url string, ArrayBuffer, or Blob to load
  31041. * @param onSuccess callback called when the file successfully loads
  31042. * @param onProgress callback called while file is loading (if the server supports this mode)
  31043. * @param offlineProvider defines the offline provider for caching
  31044. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31045. * @param onError callback called when the file fails to load
  31046. * @returns a file request object
  31047. */
  31048. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  31049. /**
  31050. * Load a script (identified by an url). When the url returns, the
  31051. * content of this file is added into a new script element, attached to the DOM (body element)
  31052. * @param scriptUrl defines the url of the script to laod
  31053. * @param onSuccess defines the callback called when the script is loaded
  31054. * @param onError defines the callback to call if an error occurs
  31055. */
  31056. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31057. /**
  31058. * Loads a file from a blob
  31059. * @param fileToLoad defines the blob to use
  31060. * @param callback defines the callback to call when data is loaded
  31061. * @param progressCallback defines the callback to call during loading process
  31062. * @returns a file request object
  31063. */
  31064. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31065. /**
  31066. * Loads a file
  31067. * @param fileToLoad defines the file to load
  31068. * @param callback defines the callback to call when data is loaded
  31069. * @param progressCallBack defines the callback to call during loading process
  31070. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31071. * @returns a file request object
  31072. */
  31073. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31074. /**
  31075. * Creates a data url from a given string content
  31076. * @param content defines the content to convert
  31077. * @returns the new data url link
  31078. */
  31079. static FileAsURL(content: string): string;
  31080. /**
  31081. * Format the given number to a specific decimal format
  31082. * @param value defines the number to format
  31083. * @param decimals defines the number of decimals to use
  31084. * @returns the formatted string
  31085. */
  31086. static Format(value: number, decimals?: number): string;
  31087. /**
  31088. * Checks if a given vector is inside a specific range
  31089. * @param v defines the vector to test
  31090. * @param min defines the minimum range
  31091. * @param max defines the maximum range
  31092. */
  31093. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31094. /**
  31095. * Tries to copy an object by duplicating every property
  31096. * @param source defines the source object
  31097. * @param destination defines the target object
  31098. * @param doNotCopyList defines a list of properties to avoid
  31099. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31100. */
  31101. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31102. /**
  31103. * Gets a boolean indicating if the given object has no own property
  31104. * @param obj defines the object to test
  31105. * @returns true if object has no own property
  31106. */
  31107. static IsEmpty(obj: any): boolean;
  31108. /**
  31109. * Function used to register events at window level
  31110. * @param events defines the events to register
  31111. */
  31112. static RegisterTopRootEvents(events: {
  31113. name: string;
  31114. handler: Nullable<(e: FocusEvent) => any>;
  31115. }[]): void;
  31116. /**
  31117. * Function used to unregister events from window level
  31118. * @param events defines the events to unregister
  31119. */
  31120. static UnregisterTopRootEvents(events: {
  31121. name: string;
  31122. handler: Nullable<(e: FocusEvent) => any>;
  31123. }[]): void;
  31124. /**
  31125. * @ignore
  31126. */
  31127. static _ScreenshotCanvas: HTMLCanvasElement;
  31128. /**
  31129. * Dumps the current bound framebuffer
  31130. * @param width defines the rendering width
  31131. * @param height defines the rendering height
  31132. * @param engine defines the hosting engine
  31133. * @param successCallback defines the callback triggered once the data are available
  31134. * @param mimeType defines the mime type of the result
  31135. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31136. */
  31137. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31138. /**
  31139. * Converts the canvas data to blob.
  31140. * This acts as a polyfill for browsers not supporting the to blob function.
  31141. * @param canvas Defines the canvas to extract the data from
  31142. * @param successCallback Defines the callback triggered once the data are available
  31143. * @param mimeType Defines the mime type of the result
  31144. */
  31145. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31146. /**
  31147. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31148. * @param successCallback defines the callback triggered once the data are available
  31149. * @param mimeType defines the mime type of the result
  31150. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31151. */
  31152. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31153. /**
  31154. * Downloads a blob in the browser
  31155. * @param blob defines the blob to download
  31156. * @param fileName defines the name of the downloaded file
  31157. */
  31158. static Download(blob: Blob, fileName: string): void;
  31159. /**
  31160. * Captures a screenshot of the current rendering
  31161. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31162. * @param engine defines the rendering engine
  31163. * @param camera defines the source camera
  31164. * @param size This parameter can be set to a single number or to an object with the
  31165. * following (optional) properties: precision, width, height. If a single number is passed,
  31166. * it will be used for both width and height. If an object is passed, the screenshot size
  31167. * will be derived from the parameters. The precision property is a multiplier allowing
  31168. * rendering at a higher or lower resolution
  31169. * @param successCallback defines the callback receives a single parameter which contains the
  31170. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31171. * src parameter of an <img> to display it
  31172. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31173. * Check your browser for supported MIME types
  31174. */
  31175. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31176. /**
  31177. * Generates an image screenshot from the specified camera.
  31178. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31179. * @param engine The engine to use for rendering
  31180. * @param camera The camera to use for rendering
  31181. * @param size This parameter can be set to a single number or to an object with the
  31182. * following (optional) properties: precision, width, height. If a single number is passed,
  31183. * it will be used for both width and height. If an object is passed, the screenshot size
  31184. * will be derived from the parameters. The precision property is a multiplier allowing
  31185. * rendering at a higher or lower resolution
  31186. * @param successCallback The callback receives a single parameter which contains the
  31187. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31188. * src parameter of an <img> to display it
  31189. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31190. * Check your browser for supported MIME types
  31191. * @param samples Texture samples (default: 1)
  31192. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31193. * @param fileName A name for for the downloaded file.
  31194. */
  31195. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31196. /**
  31197. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31198. * Be aware Math.random() could cause collisions, but:
  31199. * "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"
  31200. * @returns a pseudo random id
  31201. */
  31202. static RandomId(): string;
  31203. /**
  31204. * Test if the given uri is a base64 string
  31205. * @param uri The uri to test
  31206. * @return True if the uri is a base64 string or false otherwise
  31207. */
  31208. static IsBase64(uri: string): boolean;
  31209. /**
  31210. * Decode the given base64 uri.
  31211. * @param uri The uri to decode
  31212. * @return The decoded base64 data.
  31213. */
  31214. static DecodeBase64(uri: string): ArrayBuffer;
  31215. /**
  31216. * No log
  31217. */
  31218. static readonly NoneLogLevel: number;
  31219. /**
  31220. * Only message logs
  31221. */
  31222. static readonly MessageLogLevel: number;
  31223. /**
  31224. * Only warning logs
  31225. */
  31226. static readonly WarningLogLevel: number;
  31227. /**
  31228. * Only error logs
  31229. */
  31230. static readonly ErrorLogLevel: number;
  31231. /**
  31232. * All logs
  31233. */
  31234. static readonly AllLogLevel: number;
  31235. /**
  31236. * Gets a value indicating the number of loading errors
  31237. * @ignorenaming
  31238. */
  31239. static readonly errorsCount: number;
  31240. /**
  31241. * Callback called when a new log is added
  31242. */
  31243. static OnNewCacheEntry: (entry: string) => void;
  31244. /**
  31245. * Log a message to the console
  31246. * @param message defines the message to log
  31247. */
  31248. static Log(message: string): void;
  31249. /**
  31250. * Write a warning message to the console
  31251. * @param message defines the message to log
  31252. */
  31253. static Warn(message: string): void;
  31254. /**
  31255. * Write an error message to the console
  31256. * @param message defines the message to log
  31257. */
  31258. static Error(message: string): void;
  31259. /**
  31260. * Gets current log cache (list of logs)
  31261. */
  31262. static readonly LogCache: string;
  31263. /**
  31264. * Clears the log cache
  31265. */
  31266. static ClearLogCache(): void;
  31267. /**
  31268. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31269. */
  31270. static LogLevels: number;
  31271. /**
  31272. * Checks if the loaded document was accessed via `file:`-Protocol.
  31273. * @returns boolean
  31274. */
  31275. static IsFileURL(): boolean;
  31276. /**
  31277. * Checks if the window object exists
  31278. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31279. */
  31280. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31281. /**
  31282. * No performance log
  31283. */
  31284. static readonly PerformanceNoneLogLevel: number;
  31285. /**
  31286. * Use user marks to log performance
  31287. */
  31288. static readonly PerformanceUserMarkLogLevel: number;
  31289. /**
  31290. * Log performance to the console
  31291. */
  31292. static readonly PerformanceConsoleLogLevel: number;
  31293. private static _performance;
  31294. /**
  31295. * Sets the current performance log level
  31296. */
  31297. static PerformanceLogLevel: number;
  31298. private static _StartPerformanceCounterDisabled;
  31299. private static _EndPerformanceCounterDisabled;
  31300. private static _StartUserMark;
  31301. private static _EndUserMark;
  31302. private static _StartPerformanceConsole;
  31303. private static _EndPerformanceConsole;
  31304. /**
  31305. * Injects the @see CustomRequestHeaders into the given request
  31306. * @param request the request that should be used for injection
  31307. */
  31308. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  31309. /**
  31310. * Starts a performance counter
  31311. */
  31312. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31313. /**
  31314. * Ends a specific performance coutner
  31315. */
  31316. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31317. /**
  31318. * Gets either window.performance.now() if supported or Date.now() else
  31319. */
  31320. static readonly Now: number;
  31321. /**
  31322. * This method will return the name of the class used to create the instance of the given object.
  31323. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31324. * @param object the object to get the class name from
  31325. * @param isType defines if the object is actually a type
  31326. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31327. */
  31328. static GetClassName(object: any, isType?: boolean): string;
  31329. /**
  31330. * Gets the first element of an array satisfying a given predicate
  31331. * @param array defines the array to browse
  31332. * @param predicate defines the predicate to use
  31333. * @returns null if not found or the element
  31334. */
  31335. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31336. /**
  31337. * This method will return the name of the full name of the class, including its owning module (if any).
  31338. * 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).
  31339. * @param object the object to get the class name from
  31340. * @param isType defines if the object is actually a type
  31341. * @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.
  31342. * @ignorenaming
  31343. */
  31344. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31345. /**
  31346. * Returns a promise that resolves after the given amount of time.
  31347. * @param delay Number of milliseconds to delay
  31348. * @returns Promise that resolves after the given amount of time
  31349. */
  31350. static DelayAsync(delay: number): Promise<void>;
  31351. /**
  31352. * Gets the current gradient from an array of IValueGradient
  31353. * @param ratio defines the current ratio to get
  31354. * @param gradients defines the array of IValueGradient
  31355. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31356. */
  31357. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31358. }
  31359. /**
  31360. * This class is used to track a performance counter which is number based.
  31361. * The user has access to many properties which give statistics of different nature.
  31362. *
  31363. * The implementer can track two kinds of Performance Counter: time and count.
  31364. * 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.
  31365. * 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.
  31366. */
  31367. export class PerfCounter {
  31368. /**
  31369. * Gets or sets a global boolean to turn on and off all the counters
  31370. */
  31371. static Enabled: boolean;
  31372. /**
  31373. * Returns the smallest value ever
  31374. */
  31375. readonly min: number;
  31376. /**
  31377. * Returns the biggest value ever
  31378. */
  31379. readonly max: number;
  31380. /**
  31381. * Returns the average value since the performance counter is running
  31382. */
  31383. readonly average: number;
  31384. /**
  31385. * Returns the average value of the last second the counter was monitored
  31386. */
  31387. readonly lastSecAverage: number;
  31388. /**
  31389. * Returns the current value
  31390. */
  31391. readonly current: number;
  31392. /**
  31393. * Gets the accumulated total
  31394. */
  31395. readonly total: number;
  31396. /**
  31397. * Gets the total value count
  31398. */
  31399. readonly count: number;
  31400. /**
  31401. * Creates a new counter
  31402. */
  31403. constructor();
  31404. /**
  31405. * Call this method to start monitoring a new frame.
  31406. * 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.
  31407. */
  31408. fetchNewFrame(): void;
  31409. /**
  31410. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31411. * @param newCount the count value to add to the monitored count
  31412. * @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.
  31413. */
  31414. addCount(newCount: number, fetchResult: boolean): void;
  31415. /**
  31416. * Start monitoring this performance counter
  31417. */
  31418. beginMonitoring(): void;
  31419. /**
  31420. * Compute the time lapsed since the previous beginMonitoring() call.
  31421. * @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
  31422. */
  31423. endMonitoring(newFrame?: boolean): void;
  31424. private _fetchResult;
  31425. private _startMonitoringTime;
  31426. private _min;
  31427. private _max;
  31428. private _average;
  31429. private _current;
  31430. private _totalValueCount;
  31431. private _totalAccumulated;
  31432. private _lastSecAverage;
  31433. private _lastSecAccumulated;
  31434. private _lastSecTime;
  31435. private _lastSecValueCount;
  31436. }
  31437. /**
  31438. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31439. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31440. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31441. * @param name The name of the class, case should be preserved
  31442. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31443. */
  31444. export function className(name: string, module?: string): (target: Object) => void;
  31445. /**
  31446. * An implementation of a loop for asynchronous functions.
  31447. */
  31448. export class AsyncLoop {
  31449. /**
  31450. * Defines the number of iterations for the loop
  31451. */
  31452. iterations: number;
  31453. /**
  31454. * Defines the current index of the loop.
  31455. */
  31456. index: number;
  31457. private _done;
  31458. private _fn;
  31459. private _successCallback;
  31460. /**
  31461. * Constructor.
  31462. * @param iterations the number of iterations.
  31463. * @param func the function to run each iteration
  31464. * @param successCallback the callback that will be called upon succesful execution
  31465. * @param offset starting offset.
  31466. */
  31467. constructor(
  31468. /**
  31469. * Defines the number of iterations for the loop
  31470. */
  31471. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31472. /**
  31473. * Execute the next iteration. Must be called after the last iteration was finished.
  31474. */
  31475. executeNext(): void;
  31476. /**
  31477. * Break the loop and run the success callback.
  31478. */
  31479. breakLoop(): void;
  31480. /**
  31481. * Create and run an async loop.
  31482. * @param iterations the number of iterations.
  31483. * @param fn the function to run each iteration
  31484. * @param successCallback the callback that will be called upon succesful execution
  31485. * @param offset starting offset.
  31486. * @returns the created async loop object
  31487. */
  31488. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31489. /**
  31490. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31491. * @param iterations total number of iterations
  31492. * @param syncedIterations number of synchronous iterations in each async iteration.
  31493. * @param fn the function to call each iteration.
  31494. * @param callback a success call back that will be called when iterating stops.
  31495. * @param breakFunction a break condition (optional)
  31496. * @param timeout timeout settings for the setTimeout function. default - 0.
  31497. * @returns the created async loop object
  31498. */
  31499. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31500. }
  31501. }
  31502. declare module "babylonjs/Collisions/collisionCoordinator" {
  31503. import { Nullable } from "babylonjs/types";
  31504. import { Scene } from "babylonjs/scene";
  31505. import { Vector3 } from "babylonjs/Maths/math";
  31506. import { Collider } from "babylonjs/Collisions/collider";
  31507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31508. /** @hidden */
  31509. export interface ICollisionCoordinator {
  31510. createCollider(): Collider;
  31511. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31512. init(scene: Scene): void;
  31513. }
  31514. /** @hidden */
  31515. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31516. private _scene;
  31517. private _scaledPosition;
  31518. private _scaledVelocity;
  31519. private _finalPosition;
  31520. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31521. createCollider(): Collider;
  31522. init(scene: Scene): void;
  31523. private _collideWithWorld;
  31524. }
  31525. }
  31526. declare module "babylonjs/Animations/animationGroup" {
  31527. import { Animatable } from "babylonjs/Animations/animatable";
  31528. import { Animation } from "babylonjs/Animations/animation";
  31529. import { Scene, IDisposable } from "babylonjs/scene";
  31530. import { Observable } from "babylonjs/Misc/observable";
  31531. import { Nullable } from "babylonjs/types";
  31532. /**
  31533. * This class defines the direct association between an animation and a target
  31534. */
  31535. export class TargetedAnimation {
  31536. /**
  31537. * Animation to perform
  31538. */
  31539. animation: Animation;
  31540. /**
  31541. * Target to animate
  31542. */
  31543. target: any;
  31544. }
  31545. /**
  31546. * Use this class to create coordinated animations on multiple targets
  31547. */
  31548. export class AnimationGroup implements IDisposable {
  31549. /** The name of the animation group */
  31550. name: string;
  31551. private _scene;
  31552. private _targetedAnimations;
  31553. private _animatables;
  31554. private _from;
  31555. private _to;
  31556. private _isStarted;
  31557. private _isPaused;
  31558. private _speedRatio;
  31559. /**
  31560. * Gets or sets the unique id of the node
  31561. */
  31562. uniqueId: number;
  31563. /**
  31564. * This observable will notify when one animation have ended
  31565. */
  31566. onAnimationEndObservable: Observable<TargetedAnimation>;
  31567. /**
  31568. * Observer raised when one animation loops
  31569. */
  31570. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31571. /**
  31572. * This observable will notify when all animations have ended.
  31573. */
  31574. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31575. /**
  31576. * This observable will notify when all animations have paused.
  31577. */
  31578. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31579. /**
  31580. * This observable will notify when all animations are playing.
  31581. */
  31582. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31583. /**
  31584. * Gets the first frame
  31585. */
  31586. readonly from: number;
  31587. /**
  31588. * Gets the last frame
  31589. */
  31590. readonly to: number;
  31591. /**
  31592. * Define if the animations are started
  31593. */
  31594. readonly isStarted: boolean;
  31595. /**
  31596. * Gets a value indicating that the current group is playing
  31597. */
  31598. readonly isPlaying: boolean;
  31599. /**
  31600. * Gets or sets the speed ratio to use for all animations
  31601. */
  31602. /**
  31603. * Gets or sets the speed ratio to use for all animations
  31604. */
  31605. speedRatio: number;
  31606. /**
  31607. * Gets the targeted animations for this animation group
  31608. */
  31609. readonly targetedAnimations: Array<TargetedAnimation>;
  31610. /**
  31611. * returning the list of animatables controlled by this animation group.
  31612. */
  31613. readonly animatables: Array<Animatable>;
  31614. /**
  31615. * Instantiates a new Animation Group.
  31616. * This helps managing several animations at once.
  31617. * @see http://doc.babylonjs.com/how_to/group
  31618. * @param name Defines the name of the group
  31619. * @param scene Defines the scene the group belongs to
  31620. */
  31621. constructor(
  31622. /** The name of the animation group */
  31623. name: string, scene?: Nullable<Scene>);
  31624. /**
  31625. * Add an animation (with its target) in the group
  31626. * @param animation defines the animation we want to add
  31627. * @param target defines the target of the animation
  31628. * @returns the TargetedAnimation object
  31629. */
  31630. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31631. /**
  31632. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31633. * It can add constant keys at begin or end
  31634. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31635. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31636. * @returns the animation group
  31637. */
  31638. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31639. /**
  31640. * Start all animations on given targets
  31641. * @param loop defines if animations must loop
  31642. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31643. * @param from defines the from key (optional)
  31644. * @param to defines the to key (optional)
  31645. * @returns the current animation group
  31646. */
  31647. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31648. /**
  31649. * Pause all animations
  31650. * @returns the animation group
  31651. */
  31652. pause(): AnimationGroup;
  31653. /**
  31654. * Play all animations to initial state
  31655. * This function will start() the animations if they were not started or will restart() them if they were paused
  31656. * @param loop defines if animations must loop
  31657. * @returns the animation group
  31658. */
  31659. play(loop?: boolean): AnimationGroup;
  31660. /**
  31661. * Reset all animations to initial state
  31662. * @returns the animation group
  31663. */
  31664. reset(): AnimationGroup;
  31665. /**
  31666. * Restart animations from key 0
  31667. * @returns the animation group
  31668. */
  31669. restart(): AnimationGroup;
  31670. /**
  31671. * Stop all animations
  31672. * @returns the animation group
  31673. */
  31674. stop(): AnimationGroup;
  31675. /**
  31676. * Set animation weight for all animatables
  31677. * @param weight defines the weight to use
  31678. * @return the animationGroup
  31679. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31680. */
  31681. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31682. /**
  31683. * Synchronize and normalize all animatables with a source animatable
  31684. * @param root defines the root animatable to synchronize with
  31685. * @return the animationGroup
  31686. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31687. */
  31688. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31689. /**
  31690. * Goes to a specific frame in this animation group
  31691. * @param frame the frame number to go to
  31692. * @return the animationGroup
  31693. */
  31694. goToFrame(frame: number): AnimationGroup;
  31695. /**
  31696. * Dispose all associated resources
  31697. */
  31698. dispose(): void;
  31699. private _checkAnimationGroupEnded;
  31700. /**
  31701. * Clone the current animation group and returns a copy
  31702. * @param newName defines the name of the new group
  31703. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31704. * @returns the new aniamtion group
  31705. */
  31706. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31707. /**
  31708. * Returns a new AnimationGroup object parsed from the source provided.
  31709. * @param parsedAnimationGroup defines the source
  31710. * @param scene defines the scene that will receive the animationGroup
  31711. * @returns a new AnimationGroup
  31712. */
  31713. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31714. /**
  31715. * Returns the string "AnimationGroup"
  31716. * @returns "AnimationGroup"
  31717. */
  31718. getClassName(): string;
  31719. /**
  31720. * Creates a detailled string about the object
  31721. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31722. * @returns a string representing the object
  31723. */
  31724. toString(fullDetails?: boolean): string;
  31725. }
  31726. }
  31727. declare module "babylonjs/scene" {
  31728. import { Nullable } from "babylonjs/types";
  31729. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  31730. import { Observable } from "babylonjs/Misc/observable";
  31731. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  31732. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  31733. import { Geometry } from "babylonjs/Meshes/geometry";
  31734. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31735. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31737. import { Mesh } from "babylonjs/Meshes/mesh";
  31738. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31739. import { Bone } from "babylonjs/Bones/bone";
  31740. import { Skeleton } from "babylonjs/Bones/skeleton";
  31741. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  31742. import { Camera } from "babylonjs/Cameras/camera";
  31743. import { AbstractScene } from "babylonjs/abstractScene";
  31744. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31745. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31746. import { Material } from "babylonjs/Materials/material";
  31747. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  31748. import { Effect } from "babylonjs/Materials/effect";
  31749. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31750. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31751. import { Light } from "babylonjs/Lights/light";
  31752. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31753. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  31754. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  31755. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  31756. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31757. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  31758. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31759. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  31760. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  31761. import { Engine } from "babylonjs/Engines/engine";
  31762. import { Node } from "babylonjs/node";
  31763. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31764. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31765. import { Ray } from "babylonjs/Culling/ray";
  31766. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31767. import { Animation } from "babylonjs/Animations/animation";
  31768. import { Animatable } from "babylonjs/Animations/animatable";
  31769. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  31770. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31771. import { Collider } from "babylonjs/Collisions/collider";
  31772. /**
  31773. * Define an interface for all classes that will hold resources
  31774. */
  31775. export interface IDisposable {
  31776. /**
  31777. * Releases all held resources
  31778. */
  31779. dispose(): void;
  31780. }
  31781. /** Interface defining initialization parameters for Scene class */
  31782. export interface SceneOptions {
  31783. /**
  31784. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31785. * It will improve performance when the number of geometries becomes important.
  31786. */
  31787. useGeometryUniqueIdsMap?: boolean;
  31788. /**
  31789. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31790. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31791. */
  31792. useMaterialMeshMap?: boolean;
  31793. /**
  31794. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31795. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31796. */
  31797. useClonedMeshhMap?: boolean;
  31798. }
  31799. /**
  31800. * Represents a scene to be rendered by the engine.
  31801. * @see http://doc.babylonjs.com/features/scene
  31802. */
  31803. export class Scene extends AbstractScene implements IAnimatable {
  31804. private static _uniqueIdCounter;
  31805. /** The fog is deactivated */
  31806. static readonly FOGMODE_NONE: number;
  31807. /** The fog density is following an exponential function */
  31808. static readonly FOGMODE_EXP: number;
  31809. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31810. static readonly FOGMODE_EXP2: number;
  31811. /** The fog density is following a linear function. */
  31812. static readonly FOGMODE_LINEAR: number;
  31813. /**
  31814. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31815. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31816. */
  31817. static MinDeltaTime: number;
  31818. /**
  31819. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31820. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31821. */
  31822. static MaxDeltaTime: number;
  31823. /**
  31824. * Factory used to create the default material.
  31825. * @param name The name of the material to create
  31826. * @param scene The scene to create the material for
  31827. * @returns The default material
  31828. */
  31829. static DefaultMaterialFactory(scene: Scene): Material;
  31830. /**
  31831. * Factory used to create the a collision coordinator.
  31832. * @returns The collision coordinator
  31833. */
  31834. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31835. /** @hidden */
  31836. readonly _isScene: boolean;
  31837. /**
  31838. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31839. */
  31840. autoClear: boolean;
  31841. /**
  31842. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31843. */
  31844. autoClearDepthAndStencil: boolean;
  31845. /**
  31846. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31847. */
  31848. clearColor: Color4;
  31849. /**
  31850. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31851. */
  31852. ambientColor: Color3;
  31853. /** @hidden */
  31854. _environmentBRDFTexture: BaseTexture;
  31855. /** @hidden */
  31856. protected _environmentTexture: Nullable<BaseTexture>;
  31857. /**
  31858. * Texture used in all pbr material as the reflection texture.
  31859. * As in the majority of the scene they are the same (exception for multi room and so on),
  31860. * this is easier to reference from here than from all the materials.
  31861. */
  31862. /**
  31863. * Texture used in all pbr material as the reflection texture.
  31864. * As in the majority of the scene they are the same (exception for multi room and so on),
  31865. * this is easier to set here than in all the materials.
  31866. */
  31867. environmentTexture: Nullable<BaseTexture>;
  31868. /** @hidden */
  31869. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31870. /**
  31871. * Default image processing configuration used either in the rendering
  31872. * Forward main pass or through the imageProcessingPostProcess if present.
  31873. * As in the majority of the scene they are the same (exception for multi camera),
  31874. * this is easier to reference from here than from all the materials and post process.
  31875. *
  31876. * No setter as we it is a shared configuration, you can set the values instead.
  31877. */
  31878. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31879. private _forceWireframe;
  31880. /**
  31881. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31882. */
  31883. forceWireframe: boolean;
  31884. private _forcePointsCloud;
  31885. /**
  31886. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31887. */
  31888. forcePointsCloud: boolean;
  31889. /**
  31890. * Gets or sets the active clipplane 1
  31891. */
  31892. clipPlane: Nullable<Plane>;
  31893. /**
  31894. * Gets or sets the active clipplane 2
  31895. */
  31896. clipPlane2: Nullable<Plane>;
  31897. /**
  31898. * Gets or sets the active clipplane 3
  31899. */
  31900. clipPlane3: Nullable<Plane>;
  31901. /**
  31902. * Gets or sets the active clipplane 4
  31903. */
  31904. clipPlane4: Nullable<Plane>;
  31905. /**
  31906. * Gets or sets a boolean indicating if animations are enabled
  31907. */
  31908. animationsEnabled: boolean;
  31909. private _animationPropertiesOverride;
  31910. /**
  31911. * Gets or sets the animation properties override
  31912. */
  31913. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31914. /**
  31915. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31916. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31917. */
  31918. useConstantAnimationDeltaTime: boolean;
  31919. /**
  31920. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31921. * Please note that it requires to run a ray cast through the scene on every frame
  31922. */
  31923. constantlyUpdateMeshUnderPointer: boolean;
  31924. /**
  31925. * Defines the HTML cursor to use when hovering over interactive elements
  31926. */
  31927. hoverCursor: string;
  31928. /**
  31929. * Defines the HTML default cursor to use (empty by default)
  31930. */
  31931. defaultCursor: string;
  31932. /**
  31933. * This is used to call preventDefault() on pointer down
  31934. * in order to block unwanted artifacts like system double clicks
  31935. */
  31936. preventDefaultOnPointerDown: boolean;
  31937. /**
  31938. * This is used to call preventDefault() on pointer up
  31939. * in order to block unwanted artifacts like system double clicks
  31940. */
  31941. preventDefaultOnPointerUp: boolean;
  31942. /**
  31943. * Gets or sets user defined metadata
  31944. */
  31945. metadata: any;
  31946. /**
  31947. * For internal use only. Please do not use.
  31948. */
  31949. reservedDataStore: any;
  31950. /**
  31951. * Gets the name of the plugin used to load this scene (null by default)
  31952. */
  31953. loadingPluginName: string;
  31954. /**
  31955. * Use this array to add regular expressions used to disable offline support for specific urls
  31956. */
  31957. disableOfflineSupportExceptionRules: RegExp[];
  31958. /**
  31959. * An event triggered when the scene is disposed.
  31960. */
  31961. onDisposeObservable: Observable<Scene>;
  31962. private _onDisposeObserver;
  31963. /** Sets a function to be executed when this scene is disposed. */
  31964. onDispose: () => void;
  31965. /**
  31966. * An event triggered before rendering the scene (right after animations and physics)
  31967. */
  31968. onBeforeRenderObservable: Observable<Scene>;
  31969. private _onBeforeRenderObserver;
  31970. /** Sets a function to be executed before rendering this scene */
  31971. beforeRender: Nullable<() => void>;
  31972. /**
  31973. * An event triggered after rendering the scene
  31974. */
  31975. onAfterRenderObservable: Observable<Scene>;
  31976. private _onAfterRenderObserver;
  31977. /** Sets a function to be executed after rendering this scene */
  31978. afterRender: Nullable<() => void>;
  31979. /**
  31980. * An event triggered before animating the scene
  31981. */
  31982. onBeforeAnimationsObservable: Observable<Scene>;
  31983. /**
  31984. * An event triggered after animations processing
  31985. */
  31986. onAfterAnimationsObservable: Observable<Scene>;
  31987. /**
  31988. * An event triggered before draw calls are ready to be sent
  31989. */
  31990. onBeforeDrawPhaseObservable: Observable<Scene>;
  31991. /**
  31992. * An event triggered after draw calls have been sent
  31993. */
  31994. onAfterDrawPhaseObservable: Observable<Scene>;
  31995. /**
  31996. * An event triggered when the scene is ready
  31997. */
  31998. onReadyObservable: Observable<Scene>;
  31999. /**
  32000. * An event triggered before rendering a camera
  32001. */
  32002. onBeforeCameraRenderObservable: Observable<Camera>;
  32003. private _onBeforeCameraRenderObserver;
  32004. /** Sets a function to be executed before rendering a camera*/
  32005. beforeCameraRender: () => void;
  32006. /**
  32007. * An event triggered after rendering a camera
  32008. */
  32009. onAfterCameraRenderObservable: Observable<Camera>;
  32010. private _onAfterCameraRenderObserver;
  32011. /** Sets a function to be executed after rendering a camera*/
  32012. afterCameraRender: () => void;
  32013. /**
  32014. * An event triggered when active meshes evaluation is about to start
  32015. */
  32016. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32017. /**
  32018. * An event triggered when active meshes evaluation is done
  32019. */
  32020. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32021. /**
  32022. * An event triggered when particles rendering is about to start
  32023. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32024. */
  32025. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32026. /**
  32027. * An event triggered when particles rendering is done
  32028. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32029. */
  32030. onAfterParticlesRenderingObservable: Observable<Scene>;
  32031. /**
  32032. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32033. */
  32034. onDataLoadedObservable: Observable<Scene>;
  32035. /**
  32036. * An event triggered when a camera is created
  32037. */
  32038. onNewCameraAddedObservable: Observable<Camera>;
  32039. /**
  32040. * An event triggered when a camera is removed
  32041. */
  32042. onCameraRemovedObservable: Observable<Camera>;
  32043. /**
  32044. * An event triggered when a light is created
  32045. */
  32046. onNewLightAddedObservable: Observable<Light>;
  32047. /**
  32048. * An event triggered when a light is removed
  32049. */
  32050. onLightRemovedObservable: Observable<Light>;
  32051. /**
  32052. * An event triggered when a geometry is created
  32053. */
  32054. onNewGeometryAddedObservable: Observable<Geometry>;
  32055. /**
  32056. * An event triggered when a geometry is removed
  32057. */
  32058. onGeometryRemovedObservable: Observable<Geometry>;
  32059. /**
  32060. * An event triggered when a transform node is created
  32061. */
  32062. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32063. /**
  32064. * An event triggered when a transform node is removed
  32065. */
  32066. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32067. /**
  32068. * An event triggered when a mesh is created
  32069. */
  32070. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32071. /**
  32072. * An event triggered when a mesh is removed
  32073. */
  32074. onMeshRemovedObservable: Observable<AbstractMesh>;
  32075. /**
  32076. * An event triggered when a material is created
  32077. */
  32078. onNewMaterialAddedObservable: Observable<Material>;
  32079. /**
  32080. * An event triggered when a material is removed
  32081. */
  32082. onMaterialRemovedObservable: Observable<Material>;
  32083. /**
  32084. * An event triggered when a texture is created
  32085. */
  32086. onNewTextureAddedObservable: Observable<BaseTexture>;
  32087. /**
  32088. * An event triggered when a texture is removed
  32089. */
  32090. onTextureRemovedObservable: Observable<BaseTexture>;
  32091. /**
  32092. * An event triggered when render targets are about to be rendered
  32093. * Can happen multiple times per frame.
  32094. */
  32095. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32096. /**
  32097. * An event triggered when render targets were rendered.
  32098. * Can happen multiple times per frame.
  32099. */
  32100. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32101. /**
  32102. * An event triggered before calculating deterministic simulation step
  32103. */
  32104. onBeforeStepObservable: Observable<Scene>;
  32105. /**
  32106. * An event triggered after calculating deterministic simulation step
  32107. */
  32108. onAfterStepObservable: Observable<Scene>;
  32109. /**
  32110. * An event triggered when the activeCamera property is updated
  32111. */
  32112. onActiveCameraChanged: Observable<Scene>;
  32113. /**
  32114. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32115. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32116. * 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)
  32117. */
  32118. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32119. /**
  32120. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32121. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32122. * 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)
  32123. */
  32124. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32125. /**
  32126. * This Observable will when a mesh has been imported into the scene.
  32127. */
  32128. onMeshImportedObservable: Observable<AbstractMesh>;
  32129. /**
  32130. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32131. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32132. */
  32133. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32134. /** @hidden */
  32135. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32136. /**
  32137. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32138. */
  32139. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32140. /**
  32141. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32142. */
  32143. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32144. /**
  32145. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32146. */
  32147. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32148. private _onPointerMove;
  32149. private _onPointerDown;
  32150. private _onPointerUp;
  32151. /** Callback called when a pointer move is detected */
  32152. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32153. /** Callback called when a pointer down is detected */
  32154. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32155. /** Callback called when a pointer up is detected */
  32156. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32157. /** Callback called when a pointer pick is detected */
  32158. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32159. /**
  32160. * 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).
  32161. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32162. */
  32163. onPrePointerObservable: Observable<PointerInfoPre>;
  32164. /**
  32165. * Observable event triggered each time an input event is received from the rendering canvas
  32166. */
  32167. onPointerObservable: Observable<PointerInfo>;
  32168. /**
  32169. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32170. */
  32171. readonly unTranslatedPointer: Vector2;
  32172. /** The distance in pixel that you have to move to prevent some events */
  32173. static DragMovementThreshold: number;
  32174. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32175. static LongPressDelay: number;
  32176. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32177. static DoubleClickDelay: number;
  32178. /** If you need to check double click without raising a single click at first click, enable this flag */
  32179. static ExclusiveDoubleClickMode: boolean;
  32180. private _initClickEvent;
  32181. private _initActionManager;
  32182. private _delayedSimpleClick;
  32183. private _delayedSimpleClickTimeout;
  32184. private _previousDelayedSimpleClickTimeout;
  32185. private _meshPickProceed;
  32186. private _previousButtonPressed;
  32187. private _currentPickResult;
  32188. private _previousPickResult;
  32189. private _totalPointersPressed;
  32190. private _doubleClickOccured;
  32191. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32192. cameraToUseForPointers: Nullable<Camera>;
  32193. private _pointerX;
  32194. private _pointerY;
  32195. private _unTranslatedPointerX;
  32196. private _unTranslatedPointerY;
  32197. private _startingPointerPosition;
  32198. private _previousStartingPointerPosition;
  32199. private _startingPointerTime;
  32200. private _previousStartingPointerTime;
  32201. private _pointerCaptures;
  32202. private _timeAccumulator;
  32203. private _currentStepId;
  32204. private _currentInternalStep;
  32205. /** @hidden */
  32206. _mirroredCameraPosition: Nullable<Vector3>;
  32207. /**
  32208. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32209. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32210. */
  32211. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32212. /**
  32213. * Observable event triggered each time an keyboard event is received from the hosting window
  32214. */
  32215. onKeyboardObservable: Observable<KeyboardInfo>;
  32216. private _onKeyDown;
  32217. private _onKeyUp;
  32218. private _onCanvasFocusObserver;
  32219. private _onCanvasBlurObserver;
  32220. private _useRightHandedSystem;
  32221. /**
  32222. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32223. */
  32224. useRightHandedSystem: boolean;
  32225. /**
  32226. * Sets the step Id used by deterministic lock step
  32227. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32228. * @param newStepId defines the step Id
  32229. */
  32230. setStepId(newStepId: number): void;
  32231. /**
  32232. * Gets the step Id used by deterministic lock step
  32233. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32234. * @returns the step Id
  32235. */
  32236. getStepId(): number;
  32237. /**
  32238. * Gets the internal step used by deterministic lock step
  32239. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32240. * @returns the internal step
  32241. */
  32242. getInternalStep(): number;
  32243. private _fogEnabled;
  32244. /**
  32245. * Gets or sets a boolean indicating if fog is enabled on this scene
  32246. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32247. * (Default is true)
  32248. */
  32249. fogEnabled: boolean;
  32250. private _fogMode;
  32251. /**
  32252. * Gets or sets the fog mode to use
  32253. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32254. * | mode | value |
  32255. * | --- | --- |
  32256. * | FOGMODE_NONE | 0 |
  32257. * | FOGMODE_EXP | 1 |
  32258. * | FOGMODE_EXP2 | 2 |
  32259. * | FOGMODE_LINEAR | 3 |
  32260. */
  32261. fogMode: number;
  32262. /**
  32263. * Gets or sets the fog color to use
  32264. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32265. * (Default is Color3(0.2, 0.2, 0.3))
  32266. */
  32267. fogColor: Color3;
  32268. /**
  32269. * Gets or sets the fog density to use
  32270. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32271. * (Default is 0.1)
  32272. */
  32273. fogDensity: number;
  32274. /**
  32275. * Gets or sets the fog start distance to use
  32276. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32277. * (Default is 0)
  32278. */
  32279. fogStart: number;
  32280. /**
  32281. * Gets or sets the fog end distance to use
  32282. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32283. * (Default is 1000)
  32284. */
  32285. fogEnd: number;
  32286. private _shadowsEnabled;
  32287. /**
  32288. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32289. */
  32290. shadowsEnabled: boolean;
  32291. private _lightsEnabled;
  32292. /**
  32293. * Gets or sets a boolean indicating if lights are enabled on this scene
  32294. */
  32295. lightsEnabled: boolean;
  32296. /** All of the active cameras added to this scene. */
  32297. activeCameras: Camera[];
  32298. private _activeCamera;
  32299. /** Gets or sets the current active camera */
  32300. activeCamera: Nullable<Camera>;
  32301. private _defaultMaterial;
  32302. /** The default material used on meshes when no material is affected */
  32303. /** The default material used on meshes when no material is affected */
  32304. defaultMaterial: Material;
  32305. private _texturesEnabled;
  32306. /**
  32307. * Gets or sets a boolean indicating if textures are enabled on this scene
  32308. */
  32309. texturesEnabled: boolean;
  32310. /**
  32311. * Gets or sets a boolean indicating if particles are enabled on this scene
  32312. */
  32313. particlesEnabled: boolean;
  32314. /**
  32315. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32316. */
  32317. spritesEnabled: boolean;
  32318. private _skeletonsEnabled;
  32319. /**
  32320. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32321. */
  32322. skeletonsEnabled: boolean;
  32323. /**
  32324. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32325. */
  32326. lensFlaresEnabled: boolean;
  32327. /**
  32328. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32329. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32330. */
  32331. collisionsEnabled: boolean;
  32332. private _collisionCoordinator;
  32333. /** @hidden */
  32334. readonly collisionCoordinator: ICollisionCoordinator;
  32335. /**
  32336. * Defines the gravity applied to this scene (used only for collisions)
  32337. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32338. */
  32339. gravity: Vector3;
  32340. /**
  32341. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32342. */
  32343. postProcessesEnabled: boolean;
  32344. /**
  32345. * The list of postprocesses added to the scene
  32346. */
  32347. postProcesses: PostProcess[];
  32348. /**
  32349. * Gets the current postprocess manager
  32350. */
  32351. postProcessManager: PostProcessManager;
  32352. /**
  32353. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32354. */
  32355. renderTargetsEnabled: boolean;
  32356. /**
  32357. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32358. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32359. */
  32360. dumpNextRenderTargets: boolean;
  32361. /**
  32362. * The list of user defined render targets added to the scene
  32363. */
  32364. customRenderTargets: RenderTargetTexture[];
  32365. /**
  32366. * Defines if texture loading must be delayed
  32367. * If true, textures will only be loaded when they need to be rendered
  32368. */
  32369. useDelayedTextureLoading: boolean;
  32370. /**
  32371. * Gets the list of meshes imported to the scene through SceneLoader
  32372. */
  32373. importedMeshesFiles: String[];
  32374. /**
  32375. * Gets or sets a boolean indicating if probes are enabled on this scene
  32376. */
  32377. probesEnabled: boolean;
  32378. /**
  32379. * Gets or sets the current offline provider to use to store scene data
  32380. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32381. */
  32382. offlineProvider: IOfflineProvider;
  32383. /**
  32384. * Gets or sets the action manager associated with the scene
  32385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32386. */
  32387. actionManager: AbstractActionManager;
  32388. private _meshesForIntersections;
  32389. /**
  32390. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32391. */
  32392. proceduralTexturesEnabled: boolean;
  32393. private _engine;
  32394. private _totalVertices;
  32395. /** @hidden */
  32396. _activeIndices: PerfCounter;
  32397. /** @hidden */
  32398. _activeParticles: PerfCounter;
  32399. /** @hidden */
  32400. _activeBones: PerfCounter;
  32401. private _animationRatio;
  32402. /** @hidden */
  32403. _animationTimeLast: number;
  32404. /** @hidden */
  32405. _animationTime: number;
  32406. /**
  32407. * Gets or sets a general scale for animation speed
  32408. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32409. */
  32410. animationTimeScale: number;
  32411. /** @hidden */
  32412. _cachedMaterial: Nullable<Material>;
  32413. /** @hidden */
  32414. _cachedEffect: Nullable<Effect>;
  32415. /** @hidden */
  32416. _cachedVisibility: Nullable<number>;
  32417. private _renderId;
  32418. private _frameId;
  32419. private _executeWhenReadyTimeoutId;
  32420. private _intermediateRendering;
  32421. private _viewUpdateFlag;
  32422. private _projectionUpdateFlag;
  32423. private _alternateViewUpdateFlag;
  32424. private _alternateProjectionUpdateFlag;
  32425. /** @hidden */
  32426. _toBeDisposed: Nullable<IDisposable>[];
  32427. private _activeRequests;
  32428. /** @hidden */
  32429. _pendingData: any[];
  32430. private _isDisposed;
  32431. /**
  32432. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32433. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32434. */
  32435. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32436. private _activeMeshes;
  32437. private _processedMaterials;
  32438. private _renderTargets;
  32439. /** @hidden */
  32440. _activeParticleSystems: SmartArray<IParticleSystem>;
  32441. private _activeSkeletons;
  32442. private _softwareSkinnedMeshes;
  32443. private _renderingManager;
  32444. /** @hidden */
  32445. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32446. private _transformMatrix;
  32447. private _sceneUbo;
  32448. private _alternateSceneUbo;
  32449. private _viewMatrix;
  32450. private _projectionMatrix;
  32451. private _alternateViewMatrix;
  32452. private _alternateProjectionMatrix;
  32453. private _alternateTransformMatrix;
  32454. private _useAlternateCameraConfiguration;
  32455. private _alternateRendering;
  32456. private _wheelEventName;
  32457. /** @hidden */
  32458. _forcedViewPosition: Nullable<Vector3>;
  32459. /** @hidden */
  32460. readonly _isAlternateRenderingEnabled: boolean;
  32461. private _frustumPlanes;
  32462. /**
  32463. * Gets the list of frustum planes (built from the active camera)
  32464. */
  32465. readonly frustumPlanes: Plane[];
  32466. /**
  32467. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32468. * This is useful if there are more lights that the maximum simulteanous authorized
  32469. */
  32470. requireLightSorting: boolean;
  32471. /** @hidden */
  32472. readonly useMaterialMeshMap: boolean;
  32473. /** @hidden */
  32474. readonly useClonedMeshhMap: boolean;
  32475. private _pointerOverMesh;
  32476. private _pickedDownMesh;
  32477. private _pickedUpMesh;
  32478. private _externalData;
  32479. private _uid;
  32480. /**
  32481. * @hidden
  32482. * Backing store of defined scene components.
  32483. */
  32484. _components: ISceneComponent[];
  32485. /**
  32486. * @hidden
  32487. * Backing store of defined scene components.
  32488. */
  32489. _serializableComponents: ISceneSerializableComponent[];
  32490. /**
  32491. * List of components to register on the next registration step.
  32492. */
  32493. private _transientComponents;
  32494. /**
  32495. * Registers the transient components if needed.
  32496. */
  32497. private _registerTransientComponents;
  32498. /**
  32499. * @hidden
  32500. * Add a component to the scene.
  32501. * Note that the ccomponent could be registered on th next frame if this is called after
  32502. * the register component stage.
  32503. * @param component Defines the component to add to the scene
  32504. */
  32505. _addComponent(component: ISceneComponent): void;
  32506. /**
  32507. * @hidden
  32508. * Gets a component from the scene.
  32509. * @param name defines the name of the component to retrieve
  32510. * @returns the component or null if not present
  32511. */
  32512. _getComponent(name: string): Nullable<ISceneComponent>;
  32513. /**
  32514. * @hidden
  32515. * Defines the actions happening before camera updates.
  32516. */
  32517. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32518. /**
  32519. * @hidden
  32520. * Defines the actions happening before clear the canvas.
  32521. */
  32522. _beforeClearStage: Stage<SimpleStageAction>;
  32523. /**
  32524. * @hidden
  32525. * Defines the actions when collecting render targets for the frame.
  32526. */
  32527. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32528. /**
  32529. * @hidden
  32530. * Defines the actions happening for one camera in the frame.
  32531. */
  32532. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32533. /**
  32534. * @hidden
  32535. * Defines the actions happening during the per mesh ready checks.
  32536. */
  32537. _isReadyForMeshStage: Stage<MeshStageAction>;
  32538. /**
  32539. * @hidden
  32540. * Defines the actions happening before evaluate active mesh checks.
  32541. */
  32542. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32543. /**
  32544. * @hidden
  32545. * Defines the actions happening during the evaluate sub mesh checks.
  32546. */
  32547. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32548. /**
  32549. * @hidden
  32550. * Defines the actions happening during the active mesh stage.
  32551. */
  32552. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32553. /**
  32554. * @hidden
  32555. * Defines the actions happening during the per camera render target step.
  32556. */
  32557. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32558. /**
  32559. * @hidden
  32560. * Defines the actions happening just before the active camera is drawing.
  32561. */
  32562. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32563. /**
  32564. * @hidden
  32565. * Defines the actions happening just before a render target is drawing.
  32566. */
  32567. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32568. /**
  32569. * @hidden
  32570. * Defines the actions happening just before a rendering group is drawing.
  32571. */
  32572. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32573. /**
  32574. * @hidden
  32575. * Defines the actions happening just before a mesh is drawing.
  32576. */
  32577. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32578. /**
  32579. * @hidden
  32580. * Defines the actions happening just after a mesh has been drawn.
  32581. */
  32582. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32583. /**
  32584. * @hidden
  32585. * Defines the actions happening just after a rendering group has been drawn.
  32586. */
  32587. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32588. /**
  32589. * @hidden
  32590. * Defines the actions happening just after the active camera has been drawn.
  32591. */
  32592. _afterCameraDrawStage: Stage<CameraStageAction>;
  32593. /**
  32594. * @hidden
  32595. * Defines the actions happening just after a render target has been drawn.
  32596. */
  32597. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32598. /**
  32599. * @hidden
  32600. * Defines the actions happening just after rendering all cameras and computing intersections.
  32601. */
  32602. _afterRenderStage: Stage<SimpleStageAction>;
  32603. /**
  32604. * @hidden
  32605. * Defines the actions happening when a pointer move event happens.
  32606. */
  32607. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32608. /**
  32609. * @hidden
  32610. * Defines the actions happening when a pointer down event happens.
  32611. */
  32612. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32613. /**
  32614. * @hidden
  32615. * Defines the actions happening when a pointer up event happens.
  32616. */
  32617. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32618. /**
  32619. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32620. */
  32621. private geometriesByUniqueId;
  32622. /**
  32623. * Creates a new Scene
  32624. * @param engine defines the engine to use to render this scene
  32625. * @param options defines the scene options
  32626. */
  32627. constructor(engine: Engine, options?: SceneOptions);
  32628. private _defaultMeshCandidates;
  32629. /**
  32630. * @hidden
  32631. */
  32632. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32633. private _defaultSubMeshCandidates;
  32634. /**
  32635. * @hidden
  32636. */
  32637. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32638. /**
  32639. * Sets the default candidate providers for the scene.
  32640. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32641. * and getCollidingSubMeshCandidates to their default function
  32642. */
  32643. setDefaultCandidateProviders(): void;
  32644. /**
  32645. * Gets the mesh that is currently under the pointer
  32646. */
  32647. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32648. /**
  32649. * Gets or sets the current on-screen X position of the pointer
  32650. */
  32651. pointerX: number;
  32652. /**
  32653. * Gets or sets the current on-screen Y position of the pointer
  32654. */
  32655. pointerY: number;
  32656. /**
  32657. * Gets the cached material (ie. the latest rendered one)
  32658. * @returns the cached material
  32659. */
  32660. getCachedMaterial(): Nullable<Material>;
  32661. /**
  32662. * Gets the cached effect (ie. the latest rendered one)
  32663. * @returns the cached effect
  32664. */
  32665. getCachedEffect(): Nullable<Effect>;
  32666. /**
  32667. * Gets the cached visibility state (ie. the latest rendered one)
  32668. * @returns the cached visibility state
  32669. */
  32670. getCachedVisibility(): Nullable<number>;
  32671. /**
  32672. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32673. * @param material defines the current material
  32674. * @param effect defines the current effect
  32675. * @param visibility defines the current visibility state
  32676. * @returns true if one parameter is not cached
  32677. */
  32678. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32679. /**
  32680. * Gets the engine associated with the scene
  32681. * @returns an Engine
  32682. */
  32683. getEngine(): Engine;
  32684. /**
  32685. * Gets the total number of vertices rendered per frame
  32686. * @returns the total number of vertices rendered per frame
  32687. */
  32688. getTotalVertices(): number;
  32689. /**
  32690. * Gets the performance counter for total vertices
  32691. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32692. */
  32693. readonly totalVerticesPerfCounter: PerfCounter;
  32694. /**
  32695. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32696. * @returns the total number of active indices rendered per frame
  32697. */
  32698. getActiveIndices(): number;
  32699. /**
  32700. * Gets the performance counter for active indices
  32701. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32702. */
  32703. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32704. /**
  32705. * Gets the total number of active particles rendered per frame
  32706. * @returns the total number of active particles rendered per frame
  32707. */
  32708. getActiveParticles(): number;
  32709. /**
  32710. * Gets the performance counter for active particles
  32711. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32712. */
  32713. readonly activeParticlesPerfCounter: PerfCounter;
  32714. /**
  32715. * Gets the total number of active bones rendered per frame
  32716. * @returns the total number of active bones rendered per frame
  32717. */
  32718. getActiveBones(): number;
  32719. /**
  32720. * Gets the performance counter for active bones
  32721. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32722. */
  32723. readonly activeBonesPerfCounter: PerfCounter;
  32724. /**
  32725. * Gets the array of active meshes
  32726. * @returns an array of AbstractMesh
  32727. */
  32728. getActiveMeshes(): SmartArray<AbstractMesh>;
  32729. /**
  32730. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32731. * @returns a number
  32732. */
  32733. getAnimationRatio(): number;
  32734. /**
  32735. * Gets an unique Id for the current render phase
  32736. * @returns a number
  32737. */
  32738. getRenderId(): number;
  32739. /**
  32740. * Gets an unique Id for the current frame
  32741. * @returns a number
  32742. */
  32743. getFrameId(): number;
  32744. /** Call this function if you want to manually increment the render Id*/
  32745. incrementRenderId(): void;
  32746. private _updatePointerPosition;
  32747. private _createUbo;
  32748. private _createAlternateUbo;
  32749. private _setRayOnPointerInfo;
  32750. /**
  32751. * Use this method to simulate a pointer move on a mesh
  32752. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32753. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32754. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32755. * @returns the current scene
  32756. */
  32757. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32758. private _processPointerMove;
  32759. private _checkPrePointerObservable;
  32760. /**
  32761. * Use this method to simulate a pointer down on a mesh
  32762. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32763. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32764. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32765. * @returns the current scene
  32766. */
  32767. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32768. private _processPointerDown;
  32769. /**
  32770. * Use this method to simulate a pointer up on a mesh
  32771. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32772. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32773. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32774. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32775. * @returns the current scene
  32776. */
  32777. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32778. private _processPointerUp;
  32779. /**
  32780. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32781. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32782. * @returns true if the pointer was captured
  32783. */
  32784. isPointerCaptured(pointerId?: number): boolean;
  32785. /** @hidden */
  32786. _isPointerSwiping(): boolean;
  32787. /**
  32788. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32789. * @param attachUp defines if you want to attach events to pointerup
  32790. * @param attachDown defines if you want to attach events to pointerdown
  32791. * @param attachMove defines if you want to attach events to pointermove
  32792. */
  32793. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32794. /** Detaches all event handlers*/
  32795. detachControl(): void;
  32796. /**
  32797. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32798. * Delay loaded resources are not taking in account
  32799. * @return true if all required resources are ready
  32800. */
  32801. isReady(): boolean;
  32802. /** Resets all cached information relative to material (including effect and visibility) */
  32803. resetCachedMaterial(): void;
  32804. /**
  32805. * Registers a function to be called before every frame render
  32806. * @param func defines the function to register
  32807. */
  32808. registerBeforeRender(func: () => void): void;
  32809. /**
  32810. * Unregisters a function called before every frame render
  32811. * @param func defines the function to unregister
  32812. */
  32813. unregisterBeforeRender(func: () => void): void;
  32814. /**
  32815. * Registers a function to be called after every frame render
  32816. * @param func defines the function to register
  32817. */
  32818. registerAfterRender(func: () => void): void;
  32819. /**
  32820. * Unregisters a function called after every frame render
  32821. * @param func defines the function to unregister
  32822. */
  32823. unregisterAfterRender(func: () => void): void;
  32824. private _executeOnceBeforeRender;
  32825. /**
  32826. * The provided function will run before render once and will be disposed afterwards.
  32827. * A timeout delay can be provided so that the function will be executed in N ms.
  32828. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32829. * @param func The function to be executed.
  32830. * @param timeout optional delay in ms
  32831. */
  32832. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32833. /** @hidden */
  32834. _addPendingData(data: any): void;
  32835. /** @hidden */
  32836. _removePendingData(data: any): void;
  32837. /**
  32838. * Returns the number of items waiting to be loaded
  32839. * @returns the number of items waiting to be loaded
  32840. */
  32841. getWaitingItemsCount(): number;
  32842. /**
  32843. * Returns a boolean indicating if the scene is still loading data
  32844. */
  32845. readonly isLoading: boolean;
  32846. /**
  32847. * Registers a function to be executed when the scene is ready
  32848. * @param {Function} func - the function to be executed
  32849. */
  32850. executeWhenReady(func: () => void): void;
  32851. /**
  32852. * Returns a promise that resolves when the scene is ready
  32853. * @returns A promise that resolves when the scene is ready
  32854. */
  32855. whenReadyAsync(): Promise<void>;
  32856. /** @hidden */
  32857. _checkIsReady(): void;
  32858. /**
  32859. * Gets all animatable attached to the scene
  32860. */
  32861. readonly animatables: Animatable[];
  32862. /**
  32863. * Resets the last animation time frame.
  32864. * Useful to override when animations start running when loading a scene for the first time.
  32865. */
  32866. resetLastAnimationTimeFrame(): void;
  32867. /** @hidden */
  32868. _switchToAlternateCameraConfiguration(active: boolean): void;
  32869. /**
  32870. * Gets the current view matrix
  32871. * @returns a Matrix
  32872. */
  32873. getViewMatrix(): Matrix;
  32874. /**
  32875. * Gets the current projection matrix
  32876. * @returns a Matrix
  32877. */
  32878. getProjectionMatrix(): Matrix;
  32879. /**
  32880. * Gets the current transform matrix
  32881. * @returns a Matrix made of View * Projection
  32882. */
  32883. getTransformMatrix(): Matrix;
  32884. /**
  32885. * Sets the current transform matrix
  32886. * @param view defines the View matrix to use
  32887. * @param projection defines the Projection matrix to use
  32888. */
  32889. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32890. /** @hidden */
  32891. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32892. /**
  32893. * Gets the uniform buffer used to store scene data
  32894. * @returns a UniformBuffer
  32895. */
  32896. getSceneUniformBuffer(): UniformBuffer;
  32897. /**
  32898. * Gets an unique (relatively to the current scene) Id
  32899. * @returns an unique number for the scene
  32900. */
  32901. getUniqueId(): number;
  32902. /**
  32903. * Add a mesh to the list of scene's meshes
  32904. * @param newMesh defines the mesh to add
  32905. * @param recursive if all child meshes should also be added to the scene
  32906. */
  32907. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32908. /**
  32909. * Remove a mesh for the list of scene's meshes
  32910. * @param toRemove defines the mesh to remove
  32911. * @param recursive if all child meshes should also be removed from the scene
  32912. * @returns the index where the mesh was in the mesh list
  32913. */
  32914. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32915. /**
  32916. * Add a transform node to the list of scene's transform nodes
  32917. * @param newTransformNode defines the transform node to add
  32918. */
  32919. addTransformNode(newTransformNode: TransformNode): void;
  32920. /**
  32921. * Remove a transform node for the list of scene's transform nodes
  32922. * @param toRemove defines the transform node to remove
  32923. * @returns the index where the transform node was in the transform node list
  32924. */
  32925. removeTransformNode(toRemove: TransformNode): number;
  32926. /**
  32927. * Remove a skeleton for the list of scene's skeletons
  32928. * @param toRemove defines the skeleton to remove
  32929. * @returns the index where the skeleton was in the skeleton list
  32930. */
  32931. removeSkeleton(toRemove: Skeleton): number;
  32932. /**
  32933. * Remove a morph target for the list of scene's morph targets
  32934. * @param toRemove defines the morph target to remove
  32935. * @returns the index where the morph target was in the morph target list
  32936. */
  32937. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32938. /**
  32939. * Remove a light for the list of scene's lights
  32940. * @param toRemove defines the light to remove
  32941. * @returns the index where the light was in the light list
  32942. */
  32943. removeLight(toRemove: Light): number;
  32944. /**
  32945. * Remove a camera for the list of scene's cameras
  32946. * @param toRemove defines the camera to remove
  32947. * @returns the index where the camera was in the camera list
  32948. */
  32949. removeCamera(toRemove: Camera): number;
  32950. /**
  32951. * Remove a particle system for the list of scene's particle systems
  32952. * @param toRemove defines the particle system to remove
  32953. * @returns the index where the particle system was in the particle system list
  32954. */
  32955. removeParticleSystem(toRemove: IParticleSystem): number;
  32956. /**
  32957. * Remove a animation for the list of scene's animations
  32958. * @param toRemove defines the animation to remove
  32959. * @returns the index where the animation was in the animation list
  32960. */
  32961. removeAnimation(toRemove: Animation): number;
  32962. /**
  32963. * Removes the given animation group from this scene.
  32964. * @param toRemove The animation group to remove
  32965. * @returns The index of the removed animation group
  32966. */
  32967. removeAnimationGroup(toRemove: AnimationGroup): number;
  32968. /**
  32969. * Removes the given multi-material from this scene.
  32970. * @param toRemove The multi-material to remove
  32971. * @returns The index of the removed multi-material
  32972. */
  32973. removeMultiMaterial(toRemove: MultiMaterial): number;
  32974. /**
  32975. * Removes the given material from this scene.
  32976. * @param toRemove The material to remove
  32977. * @returns The index of the removed material
  32978. */
  32979. removeMaterial(toRemove: Material): number;
  32980. /**
  32981. * Removes the given action manager from this scene.
  32982. * @param toRemove The action manager to remove
  32983. * @returns The index of the removed action manager
  32984. */
  32985. removeActionManager(toRemove: AbstractActionManager): number;
  32986. /**
  32987. * Removes the given texture from this scene.
  32988. * @param toRemove The texture to remove
  32989. * @returns The index of the removed texture
  32990. */
  32991. removeTexture(toRemove: BaseTexture): number;
  32992. /**
  32993. * Adds the given light to this scene
  32994. * @param newLight The light to add
  32995. */
  32996. addLight(newLight: Light): void;
  32997. /**
  32998. * Sorts the list list based on light priorities
  32999. */
  33000. sortLightsByPriority(): void;
  33001. /**
  33002. * Adds the given camera to this scene
  33003. * @param newCamera The camera to add
  33004. */
  33005. addCamera(newCamera: Camera): void;
  33006. /**
  33007. * Adds the given skeleton to this scene
  33008. * @param newSkeleton The skeleton to add
  33009. */
  33010. addSkeleton(newSkeleton: Skeleton): void;
  33011. /**
  33012. * Adds the given particle system to this scene
  33013. * @param newParticleSystem The particle system to add
  33014. */
  33015. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33016. /**
  33017. * Adds the given animation to this scene
  33018. * @param newAnimation The animation to add
  33019. */
  33020. addAnimation(newAnimation: Animation): void;
  33021. /**
  33022. * Adds the given animation group to this scene.
  33023. * @param newAnimationGroup The animation group to add
  33024. */
  33025. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33026. /**
  33027. * Adds the given multi-material to this scene
  33028. * @param newMultiMaterial The multi-material to add
  33029. */
  33030. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33031. /**
  33032. * Adds the given material to this scene
  33033. * @param newMaterial The material to add
  33034. */
  33035. addMaterial(newMaterial: Material): void;
  33036. /**
  33037. * Adds the given morph target to this scene
  33038. * @param newMorphTargetManager The morph target to add
  33039. */
  33040. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33041. /**
  33042. * Adds the given geometry to this scene
  33043. * @param newGeometry The geometry to add
  33044. */
  33045. addGeometry(newGeometry: Geometry): void;
  33046. /**
  33047. * Adds the given action manager to this scene
  33048. * @param newActionManager The action manager to add
  33049. */
  33050. addActionManager(newActionManager: AbstractActionManager): void;
  33051. /**
  33052. * Adds the given texture to this scene.
  33053. * @param newTexture The texture to add
  33054. */
  33055. addTexture(newTexture: BaseTexture): void;
  33056. /**
  33057. * Switch active camera
  33058. * @param newCamera defines the new active camera
  33059. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33060. */
  33061. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33062. /**
  33063. * sets the active camera of the scene using its ID
  33064. * @param id defines the camera's ID
  33065. * @return the new active camera or null if none found.
  33066. */
  33067. setActiveCameraByID(id: string): Nullable<Camera>;
  33068. /**
  33069. * sets the active camera of the scene using its name
  33070. * @param name defines the camera's name
  33071. * @returns the new active camera or null if none found.
  33072. */
  33073. setActiveCameraByName(name: string): Nullable<Camera>;
  33074. /**
  33075. * get an animation group using its name
  33076. * @param name defines the material's name
  33077. * @return the animation group or null if none found.
  33078. */
  33079. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33080. /**
  33081. * get a material using its id
  33082. * @param id defines the material's ID
  33083. * @return the material or null if none found.
  33084. */
  33085. getMaterialByID(id: string): Nullable<Material>;
  33086. /**
  33087. * Gets a material using its name
  33088. * @param name defines the material's name
  33089. * @return the material or null if none found.
  33090. */
  33091. getMaterialByName(name: string): Nullable<Material>;
  33092. /**
  33093. * Gets a camera using its id
  33094. * @param id defines the id to look for
  33095. * @returns the camera or null if not found
  33096. */
  33097. getCameraByID(id: string): Nullable<Camera>;
  33098. /**
  33099. * Gets a camera using its unique id
  33100. * @param uniqueId defines the unique id to look for
  33101. * @returns the camera or null if not found
  33102. */
  33103. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33104. /**
  33105. * Gets a camera using its name
  33106. * @param name defines the camera's name
  33107. * @return the camera or null if none found.
  33108. */
  33109. getCameraByName(name: string): Nullable<Camera>;
  33110. /**
  33111. * Gets a bone using its id
  33112. * @param id defines the bone's id
  33113. * @return the bone or null if not found
  33114. */
  33115. getBoneByID(id: string): Nullable<Bone>;
  33116. /**
  33117. * Gets a bone using its id
  33118. * @param name defines the bone's name
  33119. * @return the bone or null if not found
  33120. */
  33121. getBoneByName(name: string): Nullable<Bone>;
  33122. /**
  33123. * Gets a light node using its name
  33124. * @param name defines the the light's name
  33125. * @return the light or null if none found.
  33126. */
  33127. getLightByName(name: string): Nullable<Light>;
  33128. /**
  33129. * Gets a light node using its id
  33130. * @param id defines the light's id
  33131. * @return the light or null if none found.
  33132. */
  33133. getLightByID(id: string): Nullable<Light>;
  33134. /**
  33135. * Gets a light node using its scene-generated unique ID
  33136. * @param uniqueId defines the light's unique id
  33137. * @return the light or null if none found.
  33138. */
  33139. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33140. /**
  33141. * Gets a particle system by id
  33142. * @param id defines the particle system id
  33143. * @return the corresponding system or null if none found
  33144. */
  33145. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33146. /**
  33147. * Gets a geometry using its ID
  33148. * @param id defines the geometry's id
  33149. * @return the geometry or null if none found.
  33150. */
  33151. getGeometryByID(id: string): Nullable<Geometry>;
  33152. private _getGeometryByUniqueID;
  33153. /**
  33154. * Add a new geometry to this scene
  33155. * @param geometry defines the geometry to be added to the scene.
  33156. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33157. * @return a boolean defining if the geometry was added or not
  33158. */
  33159. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33160. /**
  33161. * Removes an existing geometry
  33162. * @param geometry defines the geometry to be removed from the scene
  33163. * @return a boolean defining if the geometry was removed or not
  33164. */
  33165. removeGeometry(geometry: Geometry): boolean;
  33166. /**
  33167. * Gets the list of geometries attached to the scene
  33168. * @returns an array of Geometry
  33169. */
  33170. getGeometries(): Geometry[];
  33171. /**
  33172. * Gets the first added mesh found of a given ID
  33173. * @param id defines the id to search for
  33174. * @return the mesh found or null if not found at all
  33175. */
  33176. getMeshByID(id: string): Nullable<AbstractMesh>;
  33177. /**
  33178. * Gets a list of meshes using their id
  33179. * @param id defines the id to search for
  33180. * @returns a list of meshes
  33181. */
  33182. getMeshesByID(id: string): Array<AbstractMesh>;
  33183. /**
  33184. * Gets the first added transform node found of a given ID
  33185. * @param id defines the id to search for
  33186. * @return the found transform node or null if not found at all.
  33187. */
  33188. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33189. /**
  33190. * Gets a list of transform nodes using their id
  33191. * @param id defines the id to search for
  33192. * @returns a list of transform nodes
  33193. */
  33194. getTransformNodesByID(id: string): Array<TransformNode>;
  33195. /**
  33196. * Gets a mesh with its auto-generated unique id
  33197. * @param uniqueId defines the unique id to search for
  33198. * @return the found mesh or null if not found at all.
  33199. */
  33200. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33201. /**
  33202. * Gets a the last added mesh using a given id
  33203. * @param id defines the id to search for
  33204. * @return the found mesh or null if not found at all.
  33205. */
  33206. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33207. /**
  33208. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33209. * @param id defines the id to search for
  33210. * @return the found node or null if not found at all
  33211. */
  33212. getLastEntryByID(id: string): Nullable<Node>;
  33213. /**
  33214. * Gets a node (Mesh, Camera, Light) using a given id
  33215. * @param id defines the id to search for
  33216. * @return the found node or null if not found at all
  33217. */
  33218. getNodeByID(id: string): Nullable<Node>;
  33219. /**
  33220. * Gets a node (Mesh, Camera, Light) using a given name
  33221. * @param name defines the name to search for
  33222. * @return the found node or null if not found at all.
  33223. */
  33224. getNodeByName(name: string): Nullable<Node>;
  33225. /**
  33226. * Gets a mesh using a given name
  33227. * @param name defines the name to search for
  33228. * @return the found mesh or null if not found at all.
  33229. */
  33230. getMeshByName(name: string): Nullable<AbstractMesh>;
  33231. /**
  33232. * Gets a transform node using a given name
  33233. * @param name defines the name to search for
  33234. * @return the found transform node or null if not found at all.
  33235. */
  33236. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33237. /**
  33238. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33239. * @param id defines the id to search for
  33240. * @return the found skeleton or null if not found at all.
  33241. */
  33242. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33243. /**
  33244. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33245. * @param id defines the id to search for
  33246. * @return the found skeleton or null if not found at all.
  33247. */
  33248. getSkeletonById(id: string): Nullable<Skeleton>;
  33249. /**
  33250. * Gets a skeleton using a given name
  33251. * @param name defines the name to search for
  33252. * @return the found skeleton or null if not found at all.
  33253. */
  33254. getSkeletonByName(name: string): Nullable<Skeleton>;
  33255. /**
  33256. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33257. * @param id defines the id to search for
  33258. * @return the found morph target manager or null if not found at all.
  33259. */
  33260. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33261. /**
  33262. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33263. * @param id defines the id to search for
  33264. * @return the found morph target or null if not found at all.
  33265. */
  33266. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33267. /**
  33268. * Gets a boolean indicating if the given mesh is active
  33269. * @param mesh defines the mesh to look for
  33270. * @returns true if the mesh is in the active list
  33271. */
  33272. isActiveMesh(mesh: AbstractMesh): boolean;
  33273. /**
  33274. * Return a unique id as a string which can serve as an identifier for the scene
  33275. */
  33276. readonly uid: string;
  33277. /**
  33278. * Add an externaly attached data from its key.
  33279. * This method call will fail and return false, if such key already exists.
  33280. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33281. * @param key the unique key that identifies the data
  33282. * @param data the data object to associate to the key for this Engine instance
  33283. * @return true if no such key were already present and the data was added successfully, false otherwise
  33284. */
  33285. addExternalData<T>(key: string, data: T): boolean;
  33286. /**
  33287. * Get an externaly attached data from its key
  33288. * @param key the unique key that identifies the data
  33289. * @return the associated data, if present (can be null), or undefined if not present
  33290. */
  33291. getExternalData<T>(key: string): Nullable<T>;
  33292. /**
  33293. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33294. * @param key the unique key that identifies the data
  33295. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33296. * @return the associated data, can be null if the factory returned null.
  33297. */
  33298. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33299. /**
  33300. * Remove an externaly attached data from the Engine instance
  33301. * @param key the unique key that identifies the data
  33302. * @return true if the data was successfully removed, false if it doesn't exist
  33303. */
  33304. removeExternalData(key: string): boolean;
  33305. private _evaluateSubMesh;
  33306. /**
  33307. * Clear the processed materials smart array preventing retention point in material dispose.
  33308. */
  33309. freeProcessedMaterials(): void;
  33310. private _preventFreeActiveMeshesAndRenderingGroups;
  33311. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33312. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33313. * when disposing several meshes in a row or a hierarchy of meshes.
  33314. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33315. */
  33316. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33317. /**
  33318. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33319. */
  33320. freeActiveMeshes(): void;
  33321. /**
  33322. * Clear the info related to rendering groups preventing retention points during dispose.
  33323. */
  33324. freeRenderingGroups(): void;
  33325. /** @hidden */
  33326. _isInIntermediateRendering(): boolean;
  33327. /**
  33328. * Lambda returning the list of potentially active meshes.
  33329. */
  33330. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33331. /**
  33332. * Lambda returning the list of potentially active sub meshes.
  33333. */
  33334. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33335. /**
  33336. * Lambda returning the list of potentially intersecting sub meshes.
  33337. */
  33338. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33339. /**
  33340. * Lambda returning the list of potentially colliding sub meshes.
  33341. */
  33342. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33343. private _activeMeshesFrozen;
  33344. /**
  33345. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33346. * @returns the current scene
  33347. */
  33348. freezeActiveMeshes(): Scene;
  33349. /**
  33350. * Use this function to restart evaluating active meshes on every frame
  33351. * @returns the current scene
  33352. */
  33353. unfreezeActiveMeshes(): Scene;
  33354. private _evaluateActiveMeshes;
  33355. private _activeMesh;
  33356. /**
  33357. * Update the transform matrix to update from the current active camera
  33358. * @param force defines a boolean used to force the update even if cache is up to date
  33359. */
  33360. updateTransformMatrix(force?: boolean): void;
  33361. /**
  33362. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  33363. * @param alternateCamera defines the camera to use
  33364. */
  33365. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33366. /** @hidden */
  33367. _allowPostProcessClearColor: boolean;
  33368. private _renderForCamera;
  33369. private _processSubCameras;
  33370. private _checkIntersections;
  33371. /** @hidden */
  33372. _advancePhysicsEngineStep(step: number): void;
  33373. /**
  33374. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33375. */
  33376. getDeterministicFrameTime: () => number;
  33377. /** @hidden */
  33378. _animate(): void;
  33379. /**
  33380. * Render the scene
  33381. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33382. */
  33383. render(updateCameras?: boolean): void;
  33384. /**
  33385. * Freeze all materials
  33386. * A frozen material will not be updatable but should be faster to render
  33387. */
  33388. freezeMaterials(): void;
  33389. /**
  33390. * Unfreeze all materials
  33391. * A frozen material will not be updatable but should be faster to render
  33392. */
  33393. unfreezeMaterials(): void;
  33394. /**
  33395. * Releases all held ressources
  33396. */
  33397. dispose(): void;
  33398. /**
  33399. * Gets if the scene is already disposed
  33400. */
  33401. readonly isDisposed: boolean;
  33402. /**
  33403. * Call this function to reduce memory footprint of the scene.
  33404. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33405. */
  33406. clearCachedVertexData(): void;
  33407. /**
  33408. * This function will remove the local cached buffer data from texture.
  33409. * It will save memory but will prevent the texture from being rebuilt
  33410. */
  33411. cleanCachedTextureBuffer(): void;
  33412. /**
  33413. * Get the world extend vectors with an optional filter
  33414. *
  33415. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33416. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33417. */
  33418. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33419. min: Vector3;
  33420. max: Vector3;
  33421. };
  33422. /**
  33423. * Creates a ray that can be used to pick in the scene
  33424. * @param x defines the x coordinate of the origin (on-screen)
  33425. * @param y defines the y coordinate of the origin (on-screen)
  33426. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33427. * @param camera defines the camera to use for the picking
  33428. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33429. * @returns a Ray
  33430. */
  33431. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33432. /**
  33433. * Creates a ray that can be used to pick in the scene
  33434. * @param x defines the x coordinate of the origin (on-screen)
  33435. * @param y defines the y coordinate of the origin (on-screen)
  33436. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33437. * @param result defines the ray where to store the picking ray
  33438. * @param camera defines the camera to use for the picking
  33439. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33440. * @returns the current scene
  33441. */
  33442. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33443. /**
  33444. * Creates a ray that can be used to pick in the scene
  33445. * @param x defines the x coordinate of the origin (on-screen)
  33446. * @param y defines the y coordinate of the origin (on-screen)
  33447. * @param camera defines the camera to use for the picking
  33448. * @returns a Ray
  33449. */
  33450. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33451. /**
  33452. * Creates a ray that can be used to pick in the scene
  33453. * @param x defines the x coordinate of the origin (on-screen)
  33454. * @param y defines the y coordinate of the origin (on-screen)
  33455. * @param result defines the ray where to store the picking ray
  33456. * @param camera defines the camera to use for the picking
  33457. * @returns the current scene
  33458. */
  33459. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33460. /** Launch a ray to try to pick a mesh in the scene
  33461. * @param x position on screen
  33462. * @param y position on screen
  33463. * @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
  33464. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33465. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33466. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33467. * @returns a PickingInfo
  33468. */
  33469. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33470. /** Use the given ray to pick a mesh in the scene
  33471. * @param ray The ray to use to pick meshes
  33472. * @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
  33473. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33474. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33475. * @returns a PickingInfo
  33476. */
  33477. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33478. /**
  33479. * Launch a ray to try to pick a mesh in the scene
  33480. * @param x X position on screen
  33481. * @param y Y position on screen
  33482. * @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
  33483. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33484. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33485. * @returns an array of PickingInfo
  33486. */
  33487. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33488. /**
  33489. * Launch a ray to try to pick a mesh in the scene
  33490. * @param ray Ray to use
  33491. * @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
  33492. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33493. * @returns an array of PickingInfo
  33494. */
  33495. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33496. /**
  33497. * Force the value of meshUnderPointer
  33498. * @param mesh defines the mesh to use
  33499. */
  33500. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33501. /**
  33502. * Gets the mesh under the pointer
  33503. * @returns a Mesh or null if no mesh is under the pointer
  33504. */
  33505. getPointerOverMesh(): Nullable<AbstractMesh>;
  33506. /** @hidden */
  33507. _rebuildGeometries(): void;
  33508. /** @hidden */
  33509. _rebuildTextures(): void;
  33510. private _getByTags;
  33511. /**
  33512. * Get a list of meshes by tags
  33513. * @param tagsQuery defines the tags query to use
  33514. * @param forEach defines a predicate used to filter results
  33515. * @returns an array of Mesh
  33516. */
  33517. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33518. /**
  33519. * Get a list of cameras by tags
  33520. * @param tagsQuery defines the tags query to use
  33521. * @param forEach defines a predicate used to filter results
  33522. * @returns an array of Camera
  33523. */
  33524. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33525. /**
  33526. * Get a list of lights by tags
  33527. * @param tagsQuery defines the tags query to use
  33528. * @param forEach defines a predicate used to filter results
  33529. * @returns an array of Light
  33530. */
  33531. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33532. /**
  33533. * Get a list of materials by tags
  33534. * @param tagsQuery defines the tags query to use
  33535. * @param forEach defines a predicate used to filter results
  33536. * @returns an array of Material
  33537. */
  33538. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33539. /**
  33540. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33541. * This allowed control for front to back rendering or reversly depending of the special needs.
  33542. *
  33543. * @param renderingGroupId The rendering group id corresponding to its index
  33544. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33545. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33546. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33547. */
  33548. 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;
  33549. /**
  33550. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33551. *
  33552. * @param renderingGroupId The rendering group id corresponding to its index
  33553. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33554. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33555. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33556. */
  33557. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33558. /**
  33559. * Gets the current auto clear configuration for one rendering group of the rendering
  33560. * manager.
  33561. * @param index the rendering group index to get the information for
  33562. * @returns The auto clear setup for the requested rendering group
  33563. */
  33564. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33565. private _blockMaterialDirtyMechanism;
  33566. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33567. blockMaterialDirtyMechanism: boolean;
  33568. /**
  33569. * Will flag all materials as dirty to trigger new shader compilation
  33570. * @param flag defines the flag used to specify which material part must be marked as dirty
  33571. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33572. */
  33573. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33574. /** @hidden */
  33575. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  33576. /** @hidden */
  33577. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33578. }
  33579. }
  33580. declare module "babylonjs/assetContainer" {
  33581. import { AbstractScene } from "babylonjs/abstractScene";
  33582. import { Scene } from "babylonjs/scene";
  33583. import { Mesh } from "babylonjs/Meshes/mesh";
  33584. /**
  33585. * Set of assets to keep when moving a scene into an asset container.
  33586. */
  33587. export class KeepAssets extends AbstractScene {
  33588. }
  33589. /**
  33590. * Container with a set of assets that can be added or removed from a scene.
  33591. */
  33592. export class AssetContainer extends AbstractScene {
  33593. /**
  33594. * The scene the AssetContainer belongs to.
  33595. */
  33596. scene: Scene;
  33597. /**
  33598. * Instantiates an AssetContainer.
  33599. * @param scene The scene the AssetContainer belongs to.
  33600. */
  33601. constructor(scene: Scene);
  33602. /**
  33603. * Adds all the assets from the container to the scene.
  33604. */
  33605. addAllToScene(): void;
  33606. /**
  33607. * Removes all the assets in the container from the scene
  33608. */
  33609. removeAllFromScene(): void;
  33610. /**
  33611. * Disposes all the assets in the container
  33612. */
  33613. dispose(): void;
  33614. private _moveAssets;
  33615. /**
  33616. * Removes all the assets contained in the scene and adds them to the container.
  33617. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33618. */
  33619. moveAllFromScene(keepAssets?: KeepAssets): void;
  33620. /**
  33621. * 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.
  33622. * @returns the root mesh
  33623. */
  33624. createRootMesh(): Mesh;
  33625. }
  33626. }
  33627. declare module "babylonjs/abstractScene" {
  33628. import { Scene } from "babylonjs/scene";
  33629. import { Nullable } from "babylonjs/types";
  33630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33631. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33632. import { Geometry } from "babylonjs/Meshes/geometry";
  33633. import { Skeleton } from "babylonjs/Bones/skeleton";
  33634. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33635. import { AssetContainer } from "babylonjs/assetContainer";
  33636. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33637. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33638. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33639. import { Material } from "babylonjs/Materials/material";
  33640. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33641. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33642. import { Camera } from "babylonjs/Cameras/camera";
  33643. import { Light } from "babylonjs/Lights/light";
  33644. import { Node } from "babylonjs/node";
  33645. import { Animation } from "babylonjs/Animations/animation";
  33646. /**
  33647. * Defines how the parser contract is defined.
  33648. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33649. */
  33650. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33651. /**
  33652. * Defines how the individual parser contract is defined.
  33653. * These parser can parse an individual asset
  33654. */
  33655. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33656. /**
  33657. * Base class of the scene acting as a container for the different elements composing a scene.
  33658. * This class is dynamically extended by the different components of the scene increasing
  33659. * flexibility and reducing coupling
  33660. */
  33661. export abstract class AbstractScene {
  33662. /**
  33663. * Stores the list of available parsers in the application.
  33664. */
  33665. private static _BabylonFileParsers;
  33666. /**
  33667. * Stores the list of available individual parsers in the application.
  33668. */
  33669. private static _IndividualBabylonFileParsers;
  33670. /**
  33671. * Adds a parser in the list of available ones
  33672. * @param name Defines the name of the parser
  33673. * @param parser Defines the parser to add
  33674. */
  33675. static AddParser(name: string, parser: BabylonFileParser): void;
  33676. /**
  33677. * Gets a general parser from the list of avaialble ones
  33678. * @param name Defines the name of the parser
  33679. * @returns the requested parser or null
  33680. */
  33681. static GetParser(name: string): Nullable<BabylonFileParser>;
  33682. /**
  33683. * Adds n individual parser in the list of available ones
  33684. * @param name Defines the name of the parser
  33685. * @param parser Defines the parser to add
  33686. */
  33687. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33688. /**
  33689. * Gets an individual parser from the list of avaialble ones
  33690. * @param name Defines the name of the parser
  33691. * @returns the requested parser or null
  33692. */
  33693. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33694. /**
  33695. * Parser json data and populate both a scene and its associated container object
  33696. * @param jsonData Defines the data to parse
  33697. * @param scene Defines the scene to parse the data for
  33698. * @param container Defines the container attached to the parsing sequence
  33699. * @param rootUrl Defines the root url of the data
  33700. */
  33701. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33702. /**
  33703. * Gets the list of root nodes (ie. nodes with no parent)
  33704. */
  33705. rootNodes: Node[];
  33706. /** All of the cameras added to this scene
  33707. * @see http://doc.babylonjs.com/babylon101/cameras
  33708. */
  33709. cameras: Camera[];
  33710. /**
  33711. * All of the lights added to this scene
  33712. * @see http://doc.babylonjs.com/babylon101/lights
  33713. */
  33714. lights: Light[];
  33715. /**
  33716. * All of the (abstract) meshes added to this scene
  33717. */
  33718. meshes: AbstractMesh[];
  33719. /**
  33720. * The list of skeletons added to the scene
  33721. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33722. */
  33723. skeletons: Skeleton[];
  33724. /**
  33725. * All of the particle systems added to this scene
  33726. * @see http://doc.babylonjs.com/babylon101/particles
  33727. */
  33728. particleSystems: IParticleSystem[];
  33729. /**
  33730. * Gets a list of Animations associated with the scene
  33731. */
  33732. animations: Animation[];
  33733. /**
  33734. * All of the animation groups added to this scene
  33735. * @see http://doc.babylonjs.com/how_to/group
  33736. */
  33737. animationGroups: AnimationGroup[];
  33738. /**
  33739. * All of the multi-materials added to this scene
  33740. * @see http://doc.babylonjs.com/how_to/multi_materials
  33741. */
  33742. multiMaterials: MultiMaterial[];
  33743. /**
  33744. * All of the materials added to this scene
  33745. * In the context of a Scene, it is not supposed to be modified manually.
  33746. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33747. * Note also that the order of the Material wihin the array is not significant and might change.
  33748. * @see http://doc.babylonjs.com/babylon101/materials
  33749. */
  33750. materials: Material[];
  33751. /**
  33752. * The list of morph target managers added to the scene
  33753. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33754. */
  33755. morphTargetManagers: MorphTargetManager[];
  33756. /**
  33757. * The list of geometries used in the scene.
  33758. */
  33759. geometries: Geometry[];
  33760. /**
  33761. * All of the tranform nodes added to this scene
  33762. * In the context of a Scene, it is not supposed to be modified manually.
  33763. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33764. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33765. * @see http://doc.babylonjs.com/how_to/transformnode
  33766. */
  33767. transformNodes: TransformNode[];
  33768. /**
  33769. * ActionManagers available on the scene.
  33770. */
  33771. actionManagers: AbstractActionManager[];
  33772. /**
  33773. * Textures to keep.
  33774. */
  33775. textures: BaseTexture[];
  33776. }
  33777. }
  33778. declare module "babylonjs/Audio/sound" {
  33779. import { Observable } from "babylonjs/Misc/observable";
  33780. import { Vector3 } from "babylonjs/Maths/math";
  33781. import { Nullable } from "babylonjs/types";
  33782. import { Scene } from "babylonjs/scene";
  33783. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33784. /**
  33785. * Defines a sound that can be played in the application.
  33786. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33787. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33788. */
  33789. export class Sound {
  33790. /**
  33791. * The name of the sound in the scene.
  33792. */
  33793. name: string;
  33794. /**
  33795. * Does the sound autoplay once loaded.
  33796. */
  33797. autoplay: boolean;
  33798. /**
  33799. * Does the sound loop after it finishes playing once.
  33800. */
  33801. loop: boolean;
  33802. /**
  33803. * Does the sound use a custom attenuation curve to simulate the falloff
  33804. * happening when the source gets further away from the camera.
  33805. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33806. */
  33807. useCustomAttenuation: boolean;
  33808. /**
  33809. * The sound track id this sound belongs to.
  33810. */
  33811. soundTrackId: number;
  33812. /**
  33813. * Is this sound currently played.
  33814. */
  33815. isPlaying: boolean;
  33816. /**
  33817. * Is this sound currently paused.
  33818. */
  33819. isPaused: boolean;
  33820. /**
  33821. * Does this sound enables spatial sound.
  33822. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33823. */
  33824. spatialSound: boolean;
  33825. /**
  33826. * Define the reference distance the sound should be heard perfectly.
  33827. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33828. */
  33829. refDistance: number;
  33830. /**
  33831. * Define the roll off factor of spatial sounds.
  33832. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33833. */
  33834. rolloffFactor: number;
  33835. /**
  33836. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33837. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33838. */
  33839. maxDistance: number;
  33840. /**
  33841. * Define the distance attenuation model the sound will follow.
  33842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33843. */
  33844. distanceModel: string;
  33845. /**
  33846. * @hidden
  33847. * Back Compat
  33848. **/
  33849. onended: () => any;
  33850. /**
  33851. * Observable event when the current playing sound finishes.
  33852. */
  33853. onEndedObservable: Observable<Sound>;
  33854. private _panningModel;
  33855. private _playbackRate;
  33856. private _streaming;
  33857. private _startTime;
  33858. private _startOffset;
  33859. private _position;
  33860. /** @hidden */
  33861. _positionInEmitterSpace: boolean;
  33862. private _localDirection;
  33863. private _volume;
  33864. private _isReadyToPlay;
  33865. private _isDirectional;
  33866. private _readyToPlayCallback;
  33867. private _audioBuffer;
  33868. private _soundSource;
  33869. private _streamingSource;
  33870. private _soundPanner;
  33871. private _soundGain;
  33872. private _inputAudioNode;
  33873. private _outputAudioNode;
  33874. private _coneInnerAngle;
  33875. private _coneOuterAngle;
  33876. private _coneOuterGain;
  33877. private _scene;
  33878. private _connectedTransformNode;
  33879. private _customAttenuationFunction;
  33880. private _registerFunc;
  33881. private _isOutputConnected;
  33882. private _htmlAudioElement;
  33883. private _urlType;
  33884. /** @hidden */
  33885. static _SceneComponentInitialization: (scene: Scene) => void;
  33886. /**
  33887. * Create a sound and attach it to a scene
  33888. * @param name Name of your sound
  33889. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33890. * @param scene defines the scene the sound belongs to
  33891. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33892. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33893. */
  33894. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33895. /**
  33896. * Release the sound and its associated resources
  33897. */
  33898. dispose(): void;
  33899. /**
  33900. * Gets if the sounds is ready to be played or not.
  33901. * @returns true if ready, otherwise false
  33902. */
  33903. isReady(): boolean;
  33904. private _soundLoaded;
  33905. /**
  33906. * Sets the data of the sound from an audiobuffer
  33907. * @param audioBuffer The audioBuffer containing the data
  33908. */
  33909. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33910. /**
  33911. * Updates the current sounds options such as maxdistance, loop...
  33912. * @param options A JSON object containing values named as the object properties
  33913. */
  33914. updateOptions(options: any): void;
  33915. private _createSpatialParameters;
  33916. private _updateSpatialParameters;
  33917. /**
  33918. * Switch the panning model to HRTF:
  33919. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33920. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33921. */
  33922. switchPanningModelToHRTF(): void;
  33923. /**
  33924. * Switch the panning model to Equal Power:
  33925. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33926. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33927. */
  33928. switchPanningModelToEqualPower(): void;
  33929. private _switchPanningModel;
  33930. /**
  33931. * Connect this sound to a sound track audio node like gain...
  33932. * @param soundTrackAudioNode the sound track audio node to connect to
  33933. */
  33934. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33935. /**
  33936. * Transform this sound into a directional source
  33937. * @param coneInnerAngle Size of the inner cone in degree
  33938. * @param coneOuterAngle Size of the outer cone in degree
  33939. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33940. */
  33941. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33942. /**
  33943. * Gets or sets the inner angle for the directional cone.
  33944. */
  33945. /**
  33946. * Gets or sets the inner angle for the directional cone.
  33947. */
  33948. directionalConeInnerAngle: number;
  33949. /**
  33950. * Gets or sets the outer angle for the directional cone.
  33951. */
  33952. /**
  33953. * Gets or sets the outer angle for the directional cone.
  33954. */
  33955. directionalConeOuterAngle: number;
  33956. /**
  33957. * Sets the position of the emitter if spatial sound is enabled
  33958. * @param newPosition Defines the new posisiton
  33959. */
  33960. setPosition(newPosition: Vector3): void;
  33961. /**
  33962. * Sets the local direction of the emitter if spatial sound is enabled
  33963. * @param newLocalDirection Defines the new local direction
  33964. */
  33965. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33966. private _updateDirection;
  33967. /** @hidden */
  33968. updateDistanceFromListener(): void;
  33969. /**
  33970. * Sets a new custom attenuation function for the sound.
  33971. * @param callback Defines the function used for the attenuation
  33972. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33973. */
  33974. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33975. /**
  33976. * Play the sound
  33977. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33978. * @param offset (optional) Start the sound setting it at a specific time
  33979. */
  33980. play(time?: number, offset?: number): void;
  33981. private _onended;
  33982. /**
  33983. * Stop the sound
  33984. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33985. */
  33986. stop(time?: number): void;
  33987. /**
  33988. * Put the sound in pause
  33989. */
  33990. pause(): void;
  33991. /**
  33992. * Sets a dedicated volume for this sounds
  33993. * @param newVolume Define the new volume of the sound
  33994. * @param time Define in how long the sound should be at this value
  33995. */
  33996. setVolume(newVolume: number, time?: number): void;
  33997. /**
  33998. * Set the sound play back rate
  33999. * @param newPlaybackRate Define the playback rate the sound should be played at
  34000. */
  34001. setPlaybackRate(newPlaybackRate: number): void;
  34002. /**
  34003. * Gets the volume of the sound.
  34004. * @returns the volume of the sound
  34005. */
  34006. getVolume(): number;
  34007. /**
  34008. * Attach the sound to a dedicated mesh
  34009. * @param transformNode The transform node to connect the sound with
  34010. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34011. */
  34012. attachToMesh(transformNode: TransformNode): void;
  34013. /**
  34014. * Detach the sound from the previously attached mesh
  34015. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34016. */
  34017. detachFromMesh(): void;
  34018. private _onRegisterAfterWorldMatrixUpdate;
  34019. /**
  34020. * Clone the current sound in the scene.
  34021. * @returns the new sound clone
  34022. */
  34023. clone(): Nullable<Sound>;
  34024. /**
  34025. * Gets the current underlying audio buffer containing the data
  34026. * @returns the audio buffer
  34027. */
  34028. getAudioBuffer(): Nullable<AudioBuffer>;
  34029. /**
  34030. * Serializes the Sound in a JSON representation
  34031. * @returns the JSON representation of the sound
  34032. */
  34033. serialize(): any;
  34034. /**
  34035. * Parse a JSON representation of a sound to innstantiate in a given scene
  34036. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34037. * @param scene Define the scene the new parsed sound should be created in
  34038. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34039. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34040. * @returns the newly parsed sound
  34041. */
  34042. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34043. }
  34044. }
  34045. declare module "babylonjs/Actions/directAudioActions" {
  34046. import { Action } from "babylonjs/Actions/action";
  34047. import { Condition } from "babylonjs/Actions/condition";
  34048. import { Sound } from "babylonjs/Audio/sound";
  34049. /**
  34050. * This defines an action helpful to play a defined sound on a triggered action.
  34051. */
  34052. export class PlaySoundAction extends Action {
  34053. private _sound;
  34054. /**
  34055. * Instantiate the action
  34056. * @param triggerOptions defines the trigger options
  34057. * @param sound defines the sound to play
  34058. * @param condition defines the trigger related conditions
  34059. */
  34060. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34061. /** @hidden */
  34062. _prepare(): void;
  34063. /**
  34064. * Execute the action and play the sound.
  34065. */
  34066. execute(): void;
  34067. /**
  34068. * Serializes the actions and its related information.
  34069. * @param parent defines the object to serialize in
  34070. * @returns the serialized object
  34071. */
  34072. serialize(parent: any): any;
  34073. }
  34074. /**
  34075. * This defines an action helpful to stop a defined sound on a triggered action.
  34076. */
  34077. export class StopSoundAction extends Action {
  34078. private _sound;
  34079. /**
  34080. * Instantiate the action
  34081. * @param triggerOptions defines the trigger options
  34082. * @param sound defines the sound to stop
  34083. * @param condition defines the trigger related conditions
  34084. */
  34085. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34086. /** @hidden */
  34087. _prepare(): void;
  34088. /**
  34089. * Execute the action and stop the sound.
  34090. */
  34091. execute(): void;
  34092. /**
  34093. * Serializes the actions and its related information.
  34094. * @param parent defines the object to serialize in
  34095. * @returns the serialized object
  34096. */
  34097. serialize(parent: any): any;
  34098. }
  34099. }
  34100. declare module "babylonjs/Actions/interpolateValueAction" {
  34101. import { Action } from "babylonjs/Actions/action";
  34102. import { Condition } from "babylonjs/Actions/condition";
  34103. import { Observable } from "babylonjs/Misc/observable";
  34104. /**
  34105. * This defines an action responsible to change the value of a property
  34106. * by interpolating between its current value and the newly set one once triggered.
  34107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34108. */
  34109. export class InterpolateValueAction extends Action {
  34110. /**
  34111. * Defines the path of the property where the value should be interpolated
  34112. */
  34113. propertyPath: string;
  34114. /**
  34115. * Defines the target value at the end of the interpolation.
  34116. */
  34117. value: any;
  34118. /**
  34119. * Defines the time it will take for the property to interpolate to the value.
  34120. */
  34121. duration: number;
  34122. /**
  34123. * Defines if the other scene animations should be stopped when the action has been triggered
  34124. */
  34125. stopOtherAnimations?: boolean;
  34126. /**
  34127. * Defines a callback raised once the interpolation animation has been done.
  34128. */
  34129. onInterpolationDone?: () => void;
  34130. /**
  34131. * Observable triggered once the interpolation animation has been done.
  34132. */
  34133. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34134. private _target;
  34135. private _effectiveTarget;
  34136. private _property;
  34137. /**
  34138. * Instantiate the action
  34139. * @param triggerOptions defines the trigger options
  34140. * @param target defines the object containing the value to interpolate
  34141. * @param propertyPath defines the path to the property in the target object
  34142. * @param value defines the target value at the end of the interpolation
  34143. * @param duration deines the time it will take for the property to interpolate to the value.
  34144. * @param condition defines the trigger related conditions
  34145. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34146. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34147. */
  34148. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34149. /** @hidden */
  34150. _prepare(): void;
  34151. /**
  34152. * Execute the action starts the value interpolation.
  34153. */
  34154. execute(): void;
  34155. /**
  34156. * Serializes the actions and its related information.
  34157. * @param parent defines the object to serialize in
  34158. * @returns the serialized object
  34159. */
  34160. serialize(parent: any): any;
  34161. }
  34162. }
  34163. declare module "babylonjs/Actions/index" {
  34164. export * from "babylonjs/Actions/action";
  34165. export * from "babylonjs/Actions/actionEvent";
  34166. export * from "babylonjs/Actions/actionManager";
  34167. export * from "babylonjs/Actions/condition";
  34168. export * from "babylonjs/Actions/directActions";
  34169. export * from "babylonjs/Actions/directAudioActions";
  34170. export * from "babylonjs/Actions/interpolateValueAction";
  34171. }
  34172. declare module "babylonjs/Animations/index" {
  34173. export * from "babylonjs/Animations/animatable";
  34174. export * from "babylonjs/Animations/animation";
  34175. export * from "babylonjs/Animations/animationGroup";
  34176. export * from "babylonjs/Animations/animationPropertiesOverride";
  34177. export * from "babylonjs/Animations/easing";
  34178. export * from "babylonjs/Animations/runtimeAnimation";
  34179. export * from "babylonjs/Animations/animationEvent";
  34180. export * from "babylonjs/Animations/animationGroup";
  34181. export * from "babylonjs/Animations/animationKey";
  34182. export * from "babylonjs/Animations/animationRange";
  34183. }
  34184. declare module "babylonjs/Audio/soundTrack" {
  34185. import { Sound } from "babylonjs/Audio/sound";
  34186. import { Analyser } from "babylonjs/Audio/analyser";
  34187. import { Scene } from "babylonjs/scene";
  34188. /**
  34189. * Options allowed during the creation of a sound track.
  34190. */
  34191. export interface ISoundTrackOptions {
  34192. /**
  34193. * The volume the sound track should take during creation
  34194. */
  34195. volume?: number;
  34196. /**
  34197. * Define if the sound track is the main sound track of the scene
  34198. */
  34199. mainTrack?: boolean;
  34200. }
  34201. /**
  34202. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34203. * It will be also used in a future release to apply effects on a specific track.
  34204. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34205. */
  34206. export class SoundTrack {
  34207. /**
  34208. * The unique identifier of the sound track in the scene.
  34209. */
  34210. id: number;
  34211. /**
  34212. * The list of sounds included in the sound track.
  34213. */
  34214. soundCollection: Array<Sound>;
  34215. private _outputAudioNode;
  34216. private _scene;
  34217. private _isMainTrack;
  34218. private _connectedAnalyser;
  34219. private _options;
  34220. private _isInitialized;
  34221. /**
  34222. * Creates a new sound track.
  34223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34224. * @param scene Define the scene the sound track belongs to
  34225. * @param options
  34226. */
  34227. constructor(scene: Scene, options?: ISoundTrackOptions);
  34228. private _initializeSoundTrackAudioGraph;
  34229. /**
  34230. * Release the sound track and its associated resources
  34231. */
  34232. dispose(): void;
  34233. /**
  34234. * Adds a sound to this sound track
  34235. * @param sound define the cound to add
  34236. * @ignoreNaming
  34237. */
  34238. AddSound(sound: Sound): void;
  34239. /**
  34240. * Removes a sound to this sound track
  34241. * @param sound define the cound to remove
  34242. * @ignoreNaming
  34243. */
  34244. RemoveSound(sound: Sound): void;
  34245. /**
  34246. * Set a global volume for the full sound track.
  34247. * @param newVolume Define the new volume of the sound track
  34248. */
  34249. setVolume(newVolume: number): void;
  34250. /**
  34251. * Switch the panning model to HRTF:
  34252. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34254. */
  34255. switchPanningModelToHRTF(): void;
  34256. /**
  34257. * Switch the panning model to Equal Power:
  34258. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34260. */
  34261. switchPanningModelToEqualPower(): void;
  34262. /**
  34263. * Connect the sound track to an audio analyser allowing some amazing
  34264. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34265. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34266. * @param analyser The analyser to connect to the engine
  34267. */
  34268. connectToAnalyser(analyser: Analyser): void;
  34269. }
  34270. }
  34271. declare module "babylonjs/Audio/audioSceneComponent" {
  34272. import { Sound } from "babylonjs/Audio/sound";
  34273. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34274. import { Nullable } from "babylonjs/types";
  34275. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34276. import { Scene } from "babylonjs/scene";
  34277. import { AbstractScene } from "babylonjs/abstractScene";
  34278. module "babylonjs/abstractScene" {
  34279. interface AbstractScene {
  34280. /**
  34281. * The list of sounds used in the scene.
  34282. */
  34283. sounds: Nullable<Array<Sound>>;
  34284. }
  34285. }
  34286. module "babylonjs/scene" {
  34287. interface Scene {
  34288. /**
  34289. * @hidden
  34290. * Backing field
  34291. */
  34292. _mainSoundTrack: SoundTrack;
  34293. /**
  34294. * The main sound track played by the scene.
  34295. * It cotains your primary collection of sounds.
  34296. */
  34297. mainSoundTrack: SoundTrack;
  34298. /**
  34299. * The list of sound tracks added to the scene
  34300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34301. */
  34302. soundTracks: Nullable<Array<SoundTrack>>;
  34303. /**
  34304. * Gets a sound using a given name
  34305. * @param name defines the name to search for
  34306. * @return the found sound or null if not found at all.
  34307. */
  34308. getSoundByName(name: string): Nullable<Sound>;
  34309. /**
  34310. * Gets or sets if audio support is enabled
  34311. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34312. */
  34313. audioEnabled: boolean;
  34314. /**
  34315. * Gets or sets if audio will be output to headphones
  34316. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34317. */
  34318. headphone: boolean;
  34319. }
  34320. }
  34321. /**
  34322. * Defines the sound scene component responsible to manage any sounds
  34323. * in a given scene.
  34324. */
  34325. export class AudioSceneComponent implements ISceneSerializableComponent {
  34326. /**
  34327. * The component name helpfull to identify the component in the list of scene components.
  34328. */
  34329. readonly name: string;
  34330. /**
  34331. * The scene the component belongs to.
  34332. */
  34333. scene: Scene;
  34334. private _audioEnabled;
  34335. /**
  34336. * Gets whether audio is enabled or not.
  34337. * Please use related enable/disable method to switch state.
  34338. */
  34339. readonly audioEnabled: boolean;
  34340. private _headphone;
  34341. /**
  34342. * Gets whether audio is outputing to headphone or not.
  34343. * Please use the according Switch methods to change output.
  34344. */
  34345. readonly headphone: boolean;
  34346. /**
  34347. * Creates a new instance of the component for the given scene
  34348. * @param scene Defines the scene to register the component in
  34349. */
  34350. constructor(scene: Scene);
  34351. /**
  34352. * Registers the component in a given scene
  34353. */
  34354. register(): void;
  34355. /**
  34356. * Rebuilds the elements related to this component in case of
  34357. * context lost for instance.
  34358. */
  34359. rebuild(): void;
  34360. /**
  34361. * Serializes the component data to the specified json object
  34362. * @param serializationObject The object to serialize to
  34363. */
  34364. serialize(serializationObject: any): void;
  34365. /**
  34366. * Adds all the element from the container to the scene
  34367. * @param container the container holding the elements
  34368. */
  34369. addFromContainer(container: AbstractScene): void;
  34370. /**
  34371. * Removes all the elements in the container from the scene
  34372. * @param container contains the elements to remove
  34373. */
  34374. removeFromContainer(container: AbstractScene): void;
  34375. /**
  34376. * Disposes the component and the associated ressources.
  34377. */
  34378. dispose(): void;
  34379. /**
  34380. * Disables audio in the associated scene.
  34381. */
  34382. disableAudio(): void;
  34383. /**
  34384. * Enables audio in the associated scene.
  34385. */
  34386. enableAudio(): void;
  34387. /**
  34388. * Switch audio to headphone output.
  34389. */
  34390. switchAudioModeForHeadphones(): void;
  34391. /**
  34392. * Switch audio to normal speakers.
  34393. */
  34394. switchAudioModeForNormalSpeakers(): void;
  34395. private _afterRender;
  34396. }
  34397. }
  34398. declare module "babylonjs/Audio/weightedsound" {
  34399. import { Sound } from "babylonjs/Audio/sound";
  34400. /**
  34401. * Wraps one or more Sound objects and selects one with random weight for playback.
  34402. */
  34403. export class WeightedSound {
  34404. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34405. loop: boolean;
  34406. private _coneInnerAngle;
  34407. private _coneOuterAngle;
  34408. private _volume;
  34409. /** A Sound is currently playing. */
  34410. isPlaying: boolean;
  34411. /** A Sound is currently paused. */
  34412. isPaused: boolean;
  34413. private _sounds;
  34414. private _weights;
  34415. private _currentIndex?;
  34416. /**
  34417. * Creates a new WeightedSound from the list of sounds given.
  34418. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34419. * @param sounds Array of Sounds that will be selected from.
  34420. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34421. */
  34422. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34423. /**
  34424. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34425. */
  34426. /**
  34427. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34428. */
  34429. directionalConeInnerAngle: number;
  34430. /**
  34431. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34432. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34433. */
  34434. /**
  34435. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34436. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34437. */
  34438. directionalConeOuterAngle: number;
  34439. /**
  34440. * Playback volume.
  34441. */
  34442. /**
  34443. * Playback volume.
  34444. */
  34445. volume: number;
  34446. private _onended;
  34447. /**
  34448. * Suspend playback
  34449. */
  34450. pause(): void;
  34451. /**
  34452. * Stop playback
  34453. */
  34454. stop(): void;
  34455. /**
  34456. * Start playback.
  34457. * @param startOffset Position the clip head at a specific time in seconds.
  34458. */
  34459. play(startOffset?: number): void;
  34460. }
  34461. }
  34462. declare module "babylonjs/Audio/index" {
  34463. export * from "babylonjs/Audio/analyser";
  34464. export * from "babylonjs/Audio/audioEngine";
  34465. export * from "babylonjs/Audio/audioSceneComponent";
  34466. export * from "babylonjs/Audio/sound";
  34467. export * from "babylonjs/Audio/soundTrack";
  34468. export * from "babylonjs/Audio/weightedsound";
  34469. }
  34470. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34471. import { Behavior } from "babylonjs/Behaviors/behavior";
  34472. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34473. import { BackEase } from "babylonjs/Animations/easing";
  34474. /**
  34475. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34476. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34477. */
  34478. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34479. /**
  34480. * Gets the name of the behavior.
  34481. */
  34482. readonly name: string;
  34483. /**
  34484. * The easing function used by animations
  34485. */
  34486. static EasingFunction: BackEase;
  34487. /**
  34488. * The easing mode used by animations
  34489. */
  34490. static EasingMode: number;
  34491. /**
  34492. * The duration of the animation, in milliseconds
  34493. */
  34494. transitionDuration: number;
  34495. /**
  34496. * Length of the distance animated by the transition when lower radius is reached
  34497. */
  34498. lowerRadiusTransitionRange: number;
  34499. /**
  34500. * Length of the distance animated by the transition when upper radius is reached
  34501. */
  34502. upperRadiusTransitionRange: number;
  34503. private _autoTransitionRange;
  34504. /**
  34505. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34506. */
  34507. /**
  34508. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34509. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34510. */
  34511. autoTransitionRange: boolean;
  34512. private _attachedCamera;
  34513. private _onAfterCheckInputsObserver;
  34514. private _onMeshTargetChangedObserver;
  34515. /**
  34516. * Initializes the behavior.
  34517. */
  34518. init(): void;
  34519. /**
  34520. * Attaches the behavior to its arc rotate camera.
  34521. * @param camera Defines the camera to attach the behavior to
  34522. */
  34523. attach(camera: ArcRotateCamera): void;
  34524. /**
  34525. * Detaches the behavior from its current arc rotate camera.
  34526. */
  34527. detach(): void;
  34528. private _radiusIsAnimating;
  34529. private _radiusBounceTransition;
  34530. private _animatables;
  34531. private _cachedWheelPrecision;
  34532. /**
  34533. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34534. * @param radiusLimit The limit to check against.
  34535. * @return Bool to indicate if at limit.
  34536. */
  34537. private _isRadiusAtLimit;
  34538. /**
  34539. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34540. * @param radiusDelta The delta by which to animate to. Can be negative.
  34541. */
  34542. private _applyBoundRadiusAnimation;
  34543. /**
  34544. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34545. */
  34546. protected _clearAnimationLocks(): void;
  34547. /**
  34548. * Stops and removes all animations that have been applied to the camera
  34549. */
  34550. stopAllAnimations(): void;
  34551. }
  34552. }
  34553. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34554. import { Behavior } from "babylonjs/Behaviors/behavior";
  34555. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34556. import { ExponentialEase } from "babylonjs/Animations/easing";
  34557. import { Nullable } from "babylonjs/types";
  34558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34559. import { Vector3 } from "babylonjs/Maths/math";
  34560. /**
  34561. * 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.
  34562. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34563. */
  34564. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34565. /**
  34566. * Gets the name of the behavior.
  34567. */
  34568. readonly name: string;
  34569. private _mode;
  34570. private _radiusScale;
  34571. private _positionScale;
  34572. private _defaultElevation;
  34573. private _elevationReturnTime;
  34574. private _elevationReturnWaitTime;
  34575. private _zoomStopsAnimation;
  34576. private _framingTime;
  34577. /**
  34578. * The easing function used by animations
  34579. */
  34580. static EasingFunction: ExponentialEase;
  34581. /**
  34582. * The easing mode used by animations
  34583. */
  34584. static EasingMode: number;
  34585. /**
  34586. * Sets the current mode used by the behavior
  34587. */
  34588. /**
  34589. * Gets current mode used by the behavior.
  34590. */
  34591. mode: number;
  34592. /**
  34593. * Sets the scale applied to the radius (1 by default)
  34594. */
  34595. /**
  34596. * Gets the scale applied to the radius
  34597. */
  34598. radiusScale: number;
  34599. /**
  34600. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34601. */
  34602. /**
  34603. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34604. */
  34605. positionScale: number;
  34606. /**
  34607. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34608. * behaviour is triggered, in radians.
  34609. */
  34610. /**
  34611. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34612. * behaviour is triggered, in radians.
  34613. */
  34614. defaultElevation: number;
  34615. /**
  34616. * Sets the time (in milliseconds) taken to return to the default beta position.
  34617. * Negative value indicates camera should not return to default.
  34618. */
  34619. /**
  34620. * Gets the time (in milliseconds) taken to return to the default beta position.
  34621. * Negative value indicates camera should not return to default.
  34622. */
  34623. elevationReturnTime: number;
  34624. /**
  34625. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34626. */
  34627. /**
  34628. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34629. */
  34630. elevationReturnWaitTime: number;
  34631. /**
  34632. * Sets the flag that indicates if user zooming should stop animation.
  34633. */
  34634. /**
  34635. * Gets the flag that indicates if user zooming should stop animation.
  34636. */
  34637. zoomStopsAnimation: boolean;
  34638. /**
  34639. * Sets the transition time when framing the mesh, in milliseconds
  34640. */
  34641. /**
  34642. * Gets the transition time when framing the mesh, in milliseconds
  34643. */
  34644. framingTime: number;
  34645. /**
  34646. * Define if the behavior should automatically change the configured
  34647. * camera limits and sensibilities.
  34648. */
  34649. autoCorrectCameraLimitsAndSensibility: boolean;
  34650. private _onPrePointerObservableObserver;
  34651. private _onAfterCheckInputsObserver;
  34652. private _onMeshTargetChangedObserver;
  34653. private _attachedCamera;
  34654. private _isPointerDown;
  34655. private _lastInteractionTime;
  34656. /**
  34657. * Initializes the behavior.
  34658. */
  34659. init(): void;
  34660. /**
  34661. * Attaches the behavior to its arc rotate camera.
  34662. * @param camera Defines the camera to attach the behavior to
  34663. */
  34664. attach(camera: ArcRotateCamera): void;
  34665. /**
  34666. * Detaches the behavior from its current arc rotate camera.
  34667. */
  34668. detach(): void;
  34669. private _animatables;
  34670. private _betaIsAnimating;
  34671. private _betaTransition;
  34672. private _radiusTransition;
  34673. private _vectorTransition;
  34674. /**
  34675. * Targets the given mesh and updates zoom level accordingly.
  34676. * @param mesh The mesh to target.
  34677. * @param radius Optional. If a cached radius position already exists, overrides default.
  34678. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34679. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34680. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34681. */
  34682. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34683. /**
  34684. * Targets the given mesh with its children and updates zoom level accordingly.
  34685. * @param mesh The mesh to target.
  34686. * @param radius Optional. If a cached radius position already exists, overrides default.
  34687. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34688. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34689. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34690. */
  34691. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34692. /**
  34693. * Targets the given meshes with their children and updates zoom level accordingly.
  34694. * @param meshes The mesh to target.
  34695. * @param radius Optional. If a cached radius position already exists, overrides default.
  34696. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34697. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34698. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34699. */
  34700. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34701. /**
  34702. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34703. * @param minimumWorld Determines the smaller position of the bounding box extend
  34704. * @param maximumWorld Determines the bigger position of the bounding box extend
  34705. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34706. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34707. */
  34708. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34709. /**
  34710. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34711. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34712. * frustum width.
  34713. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34714. * to fully enclose the mesh in the viewing frustum.
  34715. */
  34716. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34717. /**
  34718. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34719. * is automatically returned to its default position (expected to be above ground plane).
  34720. */
  34721. private _maintainCameraAboveGround;
  34722. /**
  34723. * Returns the frustum slope based on the canvas ratio and camera FOV
  34724. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34725. */
  34726. private _getFrustumSlope;
  34727. /**
  34728. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34729. */
  34730. private _clearAnimationLocks;
  34731. /**
  34732. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34733. */
  34734. private _applyUserInteraction;
  34735. /**
  34736. * Stops and removes all animations that have been applied to the camera
  34737. */
  34738. stopAllAnimations(): void;
  34739. /**
  34740. * Gets a value indicating if the user is moving the camera
  34741. */
  34742. readonly isUserIsMoving: boolean;
  34743. /**
  34744. * The camera can move all the way towards the mesh.
  34745. */
  34746. static IgnoreBoundsSizeMode: number;
  34747. /**
  34748. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34749. */
  34750. static FitFrustumSidesMode: number;
  34751. }
  34752. }
  34753. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  34754. import { Nullable } from "babylonjs/types";
  34755. import { Camera } from "babylonjs/Cameras/camera";
  34756. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34757. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34758. /**
  34759. * Base class for Camera Pointer Inputs.
  34760. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34761. * for example usage.
  34762. */
  34763. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34764. /**
  34765. * Defines the camera the input is attached to.
  34766. */
  34767. abstract camera: Camera;
  34768. /**
  34769. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34770. */
  34771. protected _altKey: boolean;
  34772. protected _ctrlKey: boolean;
  34773. protected _metaKey: boolean;
  34774. protected _shiftKey: boolean;
  34775. /**
  34776. * Which mouse buttons were pressed at time of last mouse event.
  34777. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34778. */
  34779. protected _buttonsPressed: number;
  34780. /**
  34781. * Defines the buttons associated with the input to handle camera move.
  34782. */
  34783. buttons: number[];
  34784. /**
  34785. * Attach the input controls to a specific dom element to get the input from.
  34786. * @param element Defines the element the controls should be listened from
  34787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34788. */
  34789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34790. /**
  34791. * Detach the current controls from the specified dom element.
  34792. * @param element Defines the element to stop listening the inputs from
  34793. */
  34794. detachControl(element: Nullable<HTMLElement>): void;
  34795. /**
  34796. * Gets the class name of the current input.
  34797. * @returns the class name
  34798. */
  34799. getClassName(): string;
  34800. /**
  34801. * Get the friendly name associated with the input class.
  34802. * @returns the input friendly name
  34803. */
  34804. getSimpleName(): string;
  34805. /**
  34806. * Called on pointer POINTERDOUBLETAP event.
  34807. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34808. */
  34809. protected onDoubleTap(type: string): void;
  34810. /**
  34811. * Called on pointer POINTERMOVE event if only a single touch is active.
  34812. * Override this method to provide functionality.
  34813. */
  34814. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34815. /**
  34816. * Called on pointer POINTERMOVE event if multiple touches are active.
  34817. * Override this method to provide functionality.
  34818. */
  34819. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34820. /**
  34821. * Called on JS contextmenu event.
  34822. * Override this method to provide functionality.
  34823. */
  34824. protected onContextMenu(evt: PointerEvent): void;
  34825. /**
  34826. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34827. * press.
  34828. * Override this method to provide functionality.
  34829. */
  34830. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34831. /**
  34832. * Called each time a new POINTERUP event occurs. Ie, for each button
  34833. * release.
  34834. * Override this method to provide functionality.
  34835. */
  34836. protected onButtonUp(evt: PointerEvent): void;
  34837. /**
  34838. * Called when window becomes inactive.
  34839. * Override this method to provide functionality.
  34840. */
  34841. protected onLostFocus(): void;
  34842. private _pointerInput;
  34843. private _observer;
  34844. private _onLostFocus;
  34845. }
  34846. }
  34847. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  34848. import { Nullable } from "babylonjs/types";
  34849. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34850. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  34851. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34852. /**
  34853. * Manage the pointers inputs to control an arc rotate camera.
  34854. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34855. */
  34856. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34857. /**
  34858. * Defines the camera the input is attached to.
  34859. */
  34860. camera: ArcRotateCamera;
  34861. /**
  34862. * Gets the class name of the current input.
  34863. * @returns the class name
  34864. */
  34865. getClassName(): string;
  34866. /**
  34867. * Defines the buttons associated with the input to handle camera move.
  34868. */
  34869. buttons: number[];
  34870. /**
  34871. * Defines the pointer angular sensibility along the X axis or how fast is
  34872. * the camera rotating.
  34873. */
  34874. angularSensibilityX: number;
  34875. /**
  34876. * Defines the pointer angular sensibility along the Y axis or how fast is
  34877. * the camera rotating.
  34878. */
  34879. angularSensibilityY: number;
  34880. /**
  34881. * Defines the pointer pinch precision or how fast is the camera zooming.
  34882. */
  34883. pinchPrecision: number;
  34884. /**
  34885. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34886. * from 0.
  34887. * It defines the percentage of current camera.radius to use as delta when
  34888. * pinch zoom is used.
  34889. */
  34890. pinchDeltaPercentage: number;
  34891. /**
  34892. * Defines the pointer panning sensibility or how fast is the camera moving.
  34893. */
  34894. panningSensibility: number;
  34895. /**
  34896. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34897. */
  34898. multiTouchPanning: boolean;
  34899. /**
  34900. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34901. * zoom (pinch) through multitouch.
  34902. */
  34903. multiTouchPanAndZoom: boolean;
  34904. /**
  34905. * Revers pinch action direction.
  34906. */
  34907. pinchInwards: boolean;
  34908. private _isPanClick;
  34909. private _twoFingerActivityCount;
  34910. private _isPinching;
  34911. /**
  34912. * Called on pointer POINTERMOVE event if only a single touch is active.
  34913. */
  34914. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34915. /**
  34916. * Called on pointer POINTERDOUBLETAP event.
  34917. */
  34918. protected onDoubleTap(type: string): void;
  34919. /**
  34920. * Called on pointer POINTERMOVE event if multiple touches are active.
  34921. */
  34922. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34923. /**
  34924. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34925. * press.
  34926. */
  34927. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34928. /**
  34929. * Called each time a new POINTERUP event occurs. Ie, for each button
  34930. * release.
  34931. */
  34932. protected onButtonUp(evt: PointerEvent): void;
  34933. /**
  34934. * Called when window becomes inactive.
  34935. */
  34936. protected onLostFocus(): void;
  34937. }
  34938. }
  34939. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  34940. import { Nullable } from "babylonjs/types";
  34941. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34942. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34943. /**
  34944. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34945. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34946. */
  34947. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34948. /**
  34949. * Defines the camera the input is attached to.
  34950. */
  34951. camera: ArcRotateCamera;
  34952. /**
  34953. * Defines the list of key codes associated with the up action (increase alpha)
  34954. */
  34955. keysUp: number[];
  34956. /**
  34957. * Defines the list of key codes associated with the down action (decrease alpha)
  34958. */
  34959. keysDown: number[];
  34960. /**
  34961. * Defines the list of key codes associated with the left action (increase beta)
  34962. */
  34963. keysLeft: number[];
  34964. /**
  34965. * Defines the list of key codes associated with the right action (decrease beta)
  34966. */
  34967. keysRight: number[];
  34968. /**
  34969. * Defines the list of key codes associated with the reset action.
  34970. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34971. */
  34972. keysReset: number[];
  34973. /**
  34974. * Defines the panning sensibility of the inputs.
  34975. * (How fast is the camera paning)
  34976. */
  34977. panningSensibility: number;
  34978. /**
  34979. * Defines the zooming sensibility of the inputs.
  34980. * (How fast is the camera zooming)
  34981. */
  34982. zoomingSensibility: number;
  34983. /**
  34984. * Defines wether maintaining the alt key down switch the movement mode from
  34985. * orientation to zoom.
  34986. */
  34987. useAltToZoom: boolean;
  34988. /**
  34989. * Rotation speed of the camera
  34990. */
  34991. angularSpeed: number;
  34992. private _keys;
  34993. private _ctrlPressed;
  34994. private _altPressed;
  34995. private _onCanvasBlurObserver;
  34996. private _onKeyboardObserver;
  34997. private _engine;
  34998. private _scene;
  34999. /**
  35000. * Attach the input controls to a specific dom element to get the input from.
  35001. * @param element Defines the element the controls should be listened from
  35002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35003. */
  35004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35005. /**
  35006. * Detach the current controls from the specified dom element.
  35007. * @param element Defines the element to stop listening the inputs from
  35008. */
  35009. detachControl(element: Nullable<HTMLElement>): void;
  35010. /**
  35011. * Update the current camera state depending on the inputs that have been used this frame.
  35012. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35013. */
  35014. checkInputs(): void;
  35015. /**
  35016. * Gets the class name of the current intput.
  35017. * @returns the class name
  35018. */
  35019. getClassName(): string;
  35020. /**
  35021. * Get the friendly name associated with the input class.
  35022. * @returns the input friendly name
  35023. */
  35024. getSimpleName(): string;
  35025. }
  35026. }
  35027. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35028. import { Nullable } from "babylonjs/types";
  35029. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35030. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35031. /**
  35032. * Manage the mouse wheel inputs to control an arc rotate camera.
  35033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35034. */
  35035. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35036. /**
  35037. * Defines the camera the input is attached to.
  35038. */
  35039. camera: ArcRotateCamera;
  35040. /**
  35041. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35042. */
  35043. wheelPrecision: number;
  35044. /**
  35045. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35046. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35047. */
  35048. wheelDeltaPercentage: number;
  35049. private _wheel;
  35050. private _observer;
  35051. /**
  35052. * Attach the input controls to a specific dom element to get the input from.
  35053. * @param element Defines the element the controls should be listened from
  35054. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35055. */
  35056. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35057. /**
  35058. * Detach the current controls from the specified dom element.
  35059. * @param element Defines the element to stop listening the inputs from
  35060. */
  35061. detachControl(element: Nullable<HTMLElement>): void;
  35062. /**
  35063. * Gets the class name of the current intput.
  35064. * @returns the class name
  35065. */
  35066. getClassName(): string;
  35067. /**
  35068. * Get the friendly name associated with the input class.
  35069. * @returns the input friendly name
  35070. */
  35071. getSimpleName(): string;
  35072. }
  35073. }
  35074. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35075. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35076. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35077. /**
  35078. * Default Inputs manager for the ArcRotateCamera.
  35079. * It groups all the default supported inputs for ease of use.
  35080. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35081. */
  35082. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35083. /**
  35084. * Instantiates a new ArcRotateCameraInputsManager.
  35085. * @param camera Defines the camera the inputs belong to
  35086. */
  35087. constructor(camera: ArcRotateCamera);
  35088. /**
  35089. * Add mouse wheel input support to the input manager.
  35090. * @returns the current input manager
  35091. */
  35092. addMouseWheel(): ArcRotateCameraInputsManager;
  35093. /**
  35094. * Add pointers input support to the input manager.
  35095. * @returns the current input manager
  35096. */
  35097. addPointers(): ArcRotateCameraInputsManager;
  35098. /**
  35099. * Add keyboard input support to the input manager.
  35100. * @returns the current input manager
  35101. */
  35102. addKeyboard(): ArcRotateCameraInputsManager;
  35103. }
  35104. }
  35105. declare module "babylonjs/Cameras/arcRotateCamera" {
  35106. import { Observable } from "babylonjs/Misc/observable";
  35107. import { Nullable } from "babylonjs/types";
  35108. import { Scene } from "babylonjs/scene";
  35109. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35110. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35111. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35112. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35113. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35114. import { Camera } from "babylonjs/Cameras/camera";
  35115. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35116. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35117. import { Collider } from "babylonjs/Collisions/collider";
  35118. /**
  35119. * This represents an orbital type of camera.
  35120. *
  35121. * 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.
  35122. * 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.
  35123. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35124. */
  35125. export class ArcRotateCamera extends TargetCamera {
  35126. /**
  35127. * Defines the rotation angle of the camera along the longitudinal axis.
  35128. */
  35129. alpha: number;
  35130. /**
  35131. * Defines the rotation angle of the camera along the latitudinal axis.
  35132. */
  35133. beta: number;
  35134. /**
  35135. * Defines the radius of the camera from it s target point.
  35136. */
  35137. radius: number;
  35138. protected _target: Vector3;
  35139. protected _targetHost: Nullable<AbstractMesh>;
  35140. /**
  35141. * Defines the target point of the camera.
  35142. * The camera looks towards it form the radius distance.
  35143. */
  35144. target: Vector3;
  35145. /**
  35146. * Define the current local position of the camera in the scene
  35147. */
  35148. position: Vector3;
  35149. /**
  35150. * Current inertia value on the longitudinal axis.
  35151. * The bigger this number the longer it will take for the camera to stop.
  35152. */
  35153. inertialAlphaOffset: number;
  35154. /**
  35155. * Current inertia value on the latitudinal axis.
  35156. * The bigger this number the longer it will take for the camera to stop.
  35157. */
  35158. inertialBetaOffset: number;
  35159. /**
  35160. * Current inertia value on the radius axis.
  35161. * The bigger this number the longer it will take for the camera to stop.
  35162. */
  35163. inertialRadiusOffset: number;
  35164. /**
  35165. * Minimum allowed angle on the longitudinal axis.
  35166. * This can help limiting how the Camera is able to move in the scene.
  35167. */
  35168. lowerAlphaLimit: Nullable<number>;
  35169. /**
  35170. * Maximum allowed angle on the longitudinal axis.
  35171. * This can help limiting how the Camera is able to move in the scene.
  35172. */
  35173. upperAlphaLimit: Nullable<number>;
  35174. /**
  35175. * Minimum allowed angle on the latitudinal axis.
  35176. * This can help limiting how the Camera is able to move in the scene.
  35177. */
  35178. lowerBetaLimit: number;
  35179. /**
  35180. * Maximum allowed angle on the latitudinal axis.
  35181. * This can help limiting how the Camera is able to move in the scene.
  35182. */
  35183. upperBetaLimit: number;
  35184. /**
  35185. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35186. * This can help limiting how the Camera is able to move in the scene.
  35187. */
  35188. lowerRadiusLimit: Nullable<number>;
  35189. /**
  35190. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35191. * This can help limiting how the Camera is able to move in the scene.
  35192. */
  35193. upperRadiusLimit: Nullable<number>;
  35194. /**
  35195. * Defines the current inertia value used during panning of the camera along the X axis.
  35196. */
  35197. inertialPanningX: number;
  35198. /**
  35199. * Defines the current inertia value used during panning of the camera along the Y axis.
  35200. */
  35201. inertialPanningY: number;
  35202. /**
  35203. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35204. * Basically if your fingers moves away from more than this distance you will be considered
  35205. * in pinch mode.
  35206. */
  35207. pinchToPanMaxDistance: number;
  35208. /**
  35209. * Defines the maximum distance the camera can pan.
  35210. * This could help keeping the cammera always in your scene.
  35211. */
  35212. panningDistanceLimit: Nullable<number>;
  35213. /**
  35214. * Defines the target of the camera before paning.
  35215. */
  35216. panningOriginTarget: Vector3;
  35217. /**
  35218. * Defines the value of the inertia used during panning.
  35219. * 0 would mean stop inertia and one would mean no decelleration at all.
  35220. */
  35221. panningInertia: number;
  35222. /**
  35223. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35224. */
  35225. angularSensibilityX: number;
  35226. /**
  35227. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35228. */
  35229. angularSensibilityY: number;
  35230. /**
  35231. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35232. */
  35233. pinchPrecision: number;
  35234. /**
  35235. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35236. * It will be used instead of pinchDeltaPrecision if different from 0.
  35237. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35238. */
  35239. pinchDeltaPercentage: number;
  35240. /**
  35241. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35242. */
  35243. panningSensibility: number;
  35244. /**
  35245. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35246. */
  35247. keysUp: number[];
  35248. /**
  35249. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35250. */
  35251. keysDown: number[];
  35252. /**
  35253. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35254. */
  35255. keysLeft: number[];
  35256. /**
  35257. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35258. */
  35259. keysRight: number[];
  35260. /**
  35261. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35262. */
  35263. wheelPrecision: number;
  35264. /**
  35265. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35266. * It will be used instead of pinchDeltaPrecision if different from 0.
  35267. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35268. */
  35269. wheelDeltaPercentage: number;
  35270. /**
  35271. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35272. */
  35273. zoomOnFactor: number;
  35274. /**
  35275. * Defines a screen offset for the camera position.
  35276. */
  35277. targetScreenOffset: Vector2;
  35278. /**
  35279. * Allows the camera to be completely reversed.
  35280. * If false the camera can not arrive upside down.
  35281. */
  35282. allowUpsideDown: boolean;
  35283. /**
  35284. * Define if double tap/click is used to restore the previously saved state of the camera.
  35285. */
  35286. useInputToRestoreState: boolean;
  35287. /** @hidden */
  35288. _viewMatrix: Matrix;
  35289. /** @hidden */
  35290. _useCtrlForPanning: boolean;
  35291. /** @hidden */
  35292. _panningMouseButton: number;
  35293. /**
  35294. * Defines the input associated to the camera.
  35295. */
  35296. inputs: ArcRotateCameraInputsManager;
  35297. /** @hidden */
  35298. _reset: () => void;
  35299. /**
  35300. * Defines the allowed panning axis.
  35301. */
  35302. panningAxis: Vector3;
  35303. protected _localDirection: Vector3;
  35304. protected _transformedDirection: Vector3;
  35305. private _bouncingBehavior;
  35306. /**
  35307. * Gets the bouncing behavior of the camera if it has been enabled.
  35308. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35309. */
  35310. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35311. /**
  35312. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35313. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35314. */
  35315. useBouncingBehavior: boolean;
  35316. private _framingBehavior;
  35317. /**
  35318. * Gets the framing behavior of the camera if it has been enabled.
  35319. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35320. */
  35321. readonly framingBehavior: Nullable<FramingBehavior>;
  35322. /**
  35323. * Defines if the framing behavior of the camera is enabled on the camera.
  35324. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35325. */
  35326. useFramingBehavior: boolean;
  35327. private _autoRotationBehavior;
  35328. /**
  35329. * Gets the auto rotation behavior of the camera if it has been enabled.
  35330. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35331. */
  35332. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35333. /**
  35334. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35335. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35336. */
  35337. useAutoRotationBehavior: boolean;
  35338. /**
  35339. * Observable triggered when the mesh target has been changed on the camera.
  35340. */
  35341. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35342. /**
  35343. * Event raised when the camera is colliding with a mesh.
  35344. */
  35345. onCollide: (collidedMesh: AbstractMesh) => void;
  35346. /**
  35347. * Defines whether the camera should check collision with the objects oh the scene.
  35348. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35349. */
  35350. checkCollisions: boolean;
  35351. /**
  35352. * Defines the collision radius of the camera.
  35353. * This simulates a sphere around the camera.
  35354. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35355. */
  35356. collisionRadius: Vector3;
  35357. protected _collider: Collider;
  35358. protected _previousPosition: Vector3;
  35359. protected _collisionVelocity: Vector3;
  35360. protected _newPosition: Vector3;
  35361. protected _previousAlpha: number;
  35362. protected _previousBeta: number;
  35363. protected _previousRadius: number;
  35364. protected _collisionTriggered: boolean;
  35365. protected _targetBoundingCenter: Nullable<Vector3>;
  35366. private _computationVector;
  35367. private _tempAxisVector;
  35368. private _tempAxisRotationMatrix;
  35369. /**
  35370. * Instantiates a new ArcRotateCamera in a given scene
  35371. * @param name Defines the name of the camera
  35372. * @param alpha Defines the camera rotation along the logitudinal axis
  35373. * @param beta Defines the camera rotation along the latitudinal axis
  35374. * @param radius Defines the camera distance from its target
  35375. * @param target Defines the camera target
  35376. * @param scene Defines the scene the camera belongs to
  35377. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35378. */
  35379. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35380. /** @hidden */
  35381. _initCache(): void;
  35382. /** @hidden */
  35383. _updateCache(ignoreParentClass?: boolean): void;
  35384. protected _getTargetPosition(): Vector3;
  35385. private _storedAlpha;
  35386. private _storedBeta;
  35387. private _storedRadius;
  35388. private _storedTarget;
  35389. /**
  35390. * Stores the current state of the camera (alpha, beta, radius and target)
  35391. * @returns the camera itself
  35392. */
  35393. storeState(): Camera;
  35394. /**
  35395. * @hidden
  35396. * Restored camera state. You must call storeState() first
  35397. */
  35398. _restoreStateValues(): boolean;
  35399. /** @hidden */
  35400. _isSynchronizedViewMatrix(): boolean;
  35401. /**
  35402. * Attached controls to the current camera.
  35403. * @param element Defines the element the controls should be listened from
  35404. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35405. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35406. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35407. */
  35408. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35409. /**
  35410. * Detach the current controls from the camera.
  35411. * The camera will stop reacting to inputs.
  35412. * @param element Defines the element to stop listening the inputs from
  35413. */
  35414. detachControl(element: HTMLElement): void;
  35415. /** @hidden */
  35416. _checkInputs(): void;
  35417. protected _checkLimits(): void;
  35418. /**
  35419. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35420. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35421. */
  35422. rebuildAnglesAndRadius(updateView?: boolean): void;
  35423. /**
  35424. * Use a position to define the current camera related information like aplha, beta and radius
  35425. * @param position Defines the position to set the camera at
  35426. */
  35427. setPosition(position: Vector3): void;
  35428. /**
  35429. * Defines the target the camera should look at.
  35430. * This will automatically adapt alpha beta and radius to fit within the new target.
  35431. * @param target Defines the new target as a Vector or a mesh
  35432. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35433. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35434. */
  35435. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35436. /** @hidden */
  35437. _getViewMatrix(): Matrix;
  35438. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35439. /**
  35440. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35441. * @param meshes Defines the mesh to zoom on
  35442. * @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)
  35443. */
  35444. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35445. /**
  35446. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35447. * The target will be changed but the radius
  35448. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35449. * @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)
  35450. */
  35451. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35452. min: Vector3;
  35453. max: Vector3;
  35454. distance: number;
  35455. }, doNotUpdateMaxZ?: boolean): void;
  35456. /**
  35457. * @override
  35458. * Override Camera.createRigCamera
  35459. */
  35460. createRigCamera(name: string, cameraIndex: number): Camera;
  35461. /**
  35462. * @hidden
  35463. * @override
  35464. * Override Camera._updateRigCameras
  35465. */
  35466. _updateRigCameras(): void;
  35467. /**
  35468. * Destroy the camera and release the current resources hold by it.
  35469. */
  35470. dispose(): void;
  35471. /**
  35472. * Gets the current object class name.
  35473. * @return the class name
  35474. */
  35475. getClassName(): string;
  35476. }
  35477. }
  35478. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35479. import { Behavior } from "babylonjs/Behaviors/behavior";
  35480. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35481. /**
  35482. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35483. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35484. */
  35485. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35486. /**
  35487. * Gets the name of the behavior.
  35488. */
  35489. readonly name: string;
  35490. private _zoomStopsAnimation;
  35491. private _idleRotationSpeed;
  35492. private _idleRotationWaitTime;
  35493. private _idleRotationSpinupTime;
  35494. /**
  35495. * Sets the flag that indicates if user zooming should stop animation.
  35496. */
  35497. /**
  35498. * Gets the flag that indicates if user zooming should stop animation.
  35499. */
  35500. zoomStopsAnimation: boolean;
  35501. /**
  35502. * Sets the default speed at which the camera rotates around the model.
  35503. */
  35504. /**
  35505. * Gets the default speed at which the camera rotates around the model.
  35506. */
  35507. idleRotationSpeed: number;
  35508. /**
  35509. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35510. */
  35511. /**
  35512. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35513. */
  35514. idleRotationWaitTime: number;
  35515. /**
  35516. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35517. */
  35518. /**
  35519. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35520. */
  35521. idleRotationSpinupTime: number;
  35522. /**
  35523. * Gets a value indicating if the camera is currently rotating because of this behavior
  35524. */
  35525. readonly rotationInProgress: boolean;
  35526. private _onPrePointerObservableObserver;
  35527. private _onAfterCheckInputsObserver;
  35528. private _attachedCamera;
  35529. private _isPointerDown;
  35530. private _lastFrameTime;
  35531. private _lastInteractionTime;
  35532. private _cameraRotationSpeed;
  35533. /**
  35534. * Initializes the behavior.
  35535. */
  35536. init(): void;
  35537. /**
  35538. * Attaches the behavior to its arc rotate camera.
  35539. * @param camera Defines the camera to attach the behavior to
  35540. */
  35541. attach(camera: ArcRotateCamera): void;
  35542. /**
  35543. * Detaches the behavior from its current arc rotate camera.
  35544. */
  35545. detach(): void;
  35546. /**
  35547. * Returns true if user is scrolling.
  35548. * @return true if user is scrolling.
  35549. */
  35550. private _userIsZooming;
  35551. private _lastFrameRadius;
  35552. private _shouldAnimationStopForInteraction;
  35553. /**
  35554. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35555. */
  35556. private _applyUserInteraction;
  35557. private _userIsMoving;
  35558. }
  35559. }
  35560. declare module "babylonjs/Behaviors/Cameras/index" {
  35561. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35562. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35563. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35564. }
  35565. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35566. import { Mesh } from "babylonjs/Meshes/mesh";
  35567. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35568. import { Behavior } from "babylonjs/Behaviors/behavior";
  35569. /**
  35570. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35571. */
  35572. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35573. private ui;
  35574. /**
  35575. * The name of the behavior
  35576. */
  35577. name: string;
  35578. /**
  35579. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35580. */
  35581. distanceAwayFromFace: number;
  35582. /**
  35583. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35584. */
  35585. distanceAwayFromBottomOfFace: number;
  35586. private _faceVectors;
  35587. private _target;
  35588. private _scene;
  35589. private _onRenderObserver;
  35590. private _tmpMatrix;
  35591. private _tmpVector;
  35592. /**
  35593. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35594. * @param ui The transform node that should be attched to the mesh
  35595. */
  35596. constructor(ui: TransformNode);
  35597. /**
  35598. * Initializes the behavior
  35599. */
  35600. init(): void;
  35601. private _closestFace;
  35602. private _zeroVector;
  35603. private _lookAtTmpMatrix;
  35604. private _lookAtToRef;
  35605. /**
  35606. * Attaches the AttachToBoxBehavior to the passed in mesh
  35607. * @param target The mesh that the specified node will be attached to
  35608. */
  35609. attach(target: Mesh): void;
  35610. /**
  35611. * Detaches the behavior from the mesh
  35612. */
  35613. detach(): void;
  35614. }
  35615. }
  35616. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  35617. import { Behavior } from "babylonjs/Behaviors/behavior";
  35618. import { Mesh } from "babylonjs/Meshes/mesh";
  35619. /**
  35620. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35621. */
  35622. export class FadeInOutBehavior implements Behavior<Mesh> {
  35623. /**
  35624. * Time in milliseconds to delay before fading in (Default: 0)
  35625. */
  35626. delay: number;
  35627. /**
  35628. * Time in milliseconds for the mesh to fade in (Default: 300)
  35629. */
  35630. fadeInTime: number;
  35631. private _millisecondsPerFrame;
  35632. private _hovered;
  35633. private _hoverValue;
  35634. private _ownerNode;
  35635. /**
  35636. * Instatiates the FadeInOutBehavior
  35637. */
  35638. constructor();
  35639. /**
  35640. * The name of the behavior
  35641. */
  35642. readonly name: string;
  35643. /**
  35644. * Initializes the behavior
  35645. */
  35646. init(): void;
  35647. /**
  35648. * Attaches the fade behavior on the passed in mesh
  35649. * @param ownerNode The mesh that will be faded in/out once attached
  35650. */
  35651. attach(ownerNode: Mesh): void;
  35652. /**
  35653. * Detaches the behavior from the mesh
  35654. */
  35655. detach(): void;
  35656. /**
  35657. * Triggers the mesh to begin fading in or out
  35658. * @param value if the object should fade in or out (true to fade in)
  35659. */
  35660. fadeIn(value: boolean): void;
  35661. private _update;
  35662. private _setAllVisibility;
  35663. }
  35664. }
  35665. declare module "babylonjs/Misc/pivotTools" {
  35666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35667. /**
  35668. * Class containing a set of static utilities functions for managing Pivots
  35669. * @hidden
  35670. */
  35671. export class PivotTools {
  35672. private static _PivotCached;
  35673. private static _OldPivotPoint;
  35674. private static _PivotTranslation;
  35675. private static _PivotTmpVector;
  35676. /** @hidden */
  35677. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35678. /** @hidden */
  35679. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35680. }
  35681. }
  35682. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  35683. import { Scene } from "babylonjs/scene";
  35684. import { Vector4, Plane } from "babylonjs/Maths/math";
  35685. import { Mesh } from "babylonjs/Meshes/mesh";
  35686. /**
  35687. * Class containing static functions to help procedurally build meshes
  35688. */
  35689. export class PlaneBuilder {
  35690. /**
  35691. * Creates a plane mesh
  35692. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35693. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35694. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35696. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35698. * @param name defines the name of the mesh
  35699. * @param options defines the options used to create the mesh
  35700. * @param scene defines the hosting scene
  35701. * @returns the plane mesh
  35702. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35703. */
  35704. static CreatePlane(name: string, options: {
  35705. size?: number;
  35706. width?: number;
  35707. height?: number;
  35708. sideOrientation?: number;
  35709. frontUVs?: Vector4;
  35710. backUVs?: Vector4;
  35711. updatable?: boolean;
  35712. sourcePlane?: Plane;
  35713. }, scene: Scene): Mesh;
  35714. }
  35715. }
  35716. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  35717. import { Behavior } from "babylonjs/Behaviors/behavior";
  35718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35719. import { Observable } from "babylonjs/Misc/observable";
  35720. import { Vector3 } from "babylonjs/Maths/math";
  35721. import { Ray } from "babylonjs/Culling/ray";
  35722. import "babylonjs/Meshes/Builders/planeBuilder";
  35723. /**
  35724. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35725. */
  35726. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35727. private static _AnyMouseID;
  35728. private _attachedNode;
  35729. private _dragPlane;
  35730. private _scene;
  35731. private _pointerObserver;
  35732. private _beforeRenderObserver;
  35733. private static _planeScene;
  35734. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35735. /**
  35736. * 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)
  35737. */
  35738. maxDragAngle: number;
  35739. /**
  35740. * @hidden
  35741. */
  35742. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35743. /**
  35744. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35745. */
  35746. currentDraggingPointerID: number;
  35747. /**
  35748. * The last position where the pointer hit the drag plane in world space
  35749. */
  35750. lastDragPosition: Vector3;
  35751. /**
  35752. * If the behavior is currently in a dragging state
  35753. */
  35754. dragging: boolean;
  35755. /**
  35756. * 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)
  35757. */
  35758. dragDeltaRatio: number;
  35759. /**
  35760. * If the drag plane orientation should be updated during the dragging (Default: true)
  35761. */
  35762. updateDragPlane: boolean;
  35763. private _debugMode;
  35764. private _moving;
  35765. /**
  35766. * Fires each time the attached mesh is dragged with the pointer
  35767. * * delta between last drag position and current drag position in world space
  35768. * * dragDistance along the drag axis
  35769. * * dragPlaneNormal normal of the current drag plane used during the drag
  35770. * * dragPlanePoint in world space where the drag intersects the drag plane
  35771. */
  35772. onDragObservable: Observable<{
  35773. delta: Vector3;
  35774. dragPlanePoint: Vector3;
  35775. dragPlaneNormal: Vector3;
  35776. dragDistance: number;
  35777. pointerId: number;
  35778. }>;
  35779. /**
  35780. * Fires each time a drag begins (eg. mouse down on mesh)
  35781. */
  35782. onDragStartObservable: Observable<{
  35783. dragPlanePoint: Vector3;
  35784. pointerId: number;
  35785. }>;
  35786. /**
  35787. * Fires each time a drag ends (eg. mouse release after drag)
  35788. */
  35789. onDragEndObservable: Observable<{
  35790. dragPlanePoint: Vector3;
  35791. pointerId: number;
  35792. }>;
  35793. /**
  35794. * If the attached mesh should be moved when dragged
  35795. */
  35796. moveAttached: boolean;
  35797. /**
  35798. * If the drag behavior will react to drag events (Default: true)
  35799. */
  35800. enabled: boolean;
  35801. /**
  35802. * If camera controls should be detached during the drag
  35803. */
  35804. detachCameraControls: boolean;
  35805. /**
  35806. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35807. */
  35808. useObjectOrienationForDragging: boolean;
  35809. private _options;
  35810. /**
  35811. * Creates a pointer drag behavior that can be attached to a mesh
  35812. * @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)
  35813. */
  35814. constructor(options?: {
  35815. dragAxis?: Vector3;
  35816. dragPlaneNormal?: Vector3;
  35817. });
  35818. /**
  35819. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35820. */
  35821. validateDrag: (targetPosition: Vector3) => boolean;
  35822. /**
  35823. * The name of the behavior
  35824. */
  35825. readonly name: string;
  35826. /**
  35827. * Initializes the behavior
  35828. */
  35829. init(): void;
  35830. private _tmpVector;
  35831. private _alternatePickedPoint;
  35832. private _worldDragAxis;
  35833. private _targetPosition;
  35834. private _attachedElement;
  35835. /**
  35836. * Attaches the drag behavior the passed in mesh
  35837. * @param ownerNode The mesh that will be dragged around once attached
  35838. */
  35839. attach(ownerNode: AbstractMesh): void;
  35840. /**
  35841. * Force relase the drag action by code.
  35842. */
  35843. releaseDrag(): void;
  35844. private _startDragRay;
  35845. private _lastPointerRay;
  35846. /**
  35847. * Simulates the start of a pointer drag event on the behavior
  35848. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35849. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35850. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35851. */
  35852. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35853. private _startDrag;
  35854. private _dragDelta;
  35855. private _moveDrag;
  35856. private _pickWithRayOnDragPlane;
  35857. private _pointA;
  35858. private _pointB;
  35859. private _pointC;
  35860. private _lineA;
  35861. private _lineB;
  35862. private _localAxis;
  35863. private _lookAt;
  35864. private _updateDragPlanePosition;
  35865. /**
  35866. * Detaches the behavior from the mesh
  35867. */
  35868. detach(): void;
  35869. }
  35870. }
  35871. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  35872. import { Mesh } from "babylonjs/Meshes/mesh";
  35873. import { Behavior } from "babylonjs/Behaviors/behavior";
  35874. /**
  35875. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35876. */
  35877. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35878. private _dragBehaviorA;
  35879. private _dragBehaviorB;
  35880. private _startDistance;
  35881. private _initialScale;
  35882. private _targetScale;
  35883. private _ownerNode;
  35884. private _sceneRenderObserver;
  35885. /**
  35886. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35887. */
  35888. constructor();
  35889. /**
  35890. * The name of the behavior
  35891. */
  35892. readonly name: string;
  35893. /**
  35894. * Initializes the behavior
  35895. */
  35896. init(): void;
  35897. private _getCurrentDistance;
  35898. /**
  35899. * Attaches the scale behavior the passed in mesh
  35900. * @param ownerNode The mesh that will be scaled around once attached
  35901. */
  35902. attach(ownerNode: Mesh): void;
  35903. /**
  35904. * Detaches the behavior from the mesh
  35905. */
  35906. detach(): void;
  35907. }
  35908. }
  35909. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  35910. import { Behavior } from "babylonjs/Behaviors/behavior";
  35911. import { Mesh } from "babylonjs/Meshes/mesh";
  35912. import { Observable } from "babylonjs/Misc/observable";
  35913. /**
  35914. * 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
  35915. */
  35916. export class SixDofDragBehavior implements Behavior<Mesh> {
  35917. private static _virtualScene;
  35918. private _ownerNode;
  35919. private _sceneRenderObserver;
  35920. private _scene;
  35921. private _targetPosition;
  35922. private _virtualOriginMesh;
  35923. private _virtualDragMesh;
  35924. private _pointerObserver;
  35925. private _moving;
  35926. private _startingOrientation;
  35927. /**
  35928. * 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)
  35929. */
  35930. private zDragFactor;
  35931. /**
  35932. * If the object should rotate to face the drag origin
  35933. */
  35934. rotateDraggedObject: boolean;
  35935. /**
  35936. * If the behavior is currently in a dragging state
  35937. */
  35938. dragging: boolean;
  35939. /**
  35940. * 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)
  35941. */
  35942. dragDeltaRatio: number;
  35943. /**
  35944. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35945. */
  35946. currentDraggingPointerID: number;
  35947. /**
  35948. * If camera controls should be detached during the drag
  35949. */
  35950. detachCameraControls: boolean;
  35951. /**
  35952. * Fires each time a drag starts
  35953. */
  35954. onDragStartObservable: Observable<{}>;
  35955. /**
  35956. * Fires each time a drag ends (eg. mouse release after drag)
  35957. */
  35958. onDragEndObservable: Observable<{}>;
  35959. /**
  35960. * 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
  35961. */
  35962. constructor();
  35963. /**
  35964. * The name of the behavior
  35965. */
  35966. readonly name: string;
  35967. /**
  35968. * Initializes the behavior
  35969. */
  35970. init(): void;
  35971. /**
  35972. * Attaches the scale behavior the passed in mesh
  35973. * @param ownerNode The mesh that will be scaled around once attached
  35974. */
  35975. attach(ownerNode: Mesh): void;
  35976. /**
  35977. * Detaches the behavior from the mesh
  35978. */
  35979. detach(): void;
  35980. }
  35981. }
  35982. declare module "babylonjs/Behaviors/Meshes/index" {
  35983. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  35984. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  35985. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  35986. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  35987. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  35988. }
  35989. declare module "babylonjs/Behaviors/index" {
  35990. export * from "babylonjs/Behaviors/behavior";
  35991. export * from "babylonjs/Behaviors/Cameras/index";
  35992. export * from "babylonjs/Behaviors/Meshes/index";
  35993. }
  35994. declare module "babylonjs/Bones/boneIKController" {
  35995. import { Bone } from "babylonjs/Bones/bone";
  35996. import { Vector3 } from "babylonjs/Maths/math";
  35997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35998. import { Nullable } from "babylonjs/types";
  35999. /**
  36000. * Class used to apply inverse kinematics to bones
  36001. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36002. */
  36003. export class BoneIKController {
  36004. private static _tmpVecs;
  36005. private static _tmpQuat;
  36006. private static _tmpMats;
  36007. /**
  36008. * Gets or sets the target mesh
  36009. */
  36010. targetMesh: AbstractMesh;
  36011. /** Gets or sets the mesh used as pole */
  36012. poleTargetMesh: AbstractMesh;
  36013. /**
  36014. * Gets or sets the bone used as pole
  36015. */
  36016. poleTargetBone: Nullable<Bone>;
  36017. /**
  36018. * Gets or sets the target position
  36019. */
  36020. targetPosition: Vector3;
  36021. /**
  36022. * Gets or sets the pole target position
  36023. */
  36024. poleTargetPosition: Vector3;
  36025. /**
  36026. * Gets or sets the pole target local offset
  36027. */
  36028. poleTargetLocalOffset: Vector3;
  36029. /**
  36030. * Gets or sets the pole angle
  36031. */
  36032. poleAngle: number;
  36033. /**
  36034. * Gets or sets the mesh associated with the controller
  36035. */
  36036. mesh: AbstractMesh;
  36037. /**
  36038. * 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)
  36039. */
  36040. slerpAmount: number;
  36041. private _bone1Quat;
  36042. private _bone1Mat;
  36043. private _bone2Ang;
  36044. private _bone1;
  36045. private _bone2;
  36046. private _bone1Length;
  36047. private _bone2Length;
  36048. private _maxAngle;
  36049. private _maxReach;
  36050. private _rightHandedSystem;
  36051. private _bendAxis;
  36052. private _slerping;
  36053. private _adjustRoll;
  36054. /**
  36055. * Gets or sets maximum allowed angle
  36056. */
  36057. maxAngle: number;
  36058. /**
  36059. * Creates a new BoneIKController
  36060. * @param mesh defines the mesh to control
  36061. * @param bone defines the bone to control
  36062. * @param options defines options to set up the controller
  36063. */
  36064. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36065. targetMesh?: AbstractMesh;
  36066. poleTargetMesh?: AbstractMesh;
  36067. poleTargetBone?: Bone;
  36068. poleTargetLocalOffset?: Vector3;
  36069. poleAngle?: number;
  36070. bendAxis?: Vector3;
  36071. maxAngle?: number;
  36072. slerpAmount?: number;
  36073. });
  36074. private _setMaxAngle;
  36075. /**
  36076. * Force the controller to update the bones
  36077. */
  36078. update(): void;
  36079. }
  36080. }
  36081. declare module "babylonjs/Bones/boneLookController" {
  36082. import { Vector3, Space } from "babylonjs/Maths/math";
  36083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36084. import { Bone } from "babylonjs/Bones/bone";
  36085. /**
  36086. * Class used to make a bone look toward a point in space
  36087. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36088. */
  36089. export class BoneLookController {
  36090. private static _tmpVecs;
  36091. private static _tmpQuat;
  36092. private static _tmpMats;
  36093. /**
  36094. * The target Vector3 that the bone will look at
  36095. */
  36096. target: Vector3;
  36097. /**
  36098. * The mesh that the bone is attached to
  36099. */
  36100. mesh: AbstractMesh;
  36101. /**
  36102. * The bone that will be looking to the target
  36103. */
  36104. bone: Bone;
  36105. /**
  36106. * The up axis of the coordinate system that is used when the bone is rotated
  36107. */
  36108. upAxis: Vector3;
  36109. /**
  36110. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36111. */
  36112. upAxisSpace: Space;
  36113. /**
  36114. * Used to make an adjustment to the yaw of the bone
  36115. */
  36116. adjustYaw: number;
  36117. /**
  36118. * Used to make an adjustment to the pitch of the bone
  36119. */
  36120. adjustPitch: number;
  36121. /**
  36122. * Used to make an adjustment to the roll of the bone
  36123. */
  36124. adjustRoll: number;
  36125. /**
  36126. * 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)
  36127. */
  36128. slerpAmount: number;
  36129. private _minYaw;
  36130. private _maxYaw;
  36131. private _minPitch;
  36132. private _maxPitch;
  36133. private _minYawSin;
  36134. private _minYawCos;
  36135. private _maxYawSin;
  36136. private _maxYawCos;
  36137. private _midYawConstraint;
  36138. private _minPitchTan;
  36139. private _maxPitchTan;
  36140. private _boneQuat;
  36141. private _slerping;
  36142. private _transformYawPitch;
  36143. private _transformYawPitchInv;
  36144. private _firstFrameSkipped;
  36145. private _yawRange;
  36146. private _fowardAxis;
  36147. /**
  36148. * Gets or sets the minimum yaw angle that the bone can look to
  36149. */
  36150. minYaw: number;
  36151. /**
  36152. * Gets or sets the maximum yaw angle that the bone can look to
  36153. */
  36154. maxYaw: number;
  36155. /**
  36156. * Gets or sets the minimum pitch angle that the bone can look to
  36157. */
  36158. minPitch: number;
  36159. /**
  36160. * Gets or sets the maximum pitch angle that the bone can look to
  36161. */
  36162. maxPitch: number;
  36163. /**
  36164. * Create a BoneLookController
  36165. * @param mesh the mesh that the bone belongs to
  36166. * @param bone the bone that will be looking to the target
  36167. * @param target the target Vector3 to look at
  36168. * @param options optional settings:
  36169. * * maxYaw: the maximum angle the bone will yaw to
  36170. * * minYaw: the minimum angle the bone will yaw to
  36171. * * maxPitch: the maximum angle the bone will pitch to
  36172. * * minPitch: the minimum angle the bone will yaw to
  36173. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36174. * * upAxis: the up axis of the coordinate system
  36175. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36176. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36177. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36178. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36179. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36180. * * adjustRoll: used to make an adjustment to the roll of the bone
  36181. **/
  36182. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36183. maxYaw?: number;
  36184. minYaw?: number;
  36185. maxPitch?: number;
  36186. minPitch?: number;
  36187. slerpAmount?: number;
  36188. upAxis?: Vector3;
  36189. upAxisSpace?: Space;
  36190. yawAxis?: Vector3;
  36191. pitchAxis?: Vector3;
  36192. adjustYaw?: number;
  36193. adjustPitch?: number;
  36194. adjustRoll?: number;
  36195. });
  36196. /**
  36197. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36198. */
  36199. update(): void;
  36200. private _getAngleDiff;
  36201. private _getAngleBetween;
  36202. private _isAngleBetween;
  36203. }
  36204. }
  36205. declare module "babylonjs/Bones/index" {
  36206. export * from "babylonjs/Bones/bone";
  36207. export * from "babylonjs/Bones/boneIKController";
  36208. export * from "babylonjs/Bones/boneLookController";
  36209. export * from "babylonjs/Bones/skeleton";
  36210. }
  36211. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36212. import { Nullable } from "babylonjs/types";
  36213. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36214. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36215. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36216. /**
  36217. * Manage the gamepad inputs to control an arc rotate camera.
  36218. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36219. */
  36220. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36221. /**
  36222. * Defines the camera the input is attached to.
  36223. */
  36224. camera: ArcRotateCamera;
  36225. /**
  36226. * Defines the gamepad the input is gathering event from.
  36227. */
  36228. gamepad: Nullable<Gamepad>;
  36229. /**
  36230. * Defines the gamepad rotation sensiblity.
  36231. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36232. */
  36233. gamepadRotationSensibility: number;
  36234. /**
  36235. * Defines the gamepad move sensiblity.
  36236. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36237. */
  36238. gamepadMoveSensibility: number;
  36239. private _onGamepadConnectedObserver;
  36240. private _onGamepadDisconnectedObserver;
  36241. /**
  36242. * Attach the input controls to a specific dom element to get the input from.
  36243. * @param element Defines the element the controls should be listened from
  36244. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36245. */
  36246. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36247. /**
  36248. * Detach the current controls from the specified dom element.
  36249. * @param element Defines the element to stop listening the inputs from
  36250. */
  36251. detachControl(element: Nullable<HTMLElement>): void;
  36252. /**
  36253. * Update the current camera state depending on the inputs that have been used this frame.
  36254. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36255. */
  36256. checkInputs(): void;
  36257. /**
  36258. * Gets the class name of the current intput.
  36259. * @returns the class name
  36260. */
  36261. getClassName(): string;
  36262. /**
  36263. * Get the friendly name associated with the input class.
  36264. * @returns the input friendly name
  36265. */
  36266. getSimpleName(): string;
  36267. }
  36268. }
  36269. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36270. import { Nullable } from "babylonjs/types";
  36271. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36272. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36273. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36274. interface ArcRotateCameraInputsManager {
  36275. /**
  36276. * Add orientation input support to the input manager.
  36277. * @returns the current input manager
  36278. */
  36279. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36280. }
  36281. }
  36282. /**
  36283. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36284. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36285. */
  36286. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36287. /**
  36288. * Defines the camera the input is attached to.
  36289. */
  36290. camera: ArcRotateCamera;
  36291. /**
  36292. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36293. */
  36294. alphaCorrection: number;
  36295. /**
  36296. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36297. */
  36298. gammaCorrection: number;
  36299. private _alpha;
  36300. private _gamma;
  36301. private _dirty;
  36302. private _deviceOrientationHandler;
  36303. /**
  36304. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36305. */
  36306. constructor();
  36307. /**
  36308. * Attach the input controls to a specific dom element to get the input from.
  36309. * @param element Defines the element the controls should be listened from
  36310. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36311. */
  36312. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36313. /** @hidden */
  36314. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36315. /**
  36316. * Update the current camera state depending on the inputs that have been used this frame.
  36317. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36318. */
  36319. checkInputs(): void;
  36320. /**
  36321. * Detach the current controls from the specified dom element.
  36322. * @param element Defines the element to stop listening the inputs from
  36323. */
  36324. detachControl(element: Nullable<HTMLElement>): void;
  36325. /**
  36326. * Gets the class name of the current intput.
  36327. * @returns the class name
  36328. */
  36329. getClassName(): string;
  36330. /**
  36331. * Get the friendly name associated with the input class.
  36332. * @returns the input friendly name
  36333. */
  36334. getSimpleName(): string;
  36335. }
  36336. }
  36337. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36338. import { Nullable } from "babylonjs/types";
  36339. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36340. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36341. /**
  36342. * Listen to mouse events to control the camera.
  36343. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36344. */
  36345. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36346. /**
  36347. * Defines the camera the input is attached to.
  36348. */
  36349. camera: FlyCamera;
  36350. /**
  36351. * Defines if touch is enabled. (Default is true.)
  36352. */
  36353. touchEnabled: boolean;
  36354. /**
  36355. * Defines the buttons associated with the input to handle camera rotation.
  36356. */
  36357. buttons: number[];
  36358. /**
  36359. * Assign buttons for Yaw control.
  36360. */
  36361. buttonsYaw: number[];
  36362. /**
  36363. * Assign buttons for Pitch control.
  36364. */
  36365. buttonsPitch: number[];
  36366. /**
  36367. * Assign buttons for Roll control.
  36368. */
  36369. buttonsRoll: number[];
  36370. /**
  36371. * Detect if any button is being pressed while mouse is moved.
  36372. * -1 = Mouse locked.
  36373. * 0 = Left button.
  36374. * 1 = Middle Button.
  36375. * 2 = Right Button.
  36376. */
  36377. activeButton: number;
  36378. /**
  36379. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36380. * Higher values reduce its sensitivity.
  36381. */
  36382. angularSensibility: number;
  36383. private _mousemoveCallback;
  36384. private _observer;
  36385. private _rollObserver;
  36386. private previousPosition;
  36387. private noPreventDefault;
  36388. private element;
  36389. /**
  36390. * Listen to mouse events to control the camera.
  36391. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36392. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36393. */
  36394. constructor(touchEnabled?: boolean);
  36395. /**
  36396. * Attach the mouse control to the HTML DOM element.
  36397. * @param element Defines the element that listens to the input events.
  36398. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36399. */
  36400. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36401. /**
  36402. * Detach the current controls from the specified dom element.
  36403. * @param element Defines the element to stop listening the inputs from
  36404. */
  36405. detachControl(element: Nullable<HTMLElement>): void;
  36406. /**
  36407. * Gets the class name of the current input.
  36408. * @returns the class name.
  36409. */
  36410. getClassName(): string;
  36411. /**
  36412. * Get the friendly name associated with the input class.
  36413. * @returns the input's friendly name.
  36414. */
  36415. getSimpleName(): string;
  36416. private _pointerInput;
  36417. private _onMouseMove;
  36418. /**
  36419. * Rotate camera by mouse offset.
  36420. */
  36421. private rotateCamera;
  36422. }
  36423. }
  36424. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36425. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36426. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36427. /**
  36428. * Default Inputs manager for the FlyCamera.
  36429. * It groups all the default supported inputs for ease of use.
  36430. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36431. */
  36432. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36433. /**
  36434. * Instantiates a new FlyCameraInputsManager.
  36435. * @param camera Defines the camera the inputs belong to.
  36436. */
  36437. constructor(camera: FlyCamera);
  36438. /**
  36439. * Add keyboard input support to the input manager.
  36440. * @returns the new FlyCameraKeyboardMoveInput().
  36441. */
  36442. addKeyboard(): FlyCameraInputsManager;
  36443. /**
  36444. * Add mouse input support to the input manager.
  36445. * @param touchEnabled Enable touch screen support.
  36446. * @returns the new FlyCameraMouseInput().
  36447. */
  36448. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36449. }
  36450. }
  36451. declare module "babylonjs/Cameras/flyCamera" {
  36452. import { Scene } from "babylonjs/scene";
  36453. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36455. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36456. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36457. /**
  36458. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36459. * such as in a 3D Space Shooter or a Flight Simulator.
  36460. */
  36461. export class FlyCamera extends TargetCamera {
  36462. /**
  36463. * Define the collision ellipsoid of the camera.
  36464. * This is helpful for simulating a camera body, like a player's body.
  36465. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36466. */
  36467. ellipsoid: Vector3;
  36468. /**
  36469. * Define an offset for the position of the ellipsoid around the camera.
  36470. * This can be helpful if the camera is attached away from the player's body center,
  36471. * such as at its head.
  36472. */
  36473. ellipsoidOffset: Vector3;
  36474. /**
  36475. * Enable or disable collisions of the camera with the rest of the scene objects.
  36476. */
  36477. checkCollisions: boolean;
  36478. /**
  36479. * Enable or disable gravity on the camera.
  36480. */
  36481. applyGravity: boolean;
  36482. /**
  36483. * Define the current direction the camera is moving to.
  36484. */
  36485. cameraDirection: Vector3;
  36486. /**
  36487. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36488. * This overrides and empties cameraRotation.
  36489. */
  36490. rotationQuaternion: Quaternion;
  36491. /**
  36492. * Track Roll to maintain the wanted Rolling when looking around.
  36493. */
  36494. _trackRoll: number;
  36495. /**
  36496. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36497. */
  36498. rollCorrect: number;
  36499. /**
  36500. * Mimic a banked turn, Rolling the camera when Yawing.
  36501. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36502. */
  36503. bankedTurn: boolean;
  36504. /**
  36505. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36506. */
  36507. bankedTurnLimit: number;
  36508. /**
  36509. * Value of 0 disables the banked Roll.
  36510. * Value of 1 is equal to the Yaw angle in radians.
  36511. */
  36512. bankedTurnMultiplier: number;
  36513. /**
  36514. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36515. */
  36516. inputs: FlyCameraInputsManager;
  36517. /**
  36518. * Gets the input sensibility for mouse input.
  36519. * Higher values reduce sensitivity.
  36520. */
  36521. /**
  36522. * Sets the input sensibility for a mouse input.
  36523. * Higher values reduce sensitivity.
  36524. */
  36525. angularSensibility: number;
  36526. /**
  36527. * Get the keys for camera movement forward.
  36528. */
  36529. /**
  36530. * Set the keys for camera movement forward.
  36531. */
  36532. keysForward: number[];
  36533. /**
  36534. * Get the keys for camera movement backward.
  36535. */
  36536. keysBackward: number[];
  36537. /**
  36538. * Get the keys for camera movement up.
  36539. */
  36540. /**
  36541. * Set the keys for camera movement up.
  36542. */
  36543. keysUp: number[];
  36544. /**
  36545. * Get the keys for camera movement down.
  36546. */
  36547. /**
  36548. * Set the keys for camera movement down.
  36549. */
  36550. keysDown: number[];
  36551. /**
  36552. * Get the keys for camera movement left.
  36553. */
  36554. /**
  36555. * Set the keys for camera movement left.
  36556. */
  36557. keysLeft: number[];
  36558. /**
  36559. * Set the keys for camera movement right.
  36560. */
  36561. /**
  36562. * Set the keys for camera movement right.
  36563. */
  36564. keysRight: number[];
  36565. /**
  36566. * Event raised when the camera collides with a mesh in the scene.
  36567. */
  36568. onCollide: (collidedMesh: AbstractMesh) => void;
  36569. private _collider;
  36570. private _needMoveForGravity;
  36571. private _oldPosition;
  36572. private _diffPosition;
  36573. private _newPosition;
  36574. /** @hidden */
  36575. _localDirection: Vector3;
  36576. /** @hidden */
  36577. _transformedDirection: Vector3;
  36578. /**
  36579. * Instantiates a FlyCamera.
  36580. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36581. * such as in a 3D Space Shooter or a Flight Simulator.
  36582. * @param name Define the name of the camera in the scene.
  36583. * @param position Define the starting position of the camera in the scene.
  36584. * @param scene Define the scene the camera belongs to.
  36585. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36586. */
  36587. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36588. /**
  36589. * Attach a control to the HTML DOM element.
  36590. * @param element Defines the element that listens to the input events.
  36591. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36592. */
  36593. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36594. /**
  36595. * Detach a control from the HTML DOM element.
  36596. * The camera will stop reacting to that input.
  36597. * @param element Defines the element that listens to the input events.
  36598. */
  36599. detachControl(element: HTMLElement): void;
  36600. private _collisionMask;
  36601. /**
  36602. * Get the mask that the camera ignores in collision events.
  36603. */
  36604. /**
  36605. * Set the mask that the camera ignores in collision events.
  36606. */
  36607. collisionMask: number;
  36608. /** @hidden */
  36609. _collideWithWorld(displacement: Vector3): void;
  36610. /** @hidden */
  36611. private _onCollisionPositionChange;
  36612. /** @hidden */
  36613. _checkInputs(): void;
  36614. /** @hidden */
  36615. _decideIfNeedsToMove(): boolean;
  36616. /** @hidden */
  36617. _updatePosition(): void;
  36618. /**
  36619. * Restore the Roll to its target value at the rate specified.
  36620. * @param rate - Higher means slower restoring.
  36621. * @hidden
  36622. */
  36623. restoreRoll(rate: number): void;
  36624. /**
  36625. * Destroy the camera and release the current resources held by it.
  36626. */
  36627. dispose(): void;
  36628. /**
  36629. * Get the current object class name.
  36630. * @returns the class name.
  36631. */
  36632. getClassName(): string;
  36633. }
  36634. }
  36635. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  36636. import { Nullable } from "babylonjs/types";
  36637. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36638. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36639. /**
  36640. * Listen to keyboard events to control the camera.
  36641. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36642. */
  36643. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36644. /**
  36645. * Defines the camera the input is attached to.
  36646. */
  36647. camera: FlyCamera;
  36648. /**
  36649. * The list of keyboard keys used to control the forward move of the camera.
  36650. */
  36651. keysForward: number[];
  36652. /**
  36653. * The list of keyboard keys used to control the backward move of the camera.
  36654. */
  36655. keysBackward: number[];
  36656. /**
  36657. * The list of keyboard keys used to control the forward move of the camera.
  36658. */
  36659. keysUp: number[];
  36660. /**
  36661. * The list of keyboard keys used to control the backward move of the camera.
  36662. */
  36663. keysDown: number[];
  36664. /**
  36665. * The list of keyboard keys used to control the right strafe move of the camera.
  36666. */
  36667. keysRight: number[];
  36668. /**
  36669. * The list of keyboard keys used to control the left strafe move of the camera.
  36670. */
  36671. keysLeft: number[];
  36672. private _keys;
  36673. private _onCanvasBlurObserver;
  36674. private _onKeyboardObserver;
  36675. private _engine;
  36676. private _scene;
  36677. /**
  36678. * Attach the input controls to a specific dom element to get the input from.
  36679. * @param element Defines the element the controls should be listened from
  36680. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36681. */
  36682. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36683. /**
  36684. * Detach the current controls from the specified dom element.
  36685. * @param element Defines the element to stop listening the inputs from
  36686. */
  36687. detachControl(element: Nullable<HTMLElement>): void;
  36688. /**
  36689. * Gets the class name of the current intput.
  36690. * @returns the class name
  36691. */
  36692. getClassName(): string;
  36693. /** @hidden */
  36694. _onLostFocus(e: FocusEvent): void;
  36695. /**
  36696. * Get the friendly name associated with the input class.
  36697. * @returns the input friendly name
  36698. */
  36699. getSimpleName(): string;
  36700. /**
  36701. * Update the current camera state depending on the inputs that have been used this frame.
  36702. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36703. */
  36704. checkInputs(): void;
  36705. }
  36706. }
  36707. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  36708. import { Nullable } from "babylonjs/types";
  36709. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36710. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36711. /**
  36712. * Manage the mouse wheel inputs to control a follow camera.
  36713. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36714. */
  36715. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36716. /**
  36717. * Defines the camera the input is attached to.
  36718. */
  36719. camera: FollowCamera;
  36720. /**
  36721. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36722. */
  36723. axisControlRadius: boolean;
  36724. /**
  36725. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36726. */
  36727. axisControlHeight: boolean;
  36728. /**
  36729. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36730. */
  36731. axisControlRotation: boolean;
  36732. /**
  36733. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36734. * relation to mouseWheel events.
  36735. */
  36736. wheelPrecision: number;
  36737. /**
  36738. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36739. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36740. */
  36741. wheelDeltaPercentage: number;
  36742. private _wheel;
  36743. private _observer;
  36744. /**
  36745. * Attach the input controls to a specific dom element to get the input from.
  36746. * @param element Defines the element the controls should be listened from
  36747. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36748. */
  36749. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36750. /**
  36751. * Detach the current controls from the specified dom element.
  36752. * @param element Defines the element to stop listening the inputs from
  36753. */
  36754. detachControl(element: Nullable<HTMLElement>): void;
  36755. /**
  36756. * Gets the class name of the current intput.
  36757. * @returns the class name
  36758. */
  36759. getClassName(): string;
  36760. /**
  36761. * Get the friendly name associated with the input class.
  36762. * @returns the input friendly name
  36763. */
  36764. getSimpleName(): string;
  36765. }
  36766. }
  36767. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  36768. import { Nullable } from "babylonjs/types";
  36769. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36770. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36771. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36772. /**
  36773. * Manage the pointers inputs to control an follow camera.
  36774. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36775. */
  36776. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36777. /**
  36778. * Defines the camera the input is attached to.
  36779. */
  36780. camera: FollowCamera;
  36781. /**
  36782. * Gets the class name of the current input.
  36783. * @returns the class name
  36784. */
  36785. getClassName(): string;
  36786. /**
  36787. * Defines the pointer angular sensibility along the X axis or how fast is
  36788. * the camera rotating.
  36789. * A negative number will reverse the axis direction.
  36790. */
  36791. angularSensibilityX: number;
  36792. /**
  36793. * Defines the pointer angular sensibility along the Y axis or how fast is
  36794. * the camera rotating.
  36795. * A negative number will reverse the axis direction.
  36796. */
  36797. angularSensibilityY: number;
  36798. /**
  36799. * Defines the pointer pinch precision or how fast is the camera zooming.
  36800. * A negative number will reverse the axis direction.
  36801. */
  36802. pinchPrecision: number;
  36803. /**
  36804. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36805. * from 0.
  36806. * It defines the percentage of current camera.radius to use as delta when
  36807. * pinch zoom is used.
  36808. */
  36809. pinchDeltaPercentage: number;
  36810. /**
  36811. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36812. */
  36813. axisXControlRadius: boolean;
  36814. /**
  36815. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36816. */
  36817. axisXControlHeight: boolean;
  36818. /**
  36819. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36820. */
  36821. axisXControlRotation: boolean;
  36822. /**
  36823. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36824. */
  36825. axisYControlRadius: boolean;
  36826. /**
  36827. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36828. */
  36829. axisYControlHeight: boolean;
  36830. /**
  36831. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36832. */
  36833. axisYControlRotation: boolean;
  36834. /**
  36835. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36836. */
  36837. axisPinchControlRadius: boolean;
  36838. /**
  36839. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36840. */
  36841. axisPinchControlHeight: boolean;
  36842. /**
  36843. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36844. */
  36845. axisPinchControlRotation: boolean;
  36846. /**
  36847. * Log error messages if basic misconfiguration has occurred.
  36848. */
  36849. warningEnable: boolean;
  36850. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36851. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36852. private _warningCounter;
  36853. private _warning;
  36854. }
  36855. }
  36856. declare module "babylonjs/Cameras/followCameraInputsManager" {
  36857. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36858. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36859. /**
  36860. * Default Inputs manager for the FollowCamera.
  36861. * It groups all the default supported inputs for ease of use.
  36862. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36863. */
  36864. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36865. /**
  36866. * Instantiates a new FollowCameraInputsManager.
  36867. * @param camera Defines the camera the inputs belong to
  36868. */
  36869. constructor(camera: FollowCamera);
  36870. /**
  36871. * Add keyboard input support to the input manager.
  36872. * @returns the current input manager
  36873. */
  36874. addKeyboard(): FollowCameraInputsManager;
  36875. /**
  36876. * Add mouse wheel input support to the input manager.
  36877. * @returns the current input manager
  36878. */
  36879. addMouseWheel(): FollowCameraInputsManager;
  36880. /**
  36881. * Add pointers input support to the input manager.
  36882. * @returns the current input manager
  36883. */
  36884. addPointers(): FollowCameraInputsManager;
  36885. /**
  36886. * Add orientation input support to the input manager.
  36887. * @returns the current input manager
  36888. */
  36889. addVRDeviceOrientation(): FollowCameraInputsManager;
  36890. }
  36891. }
  36892. declare module "babylonjs/Cameras/followCamera" {
  36893. import { Nullable } from "babylonjs/types";
  36894. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36895. import { Scene } from "babylonjs/scene";
  36896. import { Vector3 } from "babylonjs/Maths/math";
  36897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36898. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  36899. /**
  36900. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36901. * an arc rotate version arcFollowCamera are available.
  36902. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36903. */
  36904. export class FollowCamera extends TargetCamera {
  36905. /**
  36906. * Distance the follow camera should follow an object at
  36907. */
  36908. radius: number;
  36909. /**
  36910. * Minimum allowed distance of the camera to the axis of rotation
  36911. * (The camera can not get closer).
  36912. * This can help limiting how the Camera is able to move in the scene.
  36913. */
  36914. lowerRadiusLimit: Nullable<number>;
  36915. /**
  36916. * Maximum allowed distance of the camera to the axis of rotation
  36917. * (The camera can not get further).
  36918. * This can help limiting how the Camera is able to move in the scene.
  36919. */
  36920. upperRadiusLimit: Nullable<number>;
  36921. /**
  36922. * Define a rotation offset between the camera and the object it follows
  36923. */
  36924. rotationOffset: number;
  36925. /**
  36926. * Minimum allowed angle to camera position relative to target object.
  36927. * This can help limiting how the Camera is able to move in the scene.
  36928. */
  36929. lowerRotationOffsetLimit: Nullable<number>;
  36930. /**
  36931. * Maximum allowed angle to camera position relative to target object.
  36932. * This can help limiting how the Camera is able to move in the scene.
  36933. */
  36934. upperRotationOffsetLimit: Nullable<number>;
  36935. /**
  36936. * Define a height offset between the camera and the object it follows.
  36937. * It can help following an object from the top (like a car chaing a plane)
  36938. */
  36939. heightOffset: number;
  36940. /**
  36941. * Minimum allowed height of camera position relative to target object.
  36942. * This can help limiting how the Camera is able to move in the scene.
  36943. */
  36944. lowerHeightOffsetLimit: Nullable<number>;
  36945. /**
  36946. * Maximum allowed height of camera position relative to target object.
  36947. * This can help limiting how the Camera is able to move in the scene.
  36948. */
  36949. upperHeightOffsetLimit: Nullable<number>;
  36950. /**
  36951. * Define how fast the camera can accelerate to follow it s target.
  36952. */
  36953. cameraAcceleration: number;
  36954. /**
  36955. * Define the speed limit of the camera following an object.
  36956. */
  36957. maxCameraSpeed: number;
  36958. /**
  36959. * Define the target of the camera.
  36960. */
  36961. lockedTarget: Nullable<AbstractMesh>;
  36962. /**
  36963. * Defines the input associated with the camera.
  36964. */
  36965. inputs: FollowCameraInputsManager;
  36966. /**
  36967. * Instantiates the follow camera.
  36968. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36969. * @param name Define the name of the camera in the scene
  36970. * @param position Define the position of the camera
  36971. * @param scene Define the scene the camera belong to
  36972. * @param lockedTarget Define the target of the camera
  36973. */
  36974. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36975. private _follow;
  36976. /**
  36977. * Attached controls to the current camera.
  36978. * @param element Defines the element the controls should be listened from
  36979. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36980. */
  36981. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36982. /**
  36983. * Detach the current controls from the camera.
  36984. * The camera will stop reacting to inputs.
  36985. * @param element Defines the element to stop listening the inputs from
  36986. */
  36987. detachControl(element: HTMLElement): void;
  36988. /** @hidden */
  36989. _checkInputs(): void;
  36990. private _checkLimits;
  36991. /**
  36992. * Gets the camera class name.
  36993. * @returns the class name
  36994. */
  36995. getClassName(): string;
  36996. }
  36997. /**
  36998. * Arc Rotate version of the follow camera.
  36999. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37000. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37001. */
  37002. export class ArcFollowCamera extends TargetCamera {
  37003. /** The longitudinal angle of the camera */
  37004. alpha: number;
  37005. /** The latitudinal angle of the camera */
  37006. beta: number;
  37007. /** The radius of the camera from its target */
  37008. radius: number;
  37009. /** Define the camera target (the messh it should follow) */
  37010. target: Nullable<AbstractMesh>;
  37011. private _cartesianCoordinates;
  37012. /**
  37013. * Instantiates a new ArcFollowCamera
  37014. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37015. * @param name Define the name of the camera
  37016. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37017. * @param beta Define the rotation angle of the camera around the elevation axis
  37018. * @param radius Define the radius of the camera from its target point
  37019. * @param target Define the target of the camera
  37020. * @param scene Define the scene the camera belongs to
  37021. */
  37022. constructor(name: string,
  37023. /** The longitudinal angle of the camera */
  37024. alpha: number,
  37025. /** The latitudinal angle of the camera */
  37026. beta: number,
  37027. /** The radius of the camera from its target */
  37028. radius: number,
  37029. /** Define the camera target (the messh it should follow) */
  37030. target: Nullable<AbstractMesh>, scene: Scene);
  37031. private _follow;
  37032. /** @hidden */
  37033. _checkInputs(): void;
  37034. /**
  37035. * Returns the class name of the object.
  37036. * It is mostly used internally for serialization purposes.
  37037. */
  37038. getClassName(): string;
  37039. }
  37040. }
  37041. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37042. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37043. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37044. import { Nullable } from "babylonjs/types";
  37045. /**
  37046. * Manage the keyboard inputs to control the movement of a follow camera.
  37047. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37048. */
  37049. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37050. /**
  37051. * Defines the camera the input is attached to.
  37052. */
  37053. camera: FollowCamera;
  37054. /**
  37055. * Defines the list of key codes associated with the up action (increase heightOffset)
  37056. */
  37057. keysHeightOffsetIncr: number[];
  37058. /**
  37059. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37060. */
  37061. keysHeightOffsetDecr: number[];
  37062. /**
  37063. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37064. */
  37065. keysHeightOffsetModifierAlt: boolean;
  37066. /**
  37067. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37068. */
  37069. keysHeightOffsetModifierCtrl: boolean;
  37070. /**
  37071. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37072. */
  37073. keysHeightOffsetModifierShift: boolean;
  37074. /**
  37075. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37076. */
  37077. keysRotationOffsetIncr: number[];
  37078. /**
  37079. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37080. */
  37081. keysRotationOffsetDecr: number[];
  37082. /**
  37083. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37084. */
  37085. keysRotationOffsetModifierAlt: boolean;
  37086. /**
  37087. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37088. */
  37089. keysRotationOffsetModifierCtrl: boolean;
  37090. /**
  37091. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37092. */
  37093. keysRotationOffsetModifierShift: boolean;
  37094. /**
  37095. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37096. */
  37097. keysRadiusIncr: number[];
  37098. /**
  37099. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37100. */
  37101. keysRadiusDecr: number[];
  37102. /**
  37103. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37104. */
  37105. keysRadiusModifierAlt: boolean;
  37106. /**
  37107. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37108. */
  37109. keysRadiusModifierCtrl: boolean;
  37110. /**
  37111. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37112. */
  37113. keysRadiusModifierShift: boolean;
  37114. /**
  37115. * Defines the rate of change of heightOffset.
  37116. */
  37117. heightSensibility: number;
  37118. /**
  37119. * Defines the rate of change of rotationOffset.
  37120. */
  37121. rotationSensibility: number;
  37122. /**
  37123. * Defines the rate of change of radius.
  37124. */
  37125. radiusSensibility: number;
  37126. private _keys;
  37127. private _ctrlPressed;
  37128. private _altPressed;
  37129. private _shiftPressed;
  37130. private _onCanvasBlurObserver;
  37131. private _onKeyboardObserver;
  37132. private _engine;
  37133. private _scene;
  37134. /**
  37135. * Attach the input controls to a specific dom element to get the input from.
  37136. * @param element Defines the element the controls should be listened from
  37137. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37138. */
  37139. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37140. /**
  37141. * Detach the current controls from the specified dom element.
  37142. * @param element Defines the element to stop listening the inputs from
  37143. */
  37144. detachControl(element: Nullable<HTMLElement>): void;
  37145. /**
  37146. * Update the current camera state depending on the inputs that have been used this frame.
  37147. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37148. */
  37149. checkInputs(): void;
  37150. /**
  37151. * Gets the class name of the current input.
  37152. * @returns the class name
  37153. */
  37154. getClassName(): string;
  37155. /**
  37156. * Get the friendly name associated with the input class.
  37157. * @returns the input friendly name
  37158. */
  37159. getSimpleName(): string;
  37160. /**
  37161. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37162. * allow modification of the heightOffset value.
  37163. */
  37164. private _modifierHeightOffset;
  37165. /**
  37166. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37167. * allow modification of the rotationOffset value.
  37168. */
  37169. private _modifierRotationOffset;
  37170. /**
  37171. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37172. * allow modification of the radius value.
  37173. */
  37174. private _modifierRadius;
  37175. }
  37176. }
  37177. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37178. import { Nullable } from "babylonjs/types";
  37179. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37180. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37181. module "babylonjs/Cameras/freeCameraInputsManager" {
  37182. interface FreeCameraInputsManager {
  37183. /**
  37184. * Add orientation input support to the input manager.
  37185. * @returns the current input manager
  37186. */
  37187. addDeviceOrientation(): FreeCameraInputsManager;
  37188. }
  37189. }
  37190. /**
  37191. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37192. * Screen rotation is taken into account.
  37193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37194. */
  37195. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37196. private _camera;
  37197. private _screenOrientationAngle;
  37198. private _constantTranform;
  37199. private _screenQuaternion;
  37200. private _alpha;
  37201. private _beta;
  37202. private _gamma;
  37203. /**
  37204. * Instantiates a new input
  37205. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37206. */
  37207. constructor();
  37208. /**
  37209. * Define the camera controlled by the input.
  37210. */
  37211. camera: FreeCamera;
  37212. /**
  37213. * Attach the input controls to a specific dom element to get the input from.
  37214. * @param element Defines the element the controls should be listened from
  37215. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37216. */
  37217. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37218. private _orientationChanged;
  37219. private _deviceOrientation;
  37220. /**
  37221. * Detach the current controls from the specified dom element.
  37222. * @param element Defines the element to stop listening the inputs from
  37223. */
  37224. detachControl(element: Nullable<HTMLElement>): void;
  37225. /**
  37226. * Update the current camera state depending on the inputs that have been used this frame.
  37227. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37228. */
  37229. checkInputs(): void;
  37230. /**
  37231. * Gets the class name of the current intput.
  37232. * @returns the class name
  37233. */
  37234. getClassName(): string;
  37235. /**
  37236. * Get the friendly name associated with the input class.
  37237. * @returns the input friendly name
  37238. */
  37239. getSimpleName(): string;
  37240. }
  37241. }
  37242. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37243. import { Nullable } from "babylonjs/types";
  37244. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37245. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37246. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37247. /**
  37248. * Manage the gamepad inputs to control a free camera.
  37249. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37250. */
  37251. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37252. /**
  37253. * Define the camera the input is attached to.
  37254. */
  37255. camera: FreeCamera;
  37256. /**
  37257. * Define the Gamepad controlling the input
  37258. */
  37259. gamepad: Nullable<Gamepad>;
  37260. /**
  37261. * Defines the gamepad rotation sensiblity.
  37262. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37263. */
  37264. gamepadAngularSensibility: number;
  37265. /**
  37266. * Defines the gamepad move sensiblity.
  37267. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37268. */
  37269. gamepadMoveSensibility: number;
  37270. private _onGamepadConnectedObserver;
  37271. private _onGamepadDisconnectedObserver;
  37272. private _cameraTransform;
  37273. private _deltaTransform;
  37274. private _vector3;
  37275. private _vector2;
  37276. /**
  37277. * Attach the input controls to a specific dom element to get the input from.
  37278. * @param element Defines the element the controls should be listened from
  37279. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37280. */
  37281. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37282. /**
  37283. * Detach the current controls from the specified dom element.
  37284. * @param element Defines the element to stop listening the inputs from
  37285. */
  37286. detachControl(element: Nullable<HTMLElement>): void;
  37287. /**
  37288. * Update the current camera state depending on the inputs that have been used this frame.
  37289. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37290. */
  37291. checkInputs(): void;
  37292. /**
  37293. * Gets the class name of the current intput.
  37294. * @returns the class name
  37295. */
  37296. getClassName(): string;
  37297. /**
  37298. * Get the friendly name associated with the input class.
  37299. * @returns the input friendly name
  37300. */
  37301. getSimpleName(): string;
  37302. }
  37303. }
  37304. declare module "babylonjs/Misc/virtualJoystick" {
  37305. import { Nullable } from "babylonjs/types";
  37306. import { Vector3 } from "babylonjs/Maths/math";
  37307. /**
  37308. * Defines the potential axis of a Joystick
  37309. */
  37310. export enum JoystickAxis {
  37311. /** X axis */
  37312. X = 0,
  37313. /** Y axis */
  37314. Y = 1,
  37315. /** Z axis */
  37316. Z = 2
  37317. }
  37318. /**
  37319. * Class used to define virtual joystick (used in touch mode)
  37320. */
  37321. export class VirtualJoystick {
  37322. /**
  37323. * Gets or sets a boolean indicating that left and right values must be inverted
  37324. */
  37325. reverseLeftRight: boolean;
  37326. /**
  37327. * Gets or sets a boolean indicating that up and down values must be inverted
  37328. */
  37329. reverseUpDown: boolean;
  37330. /**
  37331. * Gets the offset value for the position (ie. the change of the position value)
  37332. */
  37333. deltaPosition: Vector3;
  37334. /**
  37335. * Gets a boolean indicating if the virtual joystick was pressed
  37336. */
  37337. pressed: boolean;
  37338. /**
  37339. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37340. */
  37341. static Canvas: Nullable<HTMLCanvasElement>;
  37342. private static _globalJoystickIndex;
  37343. private static vjCanvasContext;
  37344. private static vjCanvasWidth;
  37345. private static vjCanvasHeight;
  37346. private static halfWidth;
  37347. private _action;
  37348. private _axisTargetedByLeftAndRight;
  37349. private _axisTargetedByUpAndDown;
  37350. private _joystickSensibility;
  37351. private _inversedSensibility;
  37352. private _joystickPointerID;
  37353. private _joystickColor;
  37354. private _joystickPointerPos;
  37355. private _joystickPreviousPointerPos;
  37356. private _joystickPointerStartPos;
  37357. private _deltaJoystickVector;
  37358. private _leftJoystick;
  37359. private _touches;
  37360. private _onPointerDownHandlerRef;
  37361. private _onPointerMoveHandlerRef;
  37362. private _onPointerUpHandlerRef;
  37363. private _onResize;
  37364. /**
  37365. * Creates a new virtual joystick
  37366. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37367. */
  37368. constructor(leftJoystick?: boolean);
  37369. /**
  37370. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37371. * @param newJoystickSensibility defines the new sensibility
  37372. */
  37373. setJoystickSensibility(newJoystickSensibility: number): void;
  37374. private _onPointerDown;
  37375. private _onPointerMove;
  37376. private _onPointerUp;
  37377. /**
  37378. * Change the color of the virtual joystick
  37379. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37380. */
  37381. setJoystickColor(newColor: string): void;
  37382. /**
  37383. * Defines a callback to call when the joystick is touched
  37384. * @param action defines the callback
  37385. */
  37386. setActionOnTouch(action: () => any): void;
  37387. /**
  37388. * Defines which axis you'd like to control for left & right
  37389. * @param axis defines the axis to use
  37390. */
  37391. setAxisForLeftRight(axis: JoystickAxis): void;
  37392. /**
  37393. * Defines which axis you'd like to control for up & down
  37394. * @param axis defines the axis to use
  37395. */
  37396. setAxisForUpDown(axis: JoystickAxis): void;
  37397. private _drawVirtualJoystick;
  37398. /**
  37399. * Release internal HTML canvas
  37400. */
  37401. releaseCanvas(): void;
  37402. }
  37403. }
  37404. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  37405. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  37406. import { Nullable } from "babylonjs/types";
  37407. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37408. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37409. module "babylonjs/Cameras/freeCameraInputsManager" {
  37410. interface FreeCameraInputsManager {
  37411. /**
  37412. * Add virtual joystick input support to the input manager.
  37413. * @returns the current input manager
  37414. */
  37415. addVirtualJoystick(): FreeCameraInputsManager;
  37416. }
  37417. }
  37418. /**
  37419. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37420. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37421. */
  37422. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37423. /**
  37424. * Defines the camera the input is attached to.
  37425. */
  37426. camera: FreeCamera;
  37427. private _leftjoystick;
  37428. private _rightjoystick;
  37429. /**
  37430. * Gets the left stick of the virtual joystick.
  37431. * @returns The virtual Joystick
  37432. */
  37433. getLeftJoystick(): VirtualJoystick;
  37434. /**
  37435. * Gets the right stick of the virtual joystick.
  37436. * @returns The virtual Joystick
  37437. */
  37438. getRightJoystick(): VirtualJoystick;
  37439. /**
  37440. * Update the current camera state depending on the inputs that have been used this frame.
  37441. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37442. */
  37443. checkInputs(): void;
  37444. /**
  37445. * Attach the input controls to a specific dom element to get the input from.
  37446. * @param element Defines the element the controls should be listened from
  37447. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37448. */
  37449. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37450. /**
  37451. * Detach the current controls from the specified dom element.
  37452. * @param element Defines the element to stop listening the inputs from
  37453. */
  37454. detachControl(element: Nullable<HTMLElement>): void;
  37455. /**
  37456. * Gets the class name of the current intput.
  37457. * @returns the class name
  37458. */
  37459. getClassName(): string;
  37460. /**
  37461. * Get the friendly name associated with the input class.
  37462. * @returns the input friendly name
  37463. */
  37464. getSimpleName(): string;
  37465. }
  37466. }
  37467. declare module "babylonjs/Cameras/Inputs/index" {
  37468. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  37469. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  37470. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  37471. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  37472. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37473. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  37474. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  37475. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  37476. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  37477. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  37478. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37479. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  37480. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  37481. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  37482. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  37483. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37484. }
  37485. declare module "babylonjs/Cameras/touchCamera" {
  37486. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37487. import { Scene } from "babylonjs/scene";
  37488. import { Vector3 } from "babylonjs/Maths/math";
  37489. /**
  37490. * This represents a FPS type of camera controlled by touch.
  37491. * This is like a universal camera minus the Gamepad controls.
  37492. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37493. */
  37494. export class TouchCamera extends FreeCamera {
  37495. /**
  37496. * Defines the touch sensibility for rotation.
  37497. * The higher the faster.
  37498. */
  37499. touchAngularSensibility: number;
  37500. /**
  37501. * Defines the touch sensibility for move.
  37502. * The higher the faster.
  37503. */
  37504. touchMoveSensibility: number;
  37505. /**
  37506. * Instantiates a new touch camera.
  37507. * This represents a FPS type of camera controlled by touch.
  37508. * This is like a universal camera minus the Gamepad controls.
  37509. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37510. * @param name Define the name of the camera in the scene
  37511. * @param position Define the start position of the camera in the scene
  37512. * @param scene Define the scene the camera belongs to
  37513. */
  37514. constructor(name: string, position: Vector3, scene: Scene);
  37515. /**
  37516. * Gets the current object class name.
  37517. * @return the class name
  37518. */
  37519. getClassName(): string;
  37520. /** @hidden */
  37521. _setupInputs(): void;
  37522. }
  37523. }
  37524. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  37525. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37526. import { Scene } from "babylonjs/scene";
  37527. import { Vector3, Axis } from "babylonjs/Maths/math";
  37528. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37529. /**
  37530. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37531. * being tilted forward or back and left or right.
  37532. */
  37533. export class DeviceOrientationCamera extends FreeCamera {
  37534. private _initialQuaternion;
  37535. private _quaternionCache;
  37536. /**
  37537. * Creates a new device orientation camera
  37538. * @param name The name of the camera
  37539. * @param position The start position camera
  37540. * @param scene The scene the camera belongs to
  37541. */
  37542. constructor(name: string, position: Vector3, scene: Scene);
  37543. /**
  37544. * Gets the current instance class name ("DeviceOrientationCamera").
  37545. * This helps avoiding instanceof at run time.
  37546. * @returns the class name
  37547. */
  37548. getClassName(): string;
  37549. /**
  37550. * @hidden
  37551. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37552. */
  37553. _checkInputs(): void;
  37554. /**
  37555. * Reset the camera to its default orientation on the specified axis only.
  37556. * @param axis The axis to reset
  37557. */
  37558. resetToCurrentRotation(axis?: Axis): void;
  37559. }
  37560. }
  37561. declare module "babylonjs/Cameras/universalCamera" {
  37562. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37563. import { Scene } from "babylonjs/scene";
  37564. import { Vector3 } from "babylonjs/Maths/math";
  37565. /**
  37566. * 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,
  37567. * which still works and will still be found in many Playgrounds.
  37568. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37569. */
  37570. export class UniversalCamera extends TouchCamera {
  37571. /**
  37572. * Defines the gamepad rotation sensiblity.
  37573. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37574. */
  37575. gamepadAngularSensibility: number;
  37576. /**
  37577. * Defines the gamepad move sensiblity.
  37578. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37579. */
  37580. gamepadMoveSensibility: number;
  37581. /**
  37582. * 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,
  37583. * which still works and will still be found in many Playgrounds.
  37584. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37585. * @param name Define the name of the camera in the scene
  37586. * @param position Define the start position of the camera in the scene
  37587. * @param scene Define the scene the camera belongs to
  37588. */
  37589. constructor(name: string, position: Vector3, scene: Scene);
  37590. /**
  37591. * Gets the current object class name.
  37592. * @return the class name
  37593. */
  37594. getClassName(): string;
  37595. }
  37596. }
  37597. declare module "babylonjs/Cameras/gamepadCamera" {
  37598. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37599. import { Scene } from "babylonjs/scene";
  37600. import { Vector3 } from "babylonjs/Maths/math";
  37601. /**
  37602. * This represents a FPS type of camera. This is only here for back compat purpose.
  37603. * Please use the UniversalCamera instead as both are identical.
  37604. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37605. */
  37606. export class GamepadCamera extends UniversalCamera {
  37607. /**
  37608. * Instantiates a new Gamepad Camera
  37609. * This represents a FPS type of camera. This is only here for back compat purpose.
  37610. * Please use the UniversalCamera instead as both are identical.
  37611. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37612. * @param name Define the name of the camera in the scene
  37613. * @param position Define the start position of the camera in the scene
  37614. * @param scene Define the scene the camera belongs to
  37615. */
  37616. constructor(name: string, position: Vector3, scene: Scene);
  37617. /**
  37618. * Gets the current object class name.
  37619. * @return the class name
  37620. */
  37621. getClassName(): string;
  37622. }
  37623. }
  37624. declare module "babylonjs/Shaders/pass.fragment" {
  37625. /** @hidden */
  37626. export var passPixelShader: {
  37627. name: string;
  37628. shader: string;
  37629. };
  37630. }
  37631. declare module "babylonjs/Shaders/passCube.fragment" {
  37632. /** @hidden */
  37633. export var passCubePixelShader: {
  37634. name: string;
  37635. shader: string;
  37636. };
  37637. }
  37638. declare module "babylonjs/PostProcesses/passPostProcess" {
  37639. import { Nullable } from "babylonjs/types";
  37640. import { Camera } from "babylonjs/Cameras/camera";
  37641. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37642. import { Engine } from "babylonjs/Engines/engine";
  37643. import "babylonjs/Shaders/pass.fragment";
  37644. import "babylonjs/Shaders/passCube.fragment";
  37645. /**
  37646. * PassPostProcess which produces an output the same as it's input
  37647. */
  37648. export class PassPostProcess extends PostProcess {
  37649. /**
  37650. * Creates the PassPostProcess
  37651. * @param name The name of the effect.
  37652. * @param options The required width/height ratio to downsize to before computing the render pass.
  37653. * @param camera The camera to apply the render pass to.
  37654. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37655. * @param engine The engine which the post process will be applied. (default: current engine)
  37656. * @param reusable If the post process can be reused on the same frame. (default: false)
  37657. * @param textureType The type of texture to be used when performing the post processing.
  37658. * @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)
  37659. */
  37660. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37661. }
  37662. /**
  37663. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37664. */
  37665. export class PassCubePostProcess extends PostProcess {
  37666. private _face;
  37667. /**
  37668. * Gets or sets the cube face to display.
  37669. * * 0 is +X
  37670. * * 1 is -X
  37671. * * 2 is +Y
  37672. * * 3 is -Y
  37673. * * 4 is +Z
  37674. * * 5 is -Z
  37675. */
  37676. face: number;
  37677. /**
  37678. * Creates the PassCubePostProcess
  37679. * @param name The name of the effect.
  37680. * @param options The required width/height ratio to downsize to before computing the render pass.
  37681. * @param camera The camera to apply the render pass to.
  37682. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37683. * @param engine The engine which the post process will be applied. (default: current engine)
  37684. * @param reusable If the post process can be reused on the same frame. (default: false)
  37685. * @param textureType The type of texture to be used when performing the post processing.
  37686. * @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)
  37687. */
  37688. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37689. }
  37690. }
  37691. declare module "babylonjs/Shaders/anaglyph.fragment" {
  37692. /** @hidden */
  37693. export var anaglyphPixelShader: {
  37694. name: string;
  37695. shader: string;
  37696. };
  37697. }
  37698. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  37699. import { Engine } from "babylonjs/Engines/engine";
  37700. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37701. import { Camera } from "babylonjs/Cameras/camera";
  37702. import "babylonjs/Shaders/anaglyph.fragment";
  37703. /**
  37704. * Postprocess used to generate anaglyphic rendering
  37705. */
  37706. export class AnaglyphPostProcess extends PostProcess {
  37707. private _passedProcess;
  37708. /**
  37709. * Creates a new AnaglyphPostProcess
  37710. * @param name defines postprocess name
  37711. * @param options defines creation options or target ratio scale
  37712. * @param rigCameras defines cameras using this postprocess
  37713. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37714. * @param engine defines hosting engine
  37715. * @param reusable defines if the postprocess will be reused multiple times per frame
  37716. */
  37717. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37718. }
  37719. }
  37720. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  37721. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  37722. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37723. import { Scene } from "babylonjs/scene";
  37724. import { Vector3 } from "babylonjs/Maths/math";
  37725. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37726. /**
  37727. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37728. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37729. */
  37730. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37731. /**
  37732. * Creates a new AnaglyphArcRotateCamera
  37733. * @param name defines camera name
  37734. * @param alpha defines alpha angle (in radians)
  37735. * @param beta defines beta angle (in radians)
  37736. * @param radius defines radius
  37737. * @param target defines camera target
  37738. * @param interaxialDistance defines distance between each color axis
  37739. * @param scene defines the hosting scene
  37740. */
  37741. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37742. /**
  37743. * Gets camera class name
  37744. * @returns AnaglyphArcRotateCamera
  37745. */
  37746. getClassName(): string;
  37747. }
  37748. }
  37749. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  37750. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37751. import { Scene } from "babylonjs/scene";
  37752. import { Vector3 } from "babylonjs/Maths/math";
  37753. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37754. /**
  37755. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37756. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37757. */
  37758. export class AnaglyphFreeCamera extends FreeCamera {
  37759. /**
  37760. * Creates a new AnaglyphFreeCamera
  37761. * @param name defines camera name
  37762. * @param position defines initial position
  37763. * @param interaxialDistance defines distance between each color axis
  37764. * @param scene defines the hosting scene
  37765. */
  37766. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37767. /**
  37768. * Gets camera class name
  37769. * @returns AnaglyphFreeCamera
  37770. */
  37771. getClassName(): string;
  37772. }
  37773. }
  37774. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  37775. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37776. import { Scene } from "babylonjs/scene";
  37777. import { Vector3 } from "babylonjs/Maths/math";
  37778. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37779. /**
  37780. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37781. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37782. */
  37783. export class AnaglyphGamepadCamera extends GamepadCamera {
  37784. /**
  37785. * Creates a new AnaglyphGamepadCamera
  37786. * @param name defines camera name
  37787. * @param position defines initial position
  37788. * @param interaxialDistance defines distance between each color axis
  37789. * @param scene defines the hosting scene
  37790. */
  37791. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37792. /**
  37793. * Gets camera class name
  37794. * @returns AnaglyphGamepadCamera
  37795. */
  37796. getClassName(): string;
  37797. }
  37798. }
  37799. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  37800. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37801. import { Scene } from "babylonjs/scene";
  37802. import { Vector3 } from "babylonjs/Maths/math";
  37803. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37804. /**
  37805. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37806. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37807. */
  37808. export class AnaglyphUniversalCamera extends UniversalCamera {
  37809. /**
  37810. * Creates a new AnaglyphUniversalCamera
  37811. * @param name defines camera name
  37812. * @param position defines initial position
  37813. * @param interaxialDistance defines distance between each color axis
  37814. * @param scene defines the hosting scene
  37815. */
  37816. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37817. /**
  37818. * Gets camera class name
  37819. * @returns AnaglyphUniversalCamera
  37820. */
  37821. getClassName(): string;
  37822. }
  37823. }
  37824. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  37825. /** @hidden */
  37826. export var stereoscopicInterlacePixelShader: {
  37827. name: string;
  37828. shader: string;
  37829. };
  37830. }
  37831. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  37832. import { Camera } from "babylonjs/Cameras/camera";
  37833. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37834. import { Engine } from "babylonjs/Engines/engine";
  37835. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  37836. /**
  37837. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37838. */
  37839. export class StereoscopicInterlacePostProcess extends PostProcess {
  37840. private _stepSize;
  37841. private _passedProcess;
  37842. /**
  37843. * Initializes a StereoscopicInterlacePostProcess
  37844. * @param name The name of the effect.
  37845. * @param rigCameras The rig cameras to be appled to the post process
  37846. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37847. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37848. * @param engine The engine which the post process will be applied. (default: current engine)
  37849. * @param reusable If the post process can be reused on the same frame. (default: false)
  37850. */
  37851. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37852. }
  37853. }
  37854. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  37855. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  37856. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37857. import { Scene } from "babylonjs/scene";
  37858. import { Vector3 } from "babylonjs/Maths/math";
  37859. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37860. /**
  37861. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37862. * @see http://doc.babylonjs.com/features/cameras
  37863. */
  37864. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37865. /**
  37866. * Creates a new StereoscopicArcRotateCamera
  37867. * @param name defines camera name
  37868. * @param alpha defines alpha angle (in radians)
  37869. * @param beta defines beta angle (in radians)
  37870. * @param radius defines radius
  37871. * @param target defines camera target
  37872. * @param interaxialDistance defines distance between each color axis
  37873. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37874. * @param scene defines the hosting scene
  37875. */
  37876. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37877. /**
  37878. * Gets camera class name
  37879. * @returns StereoscopicArcRotateCamera
  37880. */
  37881. getClassName(): string;
  37882. }
  37883. }
  37884. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  37885. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37886. import { Scene } from "babylonjs/scene";
  37887. import { Vector3 } from "babylonjs/Maths/math";
  37888. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37889. /**
  37890. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37891. * @see http://doc.babylonjs.com/features/cameras
  37892. */
  37893. export class StereoscopicFreeCamera extends FreeCamera {
  37894. /**
  37895. * Creates a new StereoscopicFreeCamera
  37896. * @param name defines camera name
  37897. * @param position defines initial position
  37898. * @param interaxialDistance defines distance between each color axis
  37899. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37900. * @param scene defines the hosting scene
  37901. */
  37902. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37903. /**
  37904. * Gets camera class name
  37905. * @returns StereoscopicFreeCamera
  37906. */
  37907. getClassName(): string;
  37908. }
  37909. }
  37910. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  37911. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37912. import { Scene } from "babylonjs/scene";
  37913. import { Vector3 } from "babylonjs/Maths/math";
  37914. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37915. /**
  37916. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37917. * @see http://doc.babylonjs.com/features/cameras
  37918. */
  37919. export class StereoscopicGamepadCamera extends GamepadCamera {
  37920. /**
  37921. * Creates a new StereoscopicGamepadCamera
  37922. * @param name defines camera name
  37923. * @param position defines initial position
  37924. * @param interaxialDistance defines distance between each color axis
  37925. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37926. * @param scene defines the hosting scene
  37927. */
  37928. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37929. /**
  37930. * Gets camera class name
  37931. * @returns StereoscopicGamepadCamera
  37932. */
  37933. getClassName(): string;
  37934. }
  37935. }
  37936. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  37937. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37938. import { Scene } from "babylonjs/scene";
  37939. import { Vector3 } from "babylonjs/Maths/math";
  37940. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37941. /**
  37942. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37943. * @see http://doc.babylonjs.com/features/cameras
  37944. */
  37945. export class StereoscopicUniversalCamera extends UniversalCamera {
  37946. /**
  37947. * Creates a new StereoscopicUniversalCamera
  37948. * @param name defines camera name
  37949. * @param position defines initial position
  37950. * @param interaxialDistance defines distance between each color axis
  37951. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37952. * @param scene defines the hosting scene
  37953. */
  37954. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37955. /**
  37956. * Gets camera class name
  37957. * @returns StereoscopicUniversalCamera
  37958. */
  37959. getClassName(): string;
  37960. }
  37961. }
  37962. declare module "babylonjs/Cameras/Stereoscopic/index" {
  37963. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  37964. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  37965. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  37966. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  37967. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  37968. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  37969. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  37970. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  37971. }
  37972. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  37973. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37974. import { Scene } from "babylonjs/scene";
  37975. import { Vector3 } from "babylonjs/Maths/math";
  37976. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37977. /**
  37978. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37979. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37980. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37981. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37982. */
  37983. export class VirtualJoysticksCamera extends FreeCamera {
  37984. /**
  37985. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37986. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37987. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37988. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37989. * @param name Define the name of the camera in the scene
  37990. * @param position Define the start position of the camera in the scene
  37991. * @param scene Define the scene the camera belongs to
  37992. */
  37993. constructor(name: string, position: Vector3, scene: Scene);
  37994. /**
  37995. * Gets the current object class name.
  37996. * @return the class name
  37997. */
  37998. getClassName(): string;
  37999. }
  38000. }
  38001. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38002. import { Matrix } from "babylonjs/Maths/math";
  38003. /**
  38004. * This represents all the required metrics to create a VR camera.
  38005. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38006. */
  38007. export class VRCameraMetrics {
  38008. /**
  38009. * Define the horizontal resolution off the screen.
  38010. */
  38011. hResolution: number;
  38012. /**
  38013. * Define the vertical resolution off the screen.
  38014. */
  38015. vResolution: number;
  38016. /**
  38017. * Define the horizontal screen size.
  38018. */
  38019. hScreenSize: number;
  38020. /**
  38021. * Define the vertical screen size.
  38022. */
  38023. vScreenSize: number;
  38024. /**
  38025. * Define the vertical screen center position.
  38026. */
  38027. vScreenCenter: number;
  38028. /**
  38029. * Define the distance of the eyes to the screen.
  38030. */
  38031. eyeToScreenDistance: number;
  38032. /**
  38033. * Define the distance between both lenses
  38034. */
  38035. lensSeparationDistance: number;
  38036. /**
  38037. * Define the distance between both viewer's eyes.
  38038. */
  38039. interpupillaryDistance: number;
  38040. /**
  38041. * Define the distortion factor of the VR postprocess.
  38042. * Please, touch with care.
  38043. */
  38044. distortionK: number[];
  38045. /**
  38046. * Define the chromatic aberration correction factors for the VR post process.
  38047. */
  38048. chromaAbCorrection: number[];
  38049. /**
  38050. * Define the scale factor of the post process.
  38051. * The smaller the better but the slower.
  38052. */
  38053. postProcessScaleFactor: number;
  38054. /**
  38055. * Define an offset for the lens center.
  38056. */
  38057. lensCenterOffset: number;
  38058. /**
  38059. * Define if the current vr camera should compensate the distortion of the lense or not.
  38060. */
  38061. compensateDistortion: boolean;
  38062. /**
  38063. * Gets the rendering aspect ratio based on the provided resolutions.
  38064. */
  38065. readonly aspectRatio: number;
  38066. /**
  38067. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38068. */
  38069. readonly aspectRatioFov: number;
  38070. /**
  38071. * @hidden
  38072. */
  38073. readonly leftHMatrix: Matrix;
  38074. /**
  38075. * @hidden
  38076. */
  38077. readonly rightHMatrix: Matrix;
  38078. /**
  38079. * @hidden
  38080. */
  38081. readonly leftPreViewMatrix: Matrix;
  38082. /**
  38083. * @hidden
  38084. */
  38085. readonly rightPreViewMatrix: Matrix;
  38086. /**
  38087. * Get the default VRMetrics based on the most generic setup.
  38088. * @returns the default vr metrics
  38089. */
  38090. static GetDefault(): VRCameraMetrics;
  38091. }
  38092. }
  38093. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38094. /** @hidden */
  38095. export var vrDistortionCorrectionPixelShader: {
  38096. name: string;
  38097. shader: string;
  38098. };
  38099. }
  38100. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38101. import { Camera } from "babylonjs/Cameras/camera";
  38102. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38103. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38104. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38105. /**
  38106. * VRDistortionCorrectionPostProcess used for mobile VR
  38107. */
  38108. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38109. private _isRightEye;
  38110. private _distortionFactors;
  38111. private _postProcessScaleFactor;
  38112. private _lensCenterOffset;
  38113. private _scaleIn;
  38114. private _scaleFactor;
  38115. private _lensCenter;
  38116. /**
  38117. * Initializes the VRDistortionCorrectionPostProcess
  38118. * @param name The name of the effect.
  38119. * @param camera The camera to apply the render pass to.
  38120. * @param isRightEye If this is for the right eye distortion
  38121. * @param vrMetrics All the required metrics for the VR camera
  38122. */
  38123. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38124. }
  38125. }
  38126. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38127. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38128. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38129. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38130. import { Scene } from "babylonjs/scene";
  38131. import { Vector3 } from "babylonjs/Maths/math";
  38132. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38133. import "babylonjs/Cameras/RigModes/vrRigMode";
  38134. /**
  38135. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38136. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38137. */
  38138. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38139. /**
  38140. * Creates a new VRDeviceOrientationArcRotateCamera
  38141. * @param name defines camera name
  38142. * @param alpha defines the camera rotation along the logitudinal axis
  38143. * @param beta defines the camera rotation along the latitudinal axis
  38144. * @param radius defines the camera distance from its target
  38145. * @param target defines the camera target
  38146. * @param scene defines the scene the camera belongs to
  38147. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38148. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38149. */
  38150. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38151. /**
  38152. * Gets camera class name
  38153. * @returns VRDeviceOrientationArcRotateCamera
  38154. */
  38155. getClassName(): string;
  38156. }
  38157. }
  38158. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38159. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38160. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38161. import { Scene } from "babylonjs/scene";
  38162. import { Vector3 } from "babylonjs/Maths/math";
  38163. import "babylonjs/Cameras/RigModes/vrRigMode";
  38164. /**
  38165. * Camera used to simulate VR rendering (based on FreeCamera)
  38166. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38167. */
  38168. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38169. /**
  38170. * Creates a new VRDeviceOrientationFreeCamera
  38171. * @param name defines camera name
  38172. * @param position defines the start position of the camera
  38173. * @param scene defines the scene the camera belongs to
  38174. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38175. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38176. */
  38177. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38178. /**
  38179. * Gets camera class name
  38180. * @returns VRDeviceOrientationFreeCamera
  38181. */
  38182. getClassName(): string;
  38183. }
  38184. }
  38185. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38186. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38187. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38188. import { Scene } from "babylonjs/scene";
  38189. import { Vector3 } from "babylonjs/Maths/math";
  38190. /**
  38191. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38192. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38193. */
  38194. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38195. /**
  38196. * Creates a new VRDeviceOrientationGamepadCamera
  38197. * @param name defines camera name
  38198. * @param position defines the start position of the camera
  38199. * @param scene defines the scene the camera belongs to
  38200. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38201. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38202. */
  38203. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38204. /**
  38205. * Gets camera class name
  38206. * @returns VRDeviceOrientationGamepadCamera
  38207. */
  38208. getClassName(): string;
  38209. }
  38210. }
  38211. declare module "babylonjs/Gamepads/xboxGamepad" {
  38212. import { Observable } from "babylonjs/Misc/observable";
  38213. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38214. /**
  38215. * Defines supported buttons for XBox360 compatible gamepads
  38216. */
  38217. export enum Xbox360Button {
  38218. /** A */
  38219. A = 0,
  38220. /** B */
  38221. B = 1,
  38222. /** X */
  38223. X = 2,
  38224. /** Y */
  38225. Y = 3,
  38226. /** Start */
  38227. Start = 4,
  38228. /** Back */
  38229. Back = 5,
  38230. /** Left button */
  38231. LB = 6,
  38232. /** Right button */
  38233. RB = 7,
  38234. /** Left stick */
  38235. LeftStick = 8,
  38236. /** Right stick */
  38237. RightStick = 9
  38238. }
  38239. /** Defines values for XBox360 DPad */
  38240. export enum Xbox360Dpad {
  38241. /** Up */
  38242. Up = 0,
  38243. /** Down */
  38244. Down = 1,
  38245. /** Left */
  38246. Left = 2,
  38247. /** Right */
  38248. Right = 3
  38249. }
  38250. /**
  38251. * Defines a XBox360 gamepad
  38252. */
  38253. export class Xbox360Pad extends Gamepad {
  38254. private _leftTrigger;
  38255. private _rightTrigger;
  38256. private _onlefttriggerchanged;
  38257. private _onrighttriggerchanged;
  38258. private _onbuttondown;
  38259. private _onbuttonup;
  38260. private _ondpaddown;
  38261. private _ondpadup;
  38262. /** Observable raised when a button is pressed */
  38263. onButtonDownObservable: Observable<Xbox360Button>;
  38264. /** Observable raised when a button is released */
  38265. onButtonUpObservable: Observable<Xbox360Button>;
  38266. /** Observable raised when a pad is pressed */
  38267. onPadDownObservable: Observable<Xbox360Dpad>;
  38268. /** Observable raised when a pad is released */
  38269. onPadUpObservable: Observable<Xbox360Dpad>;
  38270. private _buttonA;
  38271. private _buttonB;
  38272. private _buttonX;
  38273. private _buttonY;
  38274. private _buttonBack;
  38275. private _buttonStart;
  38276. private _buttonLB;
  38277. private _buttonRB;
  38278. private _buttonLeftStick;
  38279. private _buttonRightStick;
  38280. private _dPadUp;
  38281. private _dPadDown;
  38282. private _dPadLeft;
  38283. private _dPadRight;
  38284. private _isXboxOnePad;
  38285. /**
  38286. * Creates a new XBox360 gamepad object
  38287. * @param id defines the id of this gamepad
  38288. * @param index defines its index
  38289. * @param gamepad defines the internal HTML gamepad object
  38290. * @param xboxOne defines if it is a XBox One gamepad
  38291. */
  38292. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38293. /**
  38294. * Defines the callback to call when left trigger is pressed
  38295. * @param callback defines the callback to use
  38296. */
  38297. onlefttriggerchanged(callback: (value: number) => void): void;
  38298. /**
  38299. * Defines the callback to call when right trigger is pressed
  38300. * @param callback defines the callback to use
  38301. */
  38302. onrighttriggerchanged(callback: (value: number) => void): void;
  38303. /**
  38304. * Gets the left trigger value
  38305. */
  38306. /**
  38307. * Sets the left trigger value
  38308. */
  38309. leftTrigger: number;
  38310. /**
  38311. * Gets the right trigger value
  38312. */
  38313. /**
  38314. * Sets the right trigger value
  38315. */
  38316. rightTrigger: number;
  38317. /**
  38318. * Defines the callback to call when a button is pressed
  38319. * @param callback defines the callback to use
  38320. */
  38321. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38322. /**
  38323. * Defines the callback to call when a button is released
  38324. * @param callback defines the callback to use
  38325. */
  38326. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38327. /**
  38328. * Defines the callback to call when a pad is pressed
  38329. * @param callback defines the callback to use
  38330. */
  38331. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38332. /**
  38333. * Defines the callback to call when a pad is released
  38334. * @param callback defines the callback to use
  38335. */
  38336. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38337. private _setButtonValue;
  38338. private _setDPadValue;
  38339. /**
  38340. * Gets the value of the `A` button
  38341. */
  38342. /**
  38343. * Sets the value of the `A` button
  38344. */
  38345. buttonA: number;
  38346. /**
  38347. * Gets the value of the `B` button
  38348. */
  38349. /**
  38350. * Sets the value of the `B` button
  38351. */
  38352. buttonB: number;
  38353. /**
  38354. * Gets the value of the `X` button
  38355. */
  38356. /**
  38357. * Sets the value of the `X` button
  38358. */
  38359. buttonX: number;
  38360. /**
  38361. * Gets the value of the `Y` button
  38362. */
  38363. /**
  38364. * Sets the value of the `Y` button
  38365. */
  38366. buttonY: number;
  38367. /**
  38368. * Gets the value of the `Start` button
  38369. */
  38370. /**
  38371. * Sets the value of the `Start` button
  38372. */
  38373. buttonStart: number;
  38374. /**
  38375. * Gets the value of the `Back` button
  38376. */
  38377. /**
  38378. * Sets the value of the `Back` button
  38379. */
  38380. buttonBack: number;
  38381. /**
  38382. * Gets the value of the `Left` button
  38383. */
  38384. /**
  38385. * Sets the value of the `Left` button
  38386. */
  38387. buttonLB: number;
  38388. /**
  38389. * Gets the value of the `Right` button
  38390. */
  38391. /**
  38392. * Sets the value of the `Right` button
  38393. */
  38394. buttonRB: number;
  38395. /**
  38396. * Gets the value of the Left joystick
  38397. */
  38398. /**
  38399. * Sets the value of the Left joystick
  38400. */
  38401. buttonLeftStick: number;
  38402. /**
  38403. * Gets the value of the Right joystick
  38404. */
  38405. /**
  38406. * Sets the value of the Right joystick
  38407. */
  38408. buttonRightStick: number;
  38409. /**
  38410. * Gets the value of D-pad up
  38411. */
  38412. /**
  38413. * Sets the value of D-pad up
  38414. */
  38415. dPadUp: number;
  38416. /**
  38417. * Gets the value of D-pad down
  38418. */
  38419. /**
  38420. * Sets the value of D-pad down
  38421. */
  38422. dPadDown: number;
  38423. /**
  38424. * Gets the value of D-pad left
  38425. */
  38426. /**
  38427. * Sets the value of D-pad left
  38428. */
  38429. dPadLeft: number;
  38430. /**
  38431. * Gets the value of D-pad right
  38432. */
  38433. /**
  38434. * Sets the value of D-pad right
  38435. */
  38436. dPadRight: number;
  38437. /**
  38438. * Force the gamepad to synchronize with device values
  38439. */
  38440. update(): void;
  38441. /**
  38442. * Disposes the gamepad
  38443. */
  38444. dispose(): void;
  38445. }
  38446. }
  38447. declare module "babylonjs/Materials/pushMaterial" {
  38448. import { Nullable } from "babylonjs/types";
  38449. import { Scene } from "babylonjs/scene";
  38450. import { Matrix } from "babylonjs/Maths/math";
  38451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38452. import { Mesh } from "babylonjs/Meshes/mesh";
  38453. import { Material } from "babylonjs/Materials/material";
  38454. import { Effect } from "babylonjs/Materials/effect";
  38455. /**
  38456. * Base class of materials working in push mode in babylon JS
  38457. * @hidden
  38458. */
  38459. export class PushMaterial extends Material {
  38460. protected _activeEffect: Effect;
  38461. protected _normalMatrix: Matrix;
  38462. /**
  38463. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38464. * This means that the material can keep using a previous shader while a new one is being compiled.
  38465. * This is mostly used when shader parallel compilation is supported (true by default)
  38466. */
  38467. allowShaderHotSwapping: boolean;
  38468. constructor(name: string, scene: Scene);
  38469. getEffect(): Effect;
  38470. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38471. /**
  38472. * Binds the given world matrix to the active effect
  38473. *
  38474. * @param world the matrix to bind
  38475. */
  38476. bindOnlyWorldMatrix(world: Matrix): void;
  38477. /**
  38478. * Binds the given normal matrix to the active effect
  38479. *
  38480. * @param normalMatrix the matrix to bind
  38481. */
  38482. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38483. bind(world: Matrix, mesh?: Mesh): void;
  38484. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38485. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38486. }
  38487. }
  38488. declare module "babylonjs/Materials/materialFlags" {
  38489. /**
  38490. * This groups all the flags used to control the materials channel.
  38491. */
  38492. export class MaterialFlags {
  38493. private static _DiffuseTextureEnabled;
  38494. /**
  38495. * Are diffuse textures enabled in the application.
  38496. */
  38497. static DiffuseTextureEnabled: boolean;
  38498. private static _AmbientTextureEnabled;
  38499. /**
  38500. * Are ambient textures enabled in the application.
  38501. */
  38502. static AmbientTextureEnabled: boolean;
  38503. private static _OpacityTextureEnabled;
  38504. /**
  38505. * Are opacity textures enabled in the application.
  38506. */
  38507. static OpacityTextureEnabled: boolean;
  38508. private static _ReflectionTextureEnabled;
  38509. /**
  38510. * Are reflection textures enabled in the application.
  38511. */
  38512. static ReflectionTextureEnabled: boolean;
  38513. private static _EmissiveTextureEnabled;
  38514. /**
  38515. * Are emissive textures enabled in the application.
  38516. */
  38517. static EmissiveTextureEnabled: boolean;
  38518. private static _SpecularTextureEnabled;
  38519. /**
  38520. * Are specular textures enabled in the application.
  38521. */
  38522. static SpecularTextureEnabled: boolean;
  38523. private static _BumpTextureEnabled;
  38524. /**
  38525. * Are bump textures enabled in the application.
  38526. */
  38527. static BumpTextureEnabled: boolean;
  38528. private static _LightmapTextureEnabled;
  38529. /**
  38530. * Are lightmap textures enabled in the application.
  38531. */
  38532. static LightmapTextureEnabled: boolean;
  38533. private static _RefractionTextureEnabled;
  38534. /**
  38535. * Are refraction textures enabled in the application.
  38536. */
  38537. static RefractionTextureEnabled: boolean;
  38538. private static _ColorGradingTextureEnabled;
  38539. /**
  38540. * Are color grading textures enabled in the application.
  38541. */
  38542. static ColorGradingTextureEnabled: boolean;
  38543. private static _FresnelEnabled;
  38544. /**
  38545. * Are fresnels enabled in the application.
  38546. */
  38547. static FresnelEnabled: boolean;
  38548. private static _ClearCoatTextureEnabled;
  38549. /**
  38550. * Are clear coat textures enabled in the application.
  38551. */
  38552. static ClearCoatTextureEnabled: boolean;
  38553. private static _ClearCoatBumpTextureEnabled;
  38554. /**
  38555. * Are clear coat bump textures enabled in the application.
  38556. */
  38557. static ClearCoatBumpTextureEnabled: boolean;
  38558. private static _ClearCoatTintTextureEnabled;
  38559. /**
  38560. * Are clear coat tint textures enabled in the application.
  38561. */
  38562. static ClearCoatTintTextureEnabled: boolean;
  38563. private static _SheenTextureEnabled;
  38564. /**
  38565. * Are sheen textures enabled in the application.
  38566. */
  38567. static SheenTextureEnabled: boolean;
  38568. private static _AnisotropicTextureEnabled;
  38569. /**
  38570. * Are anisotropic textures enabled in the application.
  38571. */
  38572. static AnisotropicTextureEnabled: boolean;
  38573. }
  38574. }
  38575. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38576. /** @hidden */
  38577. export var defaultFragmentDeclaration: {
  38578. name: string;
  38579. shader: string;
  38580. };
  38581. }
  38582. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38583. /** @hidden */
  38584. export var defaultUboDeclaration: {
  38585. name: string;
  38586. shader: string;
  38587. };
  38588. }
  38589. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38590. /** @hidden */
  38591. export var lightFragmentDeclaration: {
  38592. name: string;
  38593. shader: string;
  38594. };
  38595. }
  38596. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38597. /** @hidden */
  38598. export var lightUboDeclaration: {
  38599. name: string;
  38600. shader: string;
  38601. };
  38602. }
  38603. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38604. /** @hidden */
  38605. export var lightsFragmentFunctions: {
  38606. name: string;
  38607. shader: string;
  38608. };
  38609. }
  38610. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  38611. /** @hidden */
  38612. export var shadowsFragmentFunctions: {
  38613. name: string;
  38614. shader: string;
  38615. };
  38616. }
  38617. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  38618. /** @hidden */
  38619. export var fresnelFunction: {
  38620. name: string;
  38621. shader: string;
  38622. };
  38623. }
  38624. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  38625. /** @hidden */
  38626. export var reflectionFunction: {
  38627. name: string;
  38628. shader: string;
  38629. };
  38630. }
  38631. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  38632. /** @hidden */
  38633. export var bumpFragmentFunctions: {
  38634. name: string;
  38635. shader: string;
  38636. };
  38637. }
  38638. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  38639. /** @hidden */
  38640. export var logDepthDeclaration: {
  38641. name: string;
  38642. shader: string;
  38643. };
  38644. }
  38645. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  38646. /** @hidden */
  38647. export var bumpFragment: {
  38648. name: string;
  38649. shader: string;
  38650. };
  38651. }
  38652. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  38653. /** @hidden */
  38654. export var depthPrePass: {
  38655. name: string;
  38656. shader: string;
  38657. };
  38658. }
  38659. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  38660. /** @hidden */
  38661. export var lightFragment: {
  38662. name: string;
  38663. shader: string;
  38664. };
  38665. }
  38666. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  38667. /** @hidden */
  38668. export var logDepthFragment: {
  38669. name: string;
  38670. shader: string;
  38671. };
  38672. }
  38673. declare module "babylonjs/Shaders/default.fragment" {
  38674. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  38675. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38676. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38677. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38678. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38679. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  38680. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  38681. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  38682. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  38683. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  38684. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  38685. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  38686. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  38687. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38688. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  38689. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  38690. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  38691. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  38692. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  38693. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  38694. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  38695. /** @hidden */
  38696. export var defaultPixelShader: {
  38697. name: string;
  38698. shader: string;
  38699. };
  38700. }
  38701. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  38702. /** @hidden */
  38703. export var defaultVertexDeclaration: {
  38704. name: string;
  38705. shader: string;
  38706. };
  38707. }
  38708. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  38709. /** @hidden */
  38710. export var bumpVertexDeclaration: {
  38711. name: string;
  38712. shader: string;
  38713. };
  38714. }
  38715. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  38716. /** @hidden */
  38717. export var bumpVertex: {
  38718. name: string;
  38719. shader: string;
  38720. };
  38721. }
  38722. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  38723. /** @hidden */
  38724. export var fogVertex: {
  38725. name: string;
  38726. shader: string;
  38727. };
  38728. }
  38729. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  38730. /** @hidden */
  38731. export var shadowsVertex: {
  38732. name: string;
  38733. shader: string;
  38734. };
  38735. }
  38736. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  38737. /** @hidden */
  38738. export var pointCloudVertex: {
  38739. name: string;
  38740. shader: string;
  38741. };
  38742. }
  38743. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  38744. /** @hidden */
  38745. export var logDepthVertex: {
  38746. name: string;
  38747. shader: string;
  38748. };
  38749. }
  38750. declare module "babylonjs/Shaders/default.vertex" {
  38751. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  38752. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38753. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38754. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  38755. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  38756. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  38757. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  38758. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  38759. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38760. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38761. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  38762. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  38763. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38764. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  38765. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  38766. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  38767. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  38768. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  38769. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  38770. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  38771. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  38772. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  38773. /** @hidden */
  38774. export var defaultVertexShader: {
  38775. name: string;
  38776. shader: string;
  38777. };
  38778. }
  38779. declare module "babylonjs/Materials/standardMaterial" {
  38780. import { SmartArray } from "babylonjs/Misc/smartArray";
  38781. import { IAnimatable } from "babylonjs/Misc/tools";
  38782. import { Nullable } from "babylonjs/types";
  38783. import { Scene } from "babylonjs/scene";
  38784. import { Matrix, Color3 } from "babylonjs/Maths/math";
  38785. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38786. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38787. import { Mesh } from "babylonjs/Meshes/mesh";
  38788. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  38789. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38790. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38791. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  38792. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  38793. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38794. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38795. import "babylonjs/Shaders/default.fragment";
  38796. import "babylonjs/Shaders/default.vertex";
  38797. /** @hidden */
  38798. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38799. MAINUV1: boolean;
  38800. MAINUV2: boolean;
  38801. DIFFUSE: boolean;
  38802. DIFFUSEDIRECTUV: number;
  38803. AMBIENT: boolean;
  38804. AMBIENTDIRECTUV: number;
  38805. OPACITY: boolean;
  38806. OPACITYDIRECTUV: number;
  38807. OPACITYRGB: boolean;
  38808. REFLECTION: boolean;
  38809. EMISSIVE: boolean;
  38810. EMISSIVEDIRECTUV: number;
  38811. SPECULAR: boolean;
  38812. SPECULARDIRECTUV: number;
  38813. BUMP: boolean;
  38814. BUMPDIRECTUV: number;
  38815. PARALLAX: boolean;
  38816. PARALLAXOCCLUSION: boolean;
  38817. SPECULAROVERALPHA: boolean;
  38818. CLIPPLANE: boolean;
  38819. CLIPPLANE2: boolean;
  38820. CLIPPLANE3: boolean;
  38821. CLIPPLANE4: boolean;
  38822. ALPHATEST: boolean;
  38823. DEPTHPREPASS: boolean;
  38824. ALPHAFROMDIFFUSE: boolean;
  38825. POINTSIZE: boolean;
  38826. FOG: boolean;
  38827. SPECULARTERM: boolean;
  38828. DIFFUSEFRESNEL: boolean;
  38829. OPACITYFRESNEL: boolean;
  38830. REFLECTIONFRESNEL: boolean;
  38831. REFRACTIONFRESNEL: boolean;
  38832. EMISSIVEFRESNEL: boolean;
  38833. FRESNEL: boolean;
  38834. NORMAL: boolean;
  38835. UV1: boolean;
  38836. UV2: boolean;
  38837. VERTEXCOLOR: boolean;
  38838. VERTEXALPHA: boolean;
  38839. NUM_BONE_INFLUENCERS: number;
  38840. BonesPerMesh: number;
  38841. BONETEXTURE: boolean;
  38842. INSTANCES: boolean;
  38843. GLOSSINESS: boolean;
  38844. ROUGHNESS: boolean;
  38845. EMISSIVEASILLUMINATION: boolean;
  38846. LINKEMISSIVEWITHDIFFUSE: boolean;
  38847. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38848. LIGHTMAP: boolean;
  38849. LIGHTMAPDIRECTUV: number;
  38850. OBJECTSPACE_NORMALMAP: boolean;
  38851. USELIGHTMAPASSHADOWMAP: boolean;
  38852. REFLECTIONMAP_3D: boolean;
  38853. REFLECTIONMAP_SPHERICAL: boolean;
  38854. REFLECTIONMAP_PLANAR: boolean;
  38855. REFLECTIONMAP_CUBIC: boolean;
  38856. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38857. REFLECTIONMAP_PROJECTION: boolean;
  38858. REFLECTIONMAP_SKYBOX: boolean;
  38859. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38860. REFLECTIONMAP_EXPLICIT: boolean;
  38861. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38862. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38863. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38864. INVERTCUBICMAP: boolean;
  38865. LOGARITHMICDEPTH: boolean;
  38866. REFRACTION: boolean;
  38867. REFRACTIONMAP_3D: boolean;
  38868. REFLECTIONOVERALPHA: boolean;
  38869. TWOSIDEDLIGHTING: boolean;
  38870. SHADOWFLOAT: boolean;
  38871. MORPHTARGETS: boolean;
  38872. MORPHTARGETS_NORMAL: boolean;
  38873. MORPHTARGETS_TANGENT: boolean;
  38874. NUM_MORPH_INFLUENCERS: number;
  38875. NONUNIFORMSCALING: boolean;
  38876. PREMULTIPLYALPHA: boolean;
  38877. IMAGEPROCESSING: boolean;
  38878. VIGNETTE: boolean;
  38879. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38880. VIGNETTEBLENDMODEOPAQUE: boolean;
  38881. TONEMAPPING: boolean;
  38882. TONEMAPPING_ACES: boolean;
  38883. CONTRAST: boolean;
  38884. COLORCURVES: boolean;
  38885. COLORGRADING: boolean;
  38886. COLORGRADING3D: boolean;
  38887. SAMPLER3DGREENDEPTH: boolean;
  38888. SAMPLER3DBGRMAP: boolean;
  38889. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38890. /**
  38891. * If the reflection texture on this material is in linear color space
  38892. * @hidden
  38893. */
  38894. IS_REFLECTION_LINEAR: boolean;
  38895. /**
  38896. * If the refraction texture on this material is in linear color space
  38897. * @hidden
  38898. */
  38899. IS_REFRACTION_LINEAR: boolean;
  38900. EXPOSURE: boolean;
  38901. constructor();
  38902. setReflectionMode(modeToEnable: string): void;
  38903. }
  38904. /**
  38905. * This is the default material used in Babylon. It is the best trade off between quality
  38906. * and performances.
  38907. * @see http://doc.babylonjs.com/babylon101/materials
  38908. */
  38909. export class StandardMaterial extends PushMaterial {
  38910. private _diffuseTexture;
  38911. /**
  38912. * The basic texture of the material as viewed under a light.
  38913. */
  38914. diffuseTexture: Nullable<BaseTexture>;
  38915. private _ambientTexture;
  38916. /**
  38917. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38918. */
  38919. ambientTexture: Nullable<BaseTexture>;
  38920. private _opacityTexture;
  38921. /**
  38922. * Define the transparency of the material from a texture.
  38923. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38924. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38925. */
  38926. opacityTexture: Nullable<BaseTexture>;
  38927. private _reflectionTexture;
  38928. /**
  38929. * Define the texture used to display the reflection.
  38930. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38931. */
  38932. reflectionTexture: Nullable<BaseTexture>;
  38933. private _emissiveTexture;
  38934. /**
  38935. * Define texture of the material as if self lit.
  38936. * This will be mixed in the final result even in the absence of light.
  38937. */
  38938. emissiveTexture: Nullable<BaseTexture>;
  38939. private _specularTexture;
  38940. /**
  38941. * Define how the color and intensity of the highlight given by the light in the material.
  38942. */
  38943. specularTexture: Nullable<BaseTexture>;
  38944. private _bumpTexture;
  38945. /**
  38946. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38947. * 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.
  38948. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38949. */
  38950. bumpTexture: Nullable<BaseTexture>;
  38951. private _lightmapTexture;
  38952. /**
  38953. * Complex lighting can be computationally expensive to compute at runtime.
  38954. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38955. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38956. */
  38957. lightmapTexture: Nullable<BaseTexture>;
  38958. private _refractionTexture;
  38959. /**
  38960. * Define the texture used to display the refraction.
  38961. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38962. */
  38963. refractionTexture: Nullable<BaseTexture>;
  38964. /**
  38965. * The color of the material lit by the environmental background lighting.
  38966. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38967. */
  38968. ambientColor: Color3;
  38969. /**
  38970. * The basic color of the material as viewed under a light.
  38971. */
  38972. diffuseColor: Color3;
  38973. /**
  38974. * Define how the color and intensity of the highlight given by the light in the material.
  38975. */
  38976. specularColor: Color3;
  38977. /**
  38978. * Define the color of the material as if self lit.
  38979. * This will be mixed in the final result even in the absence of light.
  38980. */
  38981. emissiveColor: Color3;
  38982. /**
  38983. * Defines how sharp are the highlights in the material.
  38984. * The bigger the value the sharper giving a more glossy feeling to the result.
  38985. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38986. */
  38987. specularPower: number;
  38988. private _useAlphaFromDiffuseTexture;
  38989. /**
  38990. * Does the transparency come from the diffuse texture alpha channel.
  38991. */
  38992. useAlphaFromDiffuseTexture: boolean;
  38993. private _useEmissiveAsIllumination;
  38994. /**
  38995. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38996. */
  38997. useEmissiveAsIllumination: boolean;
  38998. private _linkEmissiveWithDiffuse;
  38999. /**
  39000. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39001. * the emissive level when the final color is close to one.
  39002. */
  39003. linkEmissiveWithDiffuse: boolean;
  39004. private _useSpecularOverAlpha;
  39005. /**
  39006. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39007. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39008. */
  39009. useSpecularOverAlpha: boolean;
  39010. private _useReflectionOverAlpha;
  39011. /**
  39012. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39013. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39014. */
  39015. useReflectionOverAlpha: boolean;
  39016. private _disableLighting;
  39017. /**
  39018. * Does lights from the scene impacts this material.
  39019. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39020. */
  39021. disableLighting: boolean;
  39022. private _useObjectSpaceNormalMap;
  39023. /**
  39024. * Allows using an object space normal map (instead of tangent space).
  39025. */
  39026. useObjectSpaceNormalMap: boolean;
  39027. private _useParallax;
  39028. /**
  39029. * Is parallax enabled or not.
  39030. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39031. */
  39032. useParallax: boolean;
  39033. private _useParallaxOcclusion;
  39034. /**
  39035. * Is parallax occlusion enabled or not.
  39036. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39037. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39038. */
  39039. useParallaxOcclusion: boolean;
  39040. /**
  39041. * 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.
  39042. */
  39043. parallaxScaleBias: number;
  39044. private _roughness;
  39045. /**
  39046. * Helps to define how blurry the reflections should appears in the material.
  39047. */
  39048. roughness: number;
  39049. /**
  39050. * In case of refraction, define the value of the indice of refraction.
  39051. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39052. */
  39053. indexOfRefraction: number;
  39054. /**
  39055. * Invert the refraction texture alongside the y axis.
  39056. * It can be useful with procedural textures or probe for instance.
  39057. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39058. */
  39059. invertRefractionY: boolean;
  39060. /**
  39061. * Defines the alpha limits in alpha test mode.
  39062. */
  39063. alphaCutOff: number;
  39064. private _useLightmapAsShadowmap;
  39065. /**
  39066. * In case of light mapping, define whether the map contains light or shadow informations.
  39067. */
  39068. useLightmapAsShadowmap: boolean;
  39069. private _diffuseFresnelParameters;
  39070. /**
  39071. * Define the diffuse fresnel parameters of the material.
  39072. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39073. */
  39074. diffuseFresnelParameters: FresnelParameters;
  39075. private _opacityFresnelParameters;
  39076. /**
  39077. * Define the opacity fresnel parameters of the material.
  39078. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39079. */
  39080. opacityFresnelParameters: FresnelParameters;
  39081. private _reflectionFresnelParameters;
  39082. /**
  39083. * Define the reflection fresnel parameters of the material.
  39084. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39085. */
  39086. reflectionFresnelParameters: FresnelParameters;
  39087. private _refractionFresnelParameters;
  39088. /**
  39089. * Define the refraction fresnel parameters of the material.
  39090. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39091. */
  39092. refractionFresnelParameters: FresnelParameters;
  39093. private _emissiveFresnelParameters;
  39094. /**
  39095. * Define the emissive fresnel parameters of the material.
  39096. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39097. */
  39098. emissiveFresnelParameters: FresnelParameters;
  39099. private _useReflectionFresnelFromSpecular;
  39100. /**
  39101. * If true automatically deducts the fresnels values from the material specularity.
  39102. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39103. */
  39104. useReflectionFresnelFromSpecular: boolean;
  39105. private _useGlossinessFromSpecularMapAlpha;
  39106. /**
  39107. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39108. */
  39109. useGlossinessFromSpecularMapAlpha: boolean;
  39110. private _maxSimultaneousLights;
  39111. /**
  39112. * Defines the maximum number of lights that can be used in the material
  39113. */
  39114. maxSimultaneousLights: number;
  39115. private _invertNormalMapX;
  39116. /**
  39117. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39118. */
  39119. invertNormalMapX: boolean;
  39120. private _invertNormalMapY;
  39121. /**
  39122. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39123. */
  39124. invertNormalMapY: boolean;
  39125. private _twoSidedLighting;
  39126. /**
  39127. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39128. */
  39129. twoSidedLighting: boolean;
  39130. /**
  39131. * Default configuration related to image processing available in the standard Material.
  39132. */
  39133. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39134. /**
  39135. * Gets the image processing configuration used either in this material.
  39136. */
  39137. /**
  39138. * Sets the Default image processing configuration used either in the this material.
  39139. *
  39140. * If sets to null, the scene one is in use.
  39141. */
  39142. imageProcessingConfiguration: ImageProcessingConfiguration;
  39143. /**
  39144. * Keep track of the image processing observer to allow dispose and replace.
  39145. */
  39146. private _imageProcessingObserver;
  39147. /**
  39148. * Attaches a new image processing configuration to the Standard Material.
  39149. * @param configuration
  39150. */
  39151. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39152. /**
  39153. * Gets wether the color curves effect is enabled.
  39154. */
  39155. /**
  39156. * Sets wether the color curves effect is enabled.
  39157. */
  39158. cameraColorCurvesEnabled: boolean;
  39159. /**
  39160. * Gets wether the color grading effect is enabled.
  39161. */
  39162. /**
  39163. * Gets wether the color grading effect is enabled.
  39164. */
  39165. cameraColorGradingEnabled: boolean;
  39166. /**
  39167. * Gets wether tonemapping is enabled or not.
  39168. */
  39169. /**
  39170. * Sets wether tonemapping is enabled or not
  39171. */
  39172. cameraToneMappingEnabled: boolean;
  39173. /**
  39174. * The camera exposure used on this material.
  39175. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39176. * This corresponds to a photographic exposure.
  39177. */
  39178. /**
  39179. * The camera exposure used on this material.
  39180. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39181. * This corresponds to a photographic exposure.
  39182. */
  39183. cameraExposure: number;
  39184. /**
  39185. * Gets The camera contrast used on this material.
  39186. */
  39187. /**
  39188. * Sets The camera contrast used on this material.
  39189. */
  39190. cameraContrast: number;
  39191. /**
  39192. * Gets the Color Grading 2D Lookup Texture.
  39193. */
  39194. /**
  39195. * Sets the Color Grading 2D Lookup Texture.
  39196. */
  39197. cameraColorGradingTexture: Nullable<BaseTexture>;
  39198. /**
  39199. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39200. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39201. * 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;
  39202. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39203. */
  39204. /**
  39205. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39206. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39207. * 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;
  39208. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39209. */
  39210. cameraColorCurves: Nullable<ColorCurves>;
  39211. /**
  39212. * Custom callback helping to override the default shader used in the material.
  39213. */
  39214. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39215. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39216. protected _worldViewProjectionMatrix: Matrix;
  39217. protected _globalAmbientColor: Color3;
  39218. protected _useLogarithmicDepth: boolean;
  39219. /**
  39220. * Instantiates a new standard material.
  39221. * This is the default material used in Babylon. It is the best trade off between quality
  39222. * and performances.
  39223. * @see http://doc.babylonjs.com/babylon101/materials
  39224. * @param name Define the name of the material in the scene
  39225. * @param scene Define the scene the material belong to
  39226. */
  39227. constructor(name: string, scene: Scene);
  39228. /**
  39229. * Gets a boolean indicating that current material needs to register RTT
  39230. */
  39231. readonly hasRenderTargetTextures: boolean;
  39232. /**
  39233. * Gets the current class name of the material e.g. "StandardMaterial"
  39234. * Mainly use in serialization.
  39235. * @returns the class name
  39236. */
  39237. getClassName(): string;
  39238. /**
  39239. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39240. * You can try switching to logarithmic depth.
  39241. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39242. */
  39243. useLogarithmicDepth: boolean;
  39244. /**
  39245. * Specifies if the material will require alpha blending
  39246. * @returns a boolean specifying if alpha blending is needed
  39247. */
  39248. needAlphaBlending(): boolean;
  39249. /**
  39250. * Specifies if this material should be rendered in alpha test mode
  39251. * @returns a boolean specifying if an alpha test is needed.
  39252. */
  39253. needAlphaTesting(): boolean;
  39254. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39255. /**
  39256. * Get the texture used for alpha test purpose.
  39257. * @returns the diffuse texture in case of the standard material.
  39258. */
  39259. getAlphaTestTexture(): Nullable<BaseTexture>;
  39260. /**
  39261. * Get if the submesh is ready to be used and all its information available.
  39262. * Child classes can use it to update shaders
  39263. * @param mesh defines the mesh to check
  39264. * @param subMesh defines which submesh to check
  39265. * @param useInstances specifies that instances should be used
  39266. * @returns a boolean indicating that the submesh is ready or not
  39267. */
  39268. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39269. /**
  39270. * Builds the material UBO layouts.
  39271. * Used internally during the effect preparation.
  39272. */
  39273. buildUniformLayout(): void;
  39274. /**
  39275. * Unbinds the material from the mesh
  39276. */
  39277. unbind(): void;
  39278. /**
  39279. * Binds the submesh to this material by preparing the effect and shader to draw
  39280. * @param world defines the world transformation matrix
  39281. * @param mesh defines the mesh containing the submesh
  39282. * @param subMesh defines the submesh to bind the material to
  39283. */
  39284. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39285. /**
  39286. * Get the list of animatables in the material.
  39287. * @returns the list of animatables object used in the material
  39288. */
  39289. getAnimatables(): IAnimatable[];
  39290. /**
  39291. * Gets the active textures from the material
  39292. * @returns an array of textures
  39293. */
  39294. getActiveTextures(): BaseTexture[];
  39295. /**
  39296. * Specifies if the material uses a texture
  39297. * @param texture defines the texture to check against the material
  39298. * @returns a boolean specifying if the material uses the texture
  39299. */
  39300. hasTexture(texture: BaseTexture): boolean;
  39301. /**
  39302. * Disposes the material
  39303. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39304. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39305. */
  39306. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39307. /**
  39308. * Makes a duplicate of the material, and gives it a new name
  39309. * @param name defines the new name for the duplicated material
  39310. * @returns the cloned material
  39311. */
  39312. clone(name: string): StandardMaterial;
  39313. /**
  39314. * Serializes this material in a JSON representation
  39315. * @returns the serialized material object
  39316. */
  39317. serialize(): any;
  39318. /**
  39319. * Creates a standard material from parsed material data
  39320. * @param source defines the JSON representation of the material
  39321. * @param scene defines the hosting scene
  39322. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39323. * @returns a new standard material
  39324. */
  39325. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39326. /**
  39327. * Are diffuse textures enabled in the application.
  39328. */
  39329. static DiffuseTextureEnabled: boolean;
  39330. /**
  39331. * Are ambient textures enabled in the application.
  39332. */
  39333. static AmbientTextureEnabled: boolean;
  39334. /**
  39335. * Are opacity textures enabled in the application.
  39336. */
  39337. static OpacityTextureEnabled: boolean;
  39338. /**
  39339. * Are reflection textures enabled in the application.
  39340. */
  39341. static ReflectionTextureEnabled: boolean;
  39342. /**
  39343. * Are emissive textures enabled in the application.
  39344. */
  39345. static EmissiveTextureEnabled: boolean;
  39346. /**
  39347. * Are specular textures enabled in the application.
  39348. */
  39349. static SpecularTextureEnabled: boolean;
  39350. /**
  39351. * Are bump textures enabled in the application.
  39352. */
  39353. static BumpTextureEnabled: boolean;
  39354. /**
  39355. * Are lightmap textures enabled in the application.
  39356. */
  39357. static LightmapTextureEnabled: boolean;
  39358. /**
  39359. * Are refraction textures enabled in the application.
  39360. */
  39361. static RefractionTextureEnabled: boolean;
  39362. /**
  39363. * Are color grading textures enabled in the application.
  39364. */
  39365. static ColorGradingTextureEnabled: boolean;
  39366. /**
  39367. * Are fresnels enabled in the application.
  39368. */
  39369. static FresnelEnabled: boolean;
  39370. }
  39371. }
  39372. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39373. import { Scene } from "babylonjs/scene";
  39374. import { Texture } from "babylonjs/Materials/Textures/texture";
  39375. /**
  39376. * A class extending Texture allowing drawing on a texture
  39377. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39378. */
  39379. export class DynamicTexture extends Texture {
  39380. private _generateMipMaps;
  39381. private _canvas;
  39382. private _context;
  39383. private _engine;
  39384. /**
  39385. * Creates a DynamicTexture
  39386. * @param name defines the name of the texture
  39387. * @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
  39388. * @param scene defines the scene where you want the texture
  39389. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39390. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39391. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39392. */
  39393. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39394. /**
  39395. * Get the current class name of the texture useful for serialization or dynamic coding.
  39396. * @returns "DynamicTexture"
  39397. */
  39398. getClassName(): string;
  39399. /**
  39400. * Gets the current state of canRescale
  39401. */
  39402. readonly canRescale: boolean;
  39403. private _recreate;
  39404. /**
  39405. * Scales the texture
  39406. * @param ratio the scale factor to apply to both width and height
  39407. */
  39408. scale(ratio: number): void;
  39409. /**
  39410. * Resizes the texture
  39411. * @param width the new width
  39412. * @param height the new height
  39413. */
  39414. scaleTo(width: number, height: number): void;
  39415. /**
  39416. * Gets the context of the canvas used by the texture
  39417. * @returns the canvas context of the dynamic texture
  39418. */
  39419. getContext(): CanvasRenderingContext2D;
  39420. /**
  39421. * Clears the texture
  39422. */
  39423. clear(): void;
  39424. /**
  39425. * Updates the texture
  39426. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39427. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39428. */
  39429. update(invertY?: boolean, premulAlpha?: boolean): void;
  39430. /**
  39431. * Draws text onto the texture
  39432. * @param text defines the text to be drawn
  39433. * @param x defines the placement of the text from the left
  39434. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39435. * @param font defines the font to be used with font-style, font-size, font-name
  39436. * @param color defines the color used for the text
  39437. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39438. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39439. * @param update defines whether texture is immediately update (default is true)
  39440. */
  39441. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39442. /**
  39443. * Clones the texture
  39444. * @returns the clone of the texture.
  39445. */
  39446. clone(): DynamicTexture;
  39447. /**
  39448. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39449. * @returns a serialized dynamic texture object
  39450. */
  39451. serialize(): any;
  39452. /** @hidden */
  39453. _rebuild(): void;
  39454. }
  39455. }
  39456. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39457. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39458. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39459. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39460. /** @hidden */
  39461. export var imageProcessingPixelShader: {
  39462. name: string;
  39463. shader: string;
  39464. };
  39465. }
  39466. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39467. import { Nullable } from "babylonjs/types";
  39468. import { Color4 } from "babylonjs/Maths/math";
  39469. import { Camera } from "babylonjs/Cameras/camera";
  39470. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39471. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39472. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39473. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39474. import { Engine } from "babylonjs/Engines/engine";
  39475. import "babylonjs/Shaders/imageProcessing.fragment";
  39476. import "babylonjs/Shaders/postprocess.vertex";
  39477. /**
  39478. * ImageProcessingPostProcess
  39479. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39480. */
  39481. export class ImageProcessingPostProcess extends PostProcess {
  39482. /**
  39483. * Default configuration related to image processing available in the PBR Material.
  39484. */
  39485. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39486. /**
  39487. * Gets the image processing configuration used either in this material.
  39488. */
  39489. /**
  39490. * Sets the Default image processing configuration used either in the this material.
  39491. *
  39492. * If sets to null, the scene one is in use.
  39493. */
  39494. imageProcessingConfiguration: ImageProcessingConfiguration;
  39495. /**
  39496. * Keep track of the image processing observer to allow dispose and replace.
  39497. */
  39498. private _imageProcessingObserver;
  39499. /**
  39500. * Attaches a new image processing configuration to the PBR Material.
  39501. * @param configuration
  39502. */
  39503. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39504. /**
  39505. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39506. */
  39507. /**
  39508. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39509. */
  39510. colorCurves: Nullable<ColorCurves>;
  39511. /**
  39512. * Gets wether the color curves effect is enabled.
  39513. */
  39514. /**
  39515. * Sets wether the color curves effect is enabled.
  39516. */
  39517. colorCurvesEnabled: boolean;
  39518. /**
  39519. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39520. */
  39521. /**
  39522. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39523. */
  39524. colorGradingTexture: Nullable<BaseTexture>;
  39525. /**
  39526. * Gets wether the color grading effect is enabled.
  39527. */
  39528. /**
  39529. * Gets wether the color grading effect is enabled.
  39530. */
  39531. colorGradingEnabled: boolean;
  39532. /**
  39533. * Gets exposure used in the effect.
  39534. */
  39535. /**
  39536. * Sets exposure used in the effect.
  39537. */
  39538. exposure: number;
  39539. /**
  39540. * Gets wether tonemapping is enabled or not.
  39541. */
  39542. /**
  39543. * Sets wether tonemapping is enabled or not
  39544. */
  39545. toneMappingEnabled: boolean;
  39546. /**
  39547. * Gets the type of tone mapping effect.
  39548. */
  39549. /**
  39550. * Sets the type of tone mapping effect.
  39551. */
  39552. toneMappingType: number;
  39553. /**
  39554. * Gets contrast used in the effect.
  39555. */
  39556. /**
  39557. * Sets contrast used in the effect.
  39558. */
  39559. contrast: number;
  39560. /**
  39561. * Gets Vignette stretch size.
  39562. */
  39563. /**
  39564. * Sets Vignette stretch size.
  39565. */
  39566. vignetteStretch: number;
  39567. /**
  39568. * Gets Vignette centre X Offset.
  39569. */
  39570. /**
  39571. * Sets Vignette centre X Offset.
  39572. */
  39573. vignetteCentreX: number;
  39574. /**
  39575. * Gets Vignette centre Y Offset.
  39576. */
  39577. /**
  39578. * Sets Vignette centre Y Offset.
  39579. */
  39580. vignetteCentreY: number;
  39581. /**
  39582. * Gets Vignette weight or intensity of the vignette effect.
  39583. */
  39584. /**
  39585. * Sets Vignette weight or intensity of the vignette effect.
  39586. */
  39587. vignetteWeight: number;
  39588. /**
  39589. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39590. * if vignetteEnabled is set to true.
  39591. */
  39592. /**
  39593. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39594. * if vignetteEnabled is set to true.
  39595. */
  39596. vignetteColor: Color4;
  39597. /**
  39598. * Gets Camera field of view used by the Vignette effect.
  39599. */
  39600. /**
  39601. * Sets Camera field of view used by the Vignette effect.
  39602. */
  39603. vignetteCameraFov: number;
  39604. /**
  39605. * Gets the vignette blend mode allowing different kind of effect.
  39606. */
  39607. /**
  39608. * Sets the vignette blend mode allowing different kind of effect.
  39609. */
  39610. vignetteBlendMode: number;
  39611. /**
  39612. * Gets wether the vignette effect is enabled.
  39613. */
  39614. /**
  39615. * Sets wether the vignette effect is enabled.
  39616. */
  39617. vignetteEnabled: boolean;
  39618. private _fromLinearSpace;
  39619. /**
  39620. * Gets wether the input of the processing is in Gamma or Linear Space.
  39621. */
  39622. /**
  39623. * Sets wether the input of the processing is in Gamma or Linear Space.
  39624. */
  39625. fromLinearSpace: boolean;
  39626. /**
  39627. * Defines cache preventing GC.
  39628. */
  39629. private _defines;
  39630. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39631. /**
  39632. * "ImageProcessingPostProcess"
  39633. * @returns "ImageProcessingPostProcess"
  39634. */
  39635. getClassName(): string;
  39636. protected _updateParameters(): void;
  39637. dispose(camera?: Camera): void;
  39638. }
  39639. }
  39640. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  39641. import { Scene } from "babylonjs/scene";
  39642. import { Color3 } from "babylonjs/Maths/math";
  39643. import { Mesh } from "babylonjs/Meshes/mesh";
  39644. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  39645. /**
  39646. * Class containing static functions to help procedurally build meshes
  39647. */
  39648. export class GroundBuilder {
  39649. /**
  39650. * Creates a ground mesh
  39651. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39652. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39654. * @param name defines the name of the mesh
  39655. * @param options defines the options used to create the mesh
  39656. * @param scene defines the hosting scene
  39657. * @returns the ground mesh
  39658. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39659. */
  39660. static CreateGround(name: string, options: {
  39661. width?: number;
  39662. height?: number;
  39663. subdivisions?: number;
  39664. subdivisionsX?: number;
  39665. subdivisionsY?: number;
  39666. updatable?: boolean;
  39667. }, scene: any): Mesh;
  39668. /**
  39669. * Creates a tiled ground mesh
  39670. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39671. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39672. * * 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
  39673. * * 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
  39674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39675. * @param name defines the name of the mesh
  39676. * @param options defines the options used to create the mesh
  39677. * @param scene defines the hosting scene
  39678. * @returns the tiled ground mesh
  39679. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39680. */
  39681. static CreateTiledGround(name: string, options: {
  39682. xmin: number;
  39683. zmin: number;
  39684. xmax: number;
  39685. zmax: number;
  39686. subdivisions?: {
  39687. w: number;
  39688. h: number;
  39689. };
  39690. precision?: {
  39691. w: number;
  39692. h: number;
  39693. };
  39694. updatable?: boolean;
  39695. }, scene: Scene): Mesh;
  39696. /**
  39697. * Creates a ground mesh from a height map
  39698. * * The parameter `url` sets the URL of the height map image resource.
  39699. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39700. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39701. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39702. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39703. * * 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.
  39704. * * 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).
  39705. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39707. * @param name defines the name of the mesh
  39708. * @param url defines the url to the height map
  39709. * @param options defines the options used to create the mesh
  39710. * @param scene defines the hosting scene
  39711. * @returns the ground mesh
  39712. * @see https://doc.babylonjs.com/babylon101/height_map
  39713. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39714. */
  39715. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39716. width?: number;
  39717. height?: number;
  39718. subdivisions?: number;
  39719. minHeight?: number;
  39720. maxHeight?: number;
  39721. colorFilter?: Color3;
  39722. alphaFilter?: number;
  39723. updatable?: boolean;
  39724. onReady?: (mesh: GroundMesh) => void;
  39725. }, scene: Scene): GroundMesh;
  39726. }
  39727. }
  39728. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  39729. import { Vector4 } from "babylonjs/Maths/math";
  39730. import { Mesh } from "babylonjs/Meshes/mesh";
  39731. /**
  39732. * Class containing static functions to help procedurally build meshes
  39733. */
  39734. export class TorusBuilder {
  39735. /**
  39736. * Creates a torus mesh
  39737. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39738. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39739. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39741. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39743. * @param name defines the name of the mesh
  39744. * @param options defines the options used to create the mesh
  39745. * @param scene defines the hosting scene
  39746. * @returns the torus mesh
  39747. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39748. */
  39749. static CreateTorus(name: string, options: {
  39750. diameter?: number;
  39751. thickness?: number;
  39752. tessellation?: number;
  39753. updatable?: boolean;
  39754. sideOrientation?: number;
  39755. frontUVs?: Vector4;
  39756. backUVs?: Vector4;
  39757. }, scene: any): Mesh;
  39758. }
  39759. }
  39760. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  39761. import { Color4, Vector4 } from "babylonjs/Maths/math";
  39762. import { Mesh } from "babylonjs/Meshes/mesh";
  39763. /**
  39764. * Class containing static functions to help procedurally build meshes
  39765. */
  39766. export class CylinderBuilder {
  39767. /**
  39768. * Creates a cylinder or a cone mesh
  39769. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39770. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39771. * * 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.
  39772. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39773. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39774. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39775. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39776. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39777. * * 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).
  39778. * * 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
  39779. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39780. * * 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
  39781. * * 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.
  39782. * * If `enclose` is false, a ring surface is one element.
  39783. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39784. * * 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
  39785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39786. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39788. * @param name defines the name of the mesh
  39789. * @param options defines the options used to create the mesh
  39790. * @param scene defines the hosting scene
  39791. * @returns the cylinder mesh
  39792. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39793. */
  39794. static CreateCylinder(name: string, options: {
  39795. height?: number;
  39796. diameterTop?: number;
  39797. diameterBottom?: number;
  39798. diameter?: number;
  39799. tessellation?: number;
  39800. subdivisions?: number;
  39801. arc?: number;
  39802. faceColors?: Color4[];
  39803. faceUV?: Vector4[];
  39804. updatable?: boolean;
  39805. hasRings?: boolean;
  39806. enclose?: boolean;
  39807. sideOrientation?: number;
  39808. frontUVs?: Vector4;
  39809. backUVs?: Vector4;
  39810. }, scene: any): Mesh;
  39811. }
  39812. }
  39813. declare module "babylonjs/Gamepads/gamepadManager" {
  39814. import { Observable } from "babylonjs/Misc/observable";
  39815. import { Nullable } from "babylonjs/types";
  39816. import { Scene } from "babylonjs/scene";
  39817. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39818. /**
  39819. * Manager for handling gamepads
  39820. */
  39821. export class GamepadManager {
  39822. private _scene?;
  39823. private _babylonGamepads;
  39824. private _oneGamepadConnected;
  39825. /** @hidden */
  39826. _isMonitoring: boolean;
  39827. private _gamepadEventSupported;
  39828. private _gamepadSupport;
  39829. /**
  39830. * observable to be triggered when the gamepad controller has been connected
  39831. */
  39832. onGamepadConnectedObservable: Observable<Gamepad>;
  39833. /**
  39834. * observable to be triggered when the gamepad controller has been disconnected
  39835. */
  39836. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39837. private _onGamepadConnectedEvent;
  39838. private _onGamepadDisconnectedEvent;
  39839. /**
  39840. * Initializes the gamepad manager
  39841. * @param _scene BabylonJS scene
  39842. */
  39843. constructor(_scene?: Scene | undefined);
  39844. /**
  39845. * The gamepads in the game pad manager
  39846. */
  39847. readonly gamepads: Gamepad[];
  39848. /**
  39849. * Get the gamepad controllers based on type
  39850. * @param type The type of gamepad controller
  39851. * @returns Nullable gamepad
  39852. */
  39853. getGamepadByType(type?: number): Nullable<Gamepad>;
  39854. /**
  39855. * Disposes the gamepad manager
  39856. */
  39857. dispose(): void;
  39858. private _addNewGamepad;
  39859. private _startMonitoringGamepads;
  39860. private _stopMonitoringGamepads;
  39861. /** @hidden */
  39862. _checkGamepadsStatus(): void;
  39863. private _updateGamepadObjects;
  39864. }
  39865. }
  39866. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39867. import { Nullable } from "babylonjs/types";
  39868. import { Scene } from "babylonjs/scene";
  39869. import { ISceneComponent } from "babylonjs/sceneComponent";
  39870. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39871. module "babylonjs/scene" {
  39872. interface Scene {
  39873. /** @hidden */
  39874. _gamepadManager: Nullable<GamepadManager>;
  39875. /**
  39876. * Gets the gamepad manager associated with the scene
  39877. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39878. */
  39879. gamepadManager: GamepadManager;
  39880. }
  39881. }
  39882. module "babylonjs/Cameras/freeCameraInputsManager" {
  39883. /**
  39884. * Interface representing a free camera inputs manager
  39885. */
  39886. interface FreeCameraInputsManager {
  39887. /**
  39888. * Adds gamepad input support to the FreeCameraInputsManager.
  39889. * @returns the FreeCameraInputsManager
  39890. */
  39891. addGamepad(): FreeCameraInputsManager;
  39892. }
  39893. }
  39894. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39895. /**
  39896. * Interface representing an arc rotate camera inputs manager
  39897. */
  39898. interface ArcRotateCameraInputsManager {
  39899. /**
  39900. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39901. * @returns the camera inputs manager
  39902. */
  39903. addGamepad(): ArcRotateCameraInputsManager;
  39904. }
  39905. }
  39906. /**
  39907. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39908. */
  39909. export class GamepadSystemSceneComponent implements ISceneComponent {
  39910. /**
  39911. * The component name helpfull to identify the component in the list of scene components.
  39912. */
  39913. readonly name: string;
  39914. /**
  39915. * The scene the component belongs to.
  39916. */
  39917. scene: Scene;
  39918. /**
  39919. * Creates a new instance of the component for the given scene
  39920. * @param scene Defines the scene to register the component in
  39921. */
  39922. constructor(scene: Scene);
  39923. /**
  39924. * Registers the component in a given scene
  39925. */
  39926. register(): void;
  39927. /**
  39928. * Rebuilds the elements related to this component in case of
  39929. * context lost for instance.
  39930. */
  39931. rebuild(): void;
  39932. /**
  39933. * Disposes the component and the associated ressources
  39934. */
  39935. dispose(): void;
  39936. private _beforeCameraUpdate;
  39937. }
  39938. }
  39939. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  39940. import { Observable } from "babylonjs/Misc/observable";
  39941. import { Nullable } from "babylonjs/types";
  39942. import { Camera } from "babylonjs/Cameras/camera";
  39943. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39944. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39945. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  39946. import { Scene } from "babylonjs/scene";
  39947. import { Vector3, Color3 } from "babylonjs/Maths/math";
  39948. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  39949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39950. import { Mesh } from "babylonjs/Meshes/mesh";
  39951. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39952. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39953. import "babylonjs/Meshes/Builders/groundBuilder";
  39954. import "babylonjs/Meshes/Builders/torusBuilder";
  39955. import "babylonjs/Meshes/Builders/cylinderBuilder";
  39956. import "babylonjs/Gamepads/gamepadSceneComponent";
  39957. import "babylonjs/Animations/animatable";
  39958. /**
  39959. * Options to modify the vr teleportation behavior.
  39960. */
  39961. export interface VRTeleportationOptions {
  39962. /**
  39963. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39964. */
  39965. floorMeshName?: string;
  39966. /**
  39967. * A list of meshes to be used as the teleportation floor. (default: empty)
  39968. */
  39969. floorMeshes?: Mesh[];
  39970. }
  39971. /**
  39972. * Options to modify the vr experience helper's behavior.
  39973. */
  39974. export interface VRExperienceHelperOptions extends WebVROptions {
  39975. /**
  39976. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39977. */
  39978. createDeviceOrientationCamera?: boolean;
  39979. /**
  39980. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39981. */
  39982. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39983. /**
  39984. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39985. */
  39986. laserToggle?: boolean;
  39987. /**
  39988. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39989. */
  39990. floorMeshes?: Mesh[];
  39991. /**
  39992. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39993. */
  39994. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39995. }
  39996. /**
  39997. * Event containing information after VR has been entered
  39998. */
  39999. export class OnAfterEnteringVRObservableEvent {
  40000. /**
  40001. * If entering vr was successful
  40002. */
  40003. success: boolean;
  40004. }
  40005. /**
  40006. * Helps to quickly add VR support to an existing scene.
  40007. * See http://doc.babylonjs.com/how_to/webvr_helper
  40008. */
  40009. export class VRExperienceHelper {
  40010. /** Options to modify the vr experience helper's behavior. */
  40011. webVROptions: VRExperienceHelperOptions;
  40012. private _scene;
  40013. private _position;
  40014. private _btnVR;
  40015. private _btnVRDisplayed;
  40016. private _webVRsupported;
  40017. private _webVRready;
  40018. private _webVRrequesting;
  40019. private _webVRpresenting;
  40020. private _hasEnteredVR;
  40021. private _fullscreenVRpresenting;
  40022. private _canvas;
  40023. private _webVRCamera;
  40024. private _vrDeviceOrientationCamera;
  40025. private _deviceOrientationCamera;
  40026. private _existingCamera;
  40027. private _onKeyDown;
  40028. private _onVrDisplayPresentChange;
  40029. private _onVRDisplayChanged;
  40030. private _onVRRequestPresentStart;
  40031. private _onVRRequestPresentComplete;
  40032. /**
  40033. * Observable raised right before entering VR.
  40034. */
  40035. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40036. /**
  40037. * Observable raised when entering VR has completed.
  40038. */
  40039. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40040. /**
  40041. * Observable raised when exiting VR.
  40042. */
  40043. onExitingVRObservable: Observable<VRExperienceHelper>;
  40044. /**
  40045. * Observable raised when controller mesh is loaded.
  40046. */
  40047. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40048. /** Return this.onEnteringVRObservable
  40049. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40050. */
  40051. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40052. /** Return this.onExitingVRObservable
  40053. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40054. */
  40055. readonly onExitingVR: Observable<VRExperienceHelper>;
  40056. /** Return this.onControllerMeshLoadedObservable
  40057. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40058. */
  40059. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40060. private _rayLength;
  40061. private _useCustomVRButton;
  40062. private _teleportationRequested;
  40063. private _teleportActive;
  40064. private _floorMeshName;
  40065. private _floorMeshesCollection;
  40066. private _rotationAllowed;
  40067. private _teleportBackwardsVector;
  40068. private _teleportationTarget;
  40069. private _isDefaultTeleportationTarget;
  40070. private _postProcessMove;
  40071. private _teleportationFillColor;
  40072. private _teleportationBorderColor;
  40073. private _rotationAngle;
  40074. private _haloCenter;
  40075. private _cameraGazer;
  40076. private _padSensibilityUp;
  40077. private _padSensibilityDown;
  40078. private _leftController;
  40079. private _rightController;
  40080. /**
  40081. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40082. */
  40083. onNewMeshSelected: Observable<AbstractMesh>;
  40084. /**
  40085. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40086. */
  40087. onNewMeshPicked: Observable<PickingInfo>;
  40088. private _circleEase;
  40089. /**
  40090. * Observable raised before camera teleportation
  40091. */
  40092. onBeforeCameraTeleport: Observable<Vector3>;
  40093. /**
  40094. * Observable raised after camera teleportation
  40095. */
  40096. onAfterCameraTeleport: Observable<Vector3>;
  40097. /**
  40098. * Observable raised when current selected mesh gets unselected
  40099. */
  40100. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40101. private _raySelectionPredicate;
  40102. /**
  40103. * To be optionaly changed by user to define custom ray selection
  40104. */
  40105. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40106. /**
  40107. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40108. */
  40109. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40110. /**
  40111. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40112. */
  40113. teleportationEnabled: boolean;
  40114. private _defaultHeight;
  40115. private _teleportationInitialized;
  40116. private _interactionsEnabled;
  40117. private _interactionsRequested;
  40118. private _displayGaze;
  40119. private _displayLaserPointer;
  40120. /**
  40121. * The mesh used to display where the user is going to teleport.
  40122. */
  40123. /**
  40124. * Sets the mesh to be used to display where the user is going to teleport.
  40125. */
  40126. teleportationTarget: Mesh;
  40127. /**
  40128. * 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
  40129. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40130. * See http://doc.babylonjs.com/resources/baking_transformations
  40131. */
  40132. gazeTrackerMesh: Mesh;
  40133. /**
  40134. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40135. */
  40136. updateGazeTrackerScale: boolean;
  40137. /**
  40138. * If the gaze trackers color should be updated when selecting meshes
  40139. */
  40140. updateGazeTrackerColor: boolean;
  40141. /**
  40142. * The gaze tracking mesh corresponding to the left controller
  40143. */
  40144. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40145. /**
  40146. * The gaze tracking mesh corresponding to the right controller
  40147. */
  40148. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40149. /**
  40150. * If the ray of the gaze should be displayed.
  40151. */
  40152. /**
  40153. * Sets if the ray of the gaze should be displayed.
  40154. */
  40155. displayGaze: boolean;
  40156. /**
  40157. * If the ray of the LaserPointer should be displayed.
  40158. */
  40159. /**
  40160. * Sets if the ray of the LaserPointer should be displayed.
  40161. */
  40162. displayLaserPointer: boolean;
  40163. /**
  40164. * The deviceOrientationCamera used as the camera when not in VR.
  40165. */
  40166. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40167. /**
  40168. * Based on the current WebVR support, returns the current VR camera used.
  40169. */
  40170. readonly currentVRCamera: Nullable<Camera>;
  40171. /**
  40172. * The webVRCamera which is used when in VR.
  40173. */
  40174. readonly webVRCamera: WebVRFreeCamera;
  40175. /**
  40176. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40177. */
  40178. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40179. private readonly _teleportationRequestInitiated;
  40180. /**
  40181. * Defines wether or not Pointer lock should be requested when switching to
  40182. * full screen.
  40183. */
  40184. requestPointerLockOnFullScreen: boolean;
  40185. /**
  40186. * Instantiates a VRExperienceHelper.
  40187. * Helps to quickly add VR support to an existing scene.
  40188. * @param scene The scene the VRExperienceHelper belongs to.
  40189. * @param webVROptions Options to modify the vr experience helper's behavior.
  40190. */
  40191. constructor(scene: Scene,
  40192. /** Options to modify the vr experience helper's behavior. */
  40193. webVROptions?: VRExperienceHelperOptions);
  40194. private _onDefaultMeshLoaded;
  40195. private _onResize;
  40196. private _onFullscreenChange;
  40197. /**
  40198. * Gets a value indicating if we are currently in VR mode.
  40199. */
  40200. readonly isInVRMode: boolean;
  40201. private onVrDisplayPresentChange;
  40202. private onVRDisplayChanged;
  40203. private moveButtonToBottomRight;
  40204. private displayVRButton;
  40205. private updateButtonVisibility;
  40206. private _cachedAngularSensibility;
  40207. /**
  40208. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40209. * Otherwise, will use the fullscreen API.
  40210. */
  40211. enterVR(): void;
  40212. /**
  40213. * Attempt to exit VR, or fullscreen.
  40214. */
  40215. exitVR(): void;
  40216. /**
  40217. * The position of the vr experience helper.
  40218. */
  40219. /**
  40220. * Sets the position of the vr experience helper.
  40221. */
  40222. position: Vector3;
  40223. /**
  40224. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40225. */
  40226. enableInteractions(): void;
  40227. private readonly _noControllerIsActive;
  40228. private beforeRender;
  40229. private _isTeleportationFloor;
  40230. /**
  40231. * Adds a floor mesh to be used for teleportation.
  40232. * @param floorMesh the mesh to be used for teleportation.
  40233. */
  40234. addFloorMesh(floorMesh: Mesh): void;
  40235. /**
  40236. * Removes a floor mesh from being used for teleportation.
  40237. * @param floorMesh the mesh to be removed.
  40238. */
  40239. removeFloorMesh(floorMesh: Mesh): void;
  40240. /**
  40241. * Enables interactions and teleportation using the VR controllers and gaze.
  40242. * @param vrTeleportationOptions options to modify teleportation behavior.
  40243. */
  40244. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40245. private _onNewGamepadConnected;
  40246. private _tryEnableInteractionOnController;
  40247. private _onNewGamepadDisconnected;
  40248. private _enableInteractionOnController;
  40249. private _checkTeleportWithRay;
  40250. private _checkRotate;
  40251. private _checkTeleportBackwards;
  40252. private _enableTeleportationOnController;
  40253. private _createTeleportationCircles;
  40254. private _displayTeleportationTarget;
  40255. private _hideTeleportationTarget;
  40256. private _rotateCamera;
  40257. private _moveTeleportationSelectorTo;
  40258. private _workingVector;
  40259. private _workingQuaternion;
  40260. private _workingMatrix;
  40261. /**
  40262. * Teleports the users feet to the desired location
  40263. * @param location The location where the user's feet should be placed
  40264. */
  40265. teleportCamera(location: Vector3): void;
  40266. private _convertNormalToDirectionOfRay;
  40267. private _castRayAndSelectObject;
  40268. private _notifySelectedMeshUnselected;
  40269. /**
  40270. * Sets the color of the laser ray from the vr controllers.
  40271. * @param color new color for the ray.
  40272. */
  40273. changeLaserColor(color: Color3): void;
  40274. /**
  40275. * Sets the color of the ray from the vr headsets gaze.
  40276. * @param color new color for the ray.
  40277. */
  40278. changeGazeColor(color: Color3): void;
  40279. /**
  40280. * Exits VR and disposes of the vr experience helper
  40281. */
  40282. dispose(): void;
  40283. /**
  40284. * Gets the name of the VRExperienceHelper class
  40285. * @returns "VRExperienceHelper"
  40286. */
  40287. getClassName(): string;
  40288. }
  40289. }
  40290. declare module "babylonjs/Cameras/VR/index" {
  40291. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40292. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40293. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40294. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40295. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40296. export * from "babylonjs/Cameras/VR/webVRCamera";
  40297. }
  40298. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40299. import { Observable } from "babylonjs/Misc/observable";
  40300. import { Nullable } from "babylonjs/types";
  40301. import { IDisposable, Scene } from "babylonjs/scene";
  40302. import { Vector3 } from "babylonjs/Maths/math";
  40303. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40304. import { Ray } from "babylonjs/Culling/ray";
  40305. /**
  40306. * Manages an XRSession
  40307. * @see https://doc.babylonjs.com/how_to/webxr
  40308. */
  40309. export class WebXRSessionManager implements IDisposable {
  40310. private scene;
  40311. /**
  40312. * Fires every time a new xrFrame arrives which can be used to update the camera
  40313. */
  40314. onXRFrameObservable: Observable<any>;
  40315. /**
  40316. * Fires when the xr session is ended either by the device or manually done
  40317. */
  40318. onXRSessionEnded: Observable<any>;
  40319. /** @hidden */
  40320. _xrSession: XRSession;
  40321. /** @hidden */
  40322. _frameOfReference: XRFrameOfReference;
  40323. /** @hidden */
  40324. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40325. /** @hidden */
  40326. _currentXRFrame: Nullable<XRFrame>;
  40327. private _xrNavigator;
  40328. private _xrDevice;
  40329. private _tmpMatrix;
  40330. /**
  40331. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40332. * @param scene The scene which the session should be created for
  40333. */
  40334. constructor(scene: Scene);
  40335. /**
  40336. * Initializes the manager
  40337. * After initialization enterXR can be called to start an XR session
  40338. * @returns Promise which resolves after it is initialized
  40339. */
  40340. initializeAsync(): Promise<void>;
  40341. /**
  40342. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40343. * @param sessionCreationOptions xr options to create the session with
  40344. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40345. * @returns Promise which resolves after it enters XR
  40346. */
  40347. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40348. /**
  40349. * Stops the xrSession and restores the renderloop
  40350. * @returns Promise which resolves after it exits XR
  40351. */
  40352. exitXRAsync(): Promise<void>;
  40353. /**
  40354. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40355. * @param ray ray to cast into the environment
  40356. * @returns Promise which resolves with a collision point in the environment if it exists
  40357. */
  40358. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40359. /**
  40360. * Checks if a session would be supported for the creation options specified
  40361. * @param options creation options to check if they are supported
  40362. * @returns true if supported
  40363. */
  40364. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40365. /**
  40366. * @hidden
  40367. * Converts the render layer of xrSession to a render target
  40368. * @param session session to create render target for
  40369. * @param scene scene the new render target should be created for
  40370. */
  40371. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40372. /**
  40373. * Disposes of the session manager
  40374. */
  40375. dispose(): void;
  40376. }
  40377. }
  40378. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40379. import { Scene } from "babylonjs/scene";
  40380. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40381. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40382. /**
  40383. * WebXR Camera which holds the views for the xrSession
  40384. * @see https://doc.babylonjs.com/how_to/webxr
  40385. */
  40386. export class WebXRCamera extends FreeCamera {
  40387. private static _TmpMatrix;
  40388. /**
  40389. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40390. * @param name the name of the camera
  40391. * @param scene the scene to add the camera to
  40392. */
  40393. constructor(name: string, scene: Scene);
  40394. private _updateNumberOfRigCameras;
  40395. /** @hidden */
  40396. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40397. /**
  40398. * Updates the cameras position from the current pose information of the XR session
  40399. * @param xrSessionManager the session containing pose information
  40400. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40401. */
  40402. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40403. }
  40404. }
  40405. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40406. import { Nullable } from "babylonjs/types";
  40407. import { Observable } from "babylonjs/Misc/observable";
  40408. import { IDisposable, Scene } from "babylonjs/scene";
  40409. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40411. import { Ray } from "babylonjs/Culling/ray";
  40412. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40413. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40414. /**
  40415. * States of the webXR experience
  40416. */
  40417. export enum WebXRState {
  40418. /**
  40419. * Transitioning to being in XR mode
  40420. */
  40421. ENTERING_XR = 0,
  40422. /**
  40423. * Transitioning to non XR mode
  40424. */
  40425. EXITING_XR = 1,
  40426. /**
  40427. * In XR mode and presenting
  40428. */
  40429. IN_XR = 2,
  40430. /**
  40431. * Not entered XR mode
  40432. */
  40433. NOT_IN_XR = 3
  40434. }
  40435. /**
  40436. * Helper class used to enable XR
  40437. * @see https://doc.babylonjs.com/how_to/webxr
  40438. */
  40439. export class WebXRExperienceHelper implements IDisposable {
  40440. private scene;
  40441. /**
  40442. * 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
  40443. */
  40444. container: AbstractMesh;
  40445. /**
  40446. * Camera used to render xr content
  40447. */
  40448. camera: WebXRCamera;
  40449. /**
  40450. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40451. */
  40452. state: WebXRState;
  40453. private _setState;
  40454. private static _TmpVector;
  40455. /**
  40456. * Fires when the state of the experience helper has changed
  40457. */
  40458. onStateChangedObservable: Observable<WebXRState>;
  40459. /** @hidden */
  40460. _sessionManager: WebXRSessionManager;
  40461. private _nonVRCamera;
  40462. private _originalSceneAutoClear;
  40463. private _supported;
  40464. /**
  40465. * Creates the experience helper
  40466. * @param scene the scene to attach the experience helper to
  40467. * @returns a promise for the experience helper
  40468. */
  40469. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40470. /**
  40471. * Creates a WebXRExperienceHelper
  40472. * @param scene The scene the helper should be created in
  40473. */
  40474. private constructor();
  40475. /**
  40476. * Exits XR mode and returns the scene to its original state
  40477. * @returns promise that resolves after xr mode has exited
  40478. */
  40479. exitXRAsync(): Promise<void>;
  40480. /**
  40481. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40482. * @param sessionCreationOptions options for the XR session
  40483. * @param frameOfReference frame of reference of the XR session
  40484. * @returns promise that resolves after xr mode has entered
  40485. */
  40486. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40487. /**
  40488. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40489. * @param ray ray to cast into the environment
  40490. * @returns Promise which resolves with a collision point in the environment if it exists
  40491. */
  40492. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40493. /**
  40494. * Updates the global position of the camera by moving the camera's container
  40495. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40496. * @param position The desired global position of the camera
  40497. */
  40498. setPositionOfCameraUsingContainer(position: Vector3): void;
  40499. /**
  40500. * Rotates the xr camera by rotating the camera's container around the camera's position
  40501. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40502. * @param rotation the desired quaternion rotation to apply to the camera
  40503. */
  40504. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40505. /**
  40506. * Checks if the creation options are supported by the xr session
  40507. * @param options creation options
  40508. * @returns true if supported
  40509. */
  40510. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40511. /**
  40512. * Disposes of the experience helper
  40513. */
  40514. dispose(): void;
  40515. }
  40516. }
  40517. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40518. import { Nullable } from "babylonjs/types";
  40519. import { Observable } from "babylonjs/Misc/observable";
  40520. import { IDisposable, Scene } from "babylonjs/scene";
  40521. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40522. /**
  40523. * Button which can be used to enter a different mode of XR
  40524. */
  40525. export class WebXREnterExitUIButton {
  40526. /** button element */
  40527. element: HTMLElement;
  40528. /** XR initialization options for the button */
  40529. initializationOptions: XRSessionCreationOptions;
  40530. /**
  40531. * Creates a WebXREnterExitUIButton
  40532. * @param element button element
  40533. * @param initializationOptions XR initialization options for the button
  40534. */
  40535. constructor(
  40536. /** button element */
  40537. element: HTMLElement,
  40538. /** XR initialization options for the button */
  40539. initializationOptions: XRSessionCreationOptions);
  40540. /**
  40541. * Overwritable function which can be used to update the button's visuals when the state changes
  40542. * @param activeButton the current active button in the UI
  40543. */
  40544. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40545. }
  40546. /**
  40547. * Options to create the webXR UI
  40548. */
  40549. export class WebXREnterExitUIOptions {
  40550. /**
  40551. * Context to enter xr with
  40552. */
  40553. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40554. /**
  40555. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40556. */
  40557. customButtons?: Array<WebXREnterExitUIButton>;
  40558. }
  40559. /**
  40560. * UI to allow the user to enter/exit XR mode
  40561. */
  40562. export class WebXREnterExitUI implements IDisposable {
  40563. private scene;
  40564. private _overlay;
  40565. private _buttons;
  40566. private _activeButton;
  40567. /**
  40568. * Fired every time the active button is changed.
  40569. *
  40570. * When xr is entered via a button that launches xr that button will be the callback parameter
  40571. *
  40572. * When exiting xr the callback parameter will be null)
  40573. */
  40574. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40575. /**
  40576. * Creates UI to allow the user to enter/exit XR mode
  40577. * @param scene the scene to add the ui to
  40578. * @param helper the xr experience helper to enter/exit xr with
  40579. * @param options options to configure the UI
  40580. * @returns the created ui
  40581. */
  40582. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40583. private constructor();
  40584. private _updateButtons;
  40585. /**
  40586. * Disposes of the object
  40587. */
  40588. dispose(): void;
  40589. }
  40590. }
  40591. declare module "babylonjs/Cameras/XR/webXRInput" {
  40592. import { IDisposable, Scene } from "babylonjs/scene";
  40593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40594. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40595. /**
  40596. * Represents an XR input
  40597. */
  40598. export class WebXRController {
  40599. /**
  40600. * 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
  40601. */
  40602. grip?: AbstractMesh;
  40603. /**
  40604. * Pointer which can be used to select objects or attach a visible laser to
  40605. */
  40606. pointer: AbstractMesh;
  40607. /**
  40608. * Creates the controller
  40609. * @see https://doc.babylonjs.com/how_to/webxr
  40610. * @param scene the scene which the controller should be associated to
  40611. */
  40612. constructor(scene: Scene);
  40613. /**
  40614. * Disposes of the object
  40615. */
  40616. dispose(): void;
  40617. }
  40618. /**
  40619. * XR input used to track XR inputs such as controllers/rays
  40620. */
  40621. export class WebXRInput implements IDisposable {
  40622. private helper;
  40623. /**
  40624. * XR controllers being tracked
  40625. */
  40626. controllers: Array<WebXRController>;
  40627. private _tmpMatrix;
  40628. private _frameObserver;
  40629. /**
  40630. * Initializes the WebXRInput
  40631. * @param helper experience helper which the input should be created for
  40632. */
  40633. constructor(helper: WebXRExperienceHelper);
  40634. /**
  40635. * Disposes of the object
  40636. */
  40637. dispose(): void;
  40638. }
  40639. }
  40640. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40641. import { Nullable } from "babylonjs/types";
  40642. import { IDisposable } from "babylonjs/scene";
  40643. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40644. /**
  40645. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40646. */
  40647. export class WebXRManagedOutputCanvas implements IDisposable {
  40648. private _canvas;
  40649. /**
  40650. * xrpresent context of the canvas which can be used to display/mirror xr content
  40651. */
  40652. canvasContext: Nullable<WebGLRenderingContext>;
  40653. /**
  40654. * Initializes the canvas to be added/removed upon entering/exiting xr
  40655. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40656. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40657. */
  40658. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40659. /**
  40660. * Disposes of the object
  40661. */
  40662. dispose(): void;
  40663. private _setManagedOutputCanvas;
  40664. private _addCanvas;
  40665. private _removeCanvas;
  40666. }
  40667. }
  40668. declare module "babylonjs/Cameras/XR/index" {
  40669. export * from "babylonjs/Cameras/XR/webXRCamera";
  40670. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40671. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40672. export * from "babylonjs/Cameras/XR/webXRInput";
  40673. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40674. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40675. }
  40676. declare module "babylonjs/Cameras/RigModes/index" {
  40677. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40678. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40679. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40680. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40681. }
  40682. declare module "babylonjs/Cameras/index" {
  40683. export * from "babylonjs/Cameras/Inputs/index";
  40684. export * from "babylonjs/Cameras/cameraInputsManager";
  40685. export * from "babylonjs/Cameras/camera";
  40686. export * from "babylonjs/Cameras/targetCamera";
  40687. export * from "babylonjs/Cameras/freeCamera";
  40688. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40689. export * from "babylonjs/Cameras/touchCamera";
  40690. export * from "babylonjs/Cameras/arcRotateCamera";
  40691. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40692. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40693. export * from "babylonjs/Cameras/flyCamera";
  40694. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40695. export * from "babylonjs/Cameras/followCamera";
  40696. export * from "babylonjs/Cameras/gamepadCamera";
  40697. export * from "babylonjs/Cameras/Stereoscopic/index";
  40698. export * from "babylonjs/Cameras/universalCamera";
  40699. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40700. export * from "babylonjs/Cameras/VR/index";
  40701. export * from "babylonjs/Cameras/XR/index";
  40702. export * from "babylonjs/Cameras/RigModes/index";
  40703. }
  40704. declare module "babylonjs/Collisions/index" {
  40705. export * from "babylonjs/Collisions/collider";
  40706. export * from "babylonjs/Collisions/collisionCoordinator";
  40707. export * from "babylonjs/Collisions/pickingInfo";
  40708. export * from "babylonjs/Collisions/intersectionInfo";
  40709. }
  40710. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40711. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40712. import { Vector3, Plane } from "babylonjs/Maths/math";
  40713. import { Ray } from "babylonjs/Culling/ray";
  40714. /**
  40715. * Contains an array of blocks representing the octree
  40716. */
  40717. export interface IOctreeContainer<T> {
  40718. /**
  40719. * Blocks within the octree
  40720. */
  40721. blocks: Array<OctreeBlock<T>>;
  40722. }
  40723. /**
  40724. * Class used to store a cell in an octree
  40725. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40726. */
  40727. export class OctreeBlock<T> {
  40728. /**
  40729. * Gets the content of the current block
  40730. */
  40731. entries: T[];
  40732. /**
  40733. * Gets the list of block children
  40734. */
  40735. blocks: Array<OctreeBlock<T>>;
  40736. private _depth;
  40737. private _maxDepth;
  40738. private _capacity;
  40739. private _minPoint;
  40740. private _maxPoint;
  40741. private _boundingVectors;
  40742. private _creationFunc;
  40743. /**
  40744. * Creates a new block
  40745. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40746. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40747. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40748. * @param depth defines the current depth of this block in the octree
  40749. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40750. * @param creationFunc defines a callback to call when an element is added to the block
  40751. */
  40752. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40753. /**
  40754. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40755. */
  40756. readonly capacity: number;
  40757. /**
  40758. * Gets the minimum vector (in world space) of the block's bounding box
  40759. */
  40760. readonly minPoint: Vector3;
  40761. /**
  40762. * Gets the maximum vector (in world space) of the block's bounding box
  40763. */
  40764. readonly maxPoint: Vector3;
  40765. /**
  40766. * Add a new element to this block
  40767. * @param entry defines the element to add
  40768. */
  40769. addEntry(entry: T): void;
  40770. /**
  40771. * Remove an element from this block
  40772. * @param entry defines the element to remove
  40773. */
  40774. removeEntry(entry: T): void;
  40775. /**
  40776. * Add an array of elements to this block
  40777. * @param entries defines the array of elements to add
  40778. */
  40779. addEntries(entries: T[]): void;
  40780. /**
  40781. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40782. * @param frustumPlanes defines the frustum planes to test
  40783. * @param selection defines the array to store current content if selection is positive
  40784. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40785. */
  40786. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40787. /**
  40788. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40789. * @param sphereCenter defines the bounding sphere center
  40790. * @param sphereRadius defines the bounding sphere radius
  40791. * @param selection defines the array to store current content if selection is positive
  40792. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40793. */
  40794. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40795. /**
  40796. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40797. * @param ray defines the ray to test with
  40798. * @param selection defines the array to store current content if selection is positive
  40799. */
  40800. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40801. /**
  40802. * Subdivide the content into child blocks (this block will then be empty)
  40803. */
  40804. createInnerBlocks(): void;
  40805. /**
  40806. * @hidden
  40807. */
  40808. 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;
  40809. }
  40810. }
  40811. declare module "babylonjs/Culling/Octrees/octree" {
  40812. import { SmartArray } from "babylonjs/Misc/smartArray";
  40813. import { Vector3, Plane } from "babylonjs/Maths/math";
  40814. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40816. import { Ray } from "babylonjs/Culling/ray";
  40817. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  40818. /**
  40819. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40820. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40821. */
  40822. export class Octree<T> {
  40823. /** 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.) */
  40824. maxDepth: number;
  40825. /**
  40826. * Blocks within the octree containing objects
  40827. */
  40828. blocks: Array<OctreeBlock<T>>;
  40829. /**
  40830. * Content stored in the octree
  40831. */
  40832. dynamicContent: T[];
  40833. private _maxBlockCapacity;
  40834. private _selectionContent;
  40835. private _creationFunc;
  40836. /**
  40837. * Creates a octree
  40838. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40839. * @param creationFunc function to be used to instatiate the octree
  40840. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40841. * @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.)
  40842. */
  40843. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40844. /** 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.) */
  40845. maxDepth?: number);
  40846. /**
  40847. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40848. * @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);
  40849. * @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);
  40850. * @param entries meshes to be added to the octree blocks
  40851. */
  40852. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40853. /**
  40854. * Adds a mesh to the octree
  40855. * @param entry Mesh to add to the octree
  40856. */
  40857. addMesh(entry: T): void;
  40858. /**
  40859. * Remove an element from the octree
  40860. * @param entry defines the element to remove
  40861. */
  40862. removeMesh(entry: T): void;
  40863. /**
  40864. * Selects an array of meshes within the frustum
  40865. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40866. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40867. * @returns array of meshes within the frustum
  40868. */
  40869. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40870. /**
  40871. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40872. * @param sphereCenter defines the bounding sphere center
  40873. * @param sphereRadius defines the bounding sphere radius
  40874. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40875. * @returns an array of objects that intersect the sphere
  40876. */
  40877. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40878. /**
  40879. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40880. * @param ray defines the ray to test with
  40881. * @returns array of intersected objects
  40882. */
  40883. intersectsRay(ray: Ray): SmartArray<T>;
  40884. /**
  40885. * Adds a mesh into the octree block if it intersects the block
  40886. */
  40887. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40888. /**
  40889. * Adds a submesh into the octree block if it intersects the block
  40890. */
  40891. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40892. }
  40893. }
  40894. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  40895. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40896. import { Scene } from "babylonjs/scene";
  40897. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40899. import { Ray } from "babylonjs/Culling/ray";
  40900. import { Octree } from "babylonjs/Culling/Octrees/octree";
  40901. import { Collider } from "babylonjs/Collisions/collider";
  40902. module "babylonjs/scene" {
  40903. interface Scene {
  40904. /**
  40905. * @hidden
  40906. * Backing Filed
  40907. */
  40908. _selectionOctree: Octree<AbstractMesh>;
  40909. /**
  40910. * Gets the octree used to boost mesh selection (picking)
  40911. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40912. */
  40913. selectionOctree: Octree<AbstractMesh>;
  40914. /**
  40915. * Creates or updates the octree used to boost selection (picking)
  40916. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40917. * @param maxCapacity defines the maximum capacity per leaf
  40918. * @param maxDepth defines the maximum depth of the octree
  40919. * @returns an octree of AbstractMesh
  40920. */
  40921. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40922. }
  40923. }
  40924. module "babylonjs/Meshes/abstractMesh" {
  40925. interface AbstractMesh {
  40926. /**
  40927. * @hidden
  40928. * Backing Field
  40929. */
  40930. _submeshesOctree: Octree<SubMesh>;
  40931. /**
  40932. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40933. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40934. * @param maxCapacity defines the maximum size of each block (64 by default)
  40935. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40936. * @returns the new octree
  40937. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40938. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40939. */
  40940. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40941. }
  40942. }
  40943. /**
  40944. * Defines the octree scene component responsible to manage any octrees
  40945. * in a given scene.
  40946. */
  40947. export class OctreeSceneComponent {
  40948. /**
  40949. * The component name helpfull to identify the component in the list of scene components.
  40950. */
  40951. readonly name: string;
  40952. /**
  40953. * The scene the component belongs to.
  40954. */
  40955. scene: Scene;
  40956. /**
  40957. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40958. */
  40959. readonly checksIsEnabled: boolean;
  40960. /**
  40961. * Creates a new instance of the component for the given scene
  40962. * @param scene Defines the scene to register the component in
  40963. */
  40964. constructor(scene: Scene);
  40965. /**
  40966. * Registers the component in a given scene
  40967. */
  40968. register(): void;
  40969. /**
  40970. * Return the list of active meshes
  40971. * @returns the list of active meshes
  40972. */
  40973. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40974. /**
  40975. * Return the list of active sub meshes
  40976. * @param mesh The mesh to get the candidates sub meshes from
  40977. * @returns the list of active sub meshes
  40978. */
  40979. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40980. private _tempRay;
  40981. /**
  40982. * Return the list of sub meshes intersecting with a given local ray
  40983. * @param mesh defines the mesh to find the submesh for
  40984. * @param localRay defines the ray in local space
  40985. * @returns the list of intersecting sub meshes
  40986. */
  40987. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40988. /**
  40989. * Return the list of sub meshes colliding with a collider
  40990. * @param mesh defines the mesh to find the submesh for
  40991. * @param collider defines the collider to evaluate the collision against
  40992. * @returns the list of colliding sub meshes
  40993. */
  40994. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40995. /**
  40996. * Rebuilds the elements related to this component in case of
  40997. * context lost for instance.
  40998. */
  40999. rebuild(): void;
  41000. /**
  41001. * Disposes the component and the associated ressources.
  41002. */
  41003. dispose(): void;
  41004. }
  41005. }
  41006. declare module "babylonjs/Culling/Octrees/index" {
  41007. export * from "babylonjs/Culling/Octrees/octree";
  41008. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41009. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41010. }
  41011. declare module "babylonjs/Culling/index" {
  41012. export * from "babylonjs/Culling/boundingBox";
  41013. export * from "babylonjs/Culling/boundingInfo";
  41014. export * from "babylonjs/Culling/boundingSphere";
  41015. export * from "babylonjs/Culling/Octrees/index";
  41016. export * from "babylonjs/Culling/ray";
  41017. }
  41018. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  41019. import { Vector3, Color4 } from "babylonjs/Maths/math";
  41020. import { Nullable } from "babylonjs/types";
  41021. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41022. import { Scene } from "babylonjs/scene";
  41023. /**
  41024. * Class containing static functions to help procedurally build meshes
  41025. */
  41026. export class LinesBuilder {
  41027. /**
  41028. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41029. * * 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
  41030. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41031. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41032. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41033. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41034. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41035. * * 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
  41036. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41038. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41039. * @param name defines the name of the new line system
  41040. * @param options defines the options used to create the line system
  41041. * @param scene defines the hosting scene
  41042. * @returns a new line system mesh
  41043. */
  41044. static CreateLineSystem(name: string, options: {
  41045. lines: Vector3[][];
  41046. updatable?: boolean;
  41047. instance?: Nullable<LinesMesh>;
  41048. colors?: Nullable<Color4[][]>;
  41049. useVertexAlpha?: boolean;
  41050. }, scene: Nullable<Scene>): LinesMesh;
  41051. /**
  41052. * Creates a line mesh
  41053. * 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
  41054. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41055. * * The parameter `points` is an array successive Vector3
  41056. * * 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
  41057. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41058. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41059. * * When updating an instance, remember that only point positions can change, not the number of points
  41060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41061. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41062. * @param name defines the name of the new line system
  41063. * @param options defines the options used to create the line system
  41064. * @param scene defines the hosting scene
  41065. * @returns a new line mesh
  41066. */
  41067. static CreateLines(name: string, options: {
  41068. points: Vector3[];
  41069. updatable?: boolean;
  41070. instance?: Nullable<LinesMesh>;
  41071. colors?: Color4[];
  41072. useVertexAlpha?: boolean;
  41073. }, scene?: Nullable<Scene>): LinesMesh;
  41074. /**
  41075. * Creates a dashed line mesh
  41076. * * 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
  41077. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41078. * * The parameter `points` is an array successive Vector3
  41079. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41080. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41081. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41082. * * 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
  41083. * * When updating an instance, remember that only point positions can change, not the number of points
  41084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41085. * @param name defines the name of the mesh
  41086. * @param options defines the options used to create the mesh
  41087. * @param scene defines the hosting scene
  41088. * @returns the dashed line mesh
  41089. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41090. */
  41091. static CreateDashedLines(name: string, options: {
  41092. points: Vector3[];
  41093. dashSize?: number;
  41094. gapSize?: number;
  41095. dashNb?: number;
  41096. updatable?: boolean;
  41097. instance?: LinesMesh;
  41098. }, scene?: Nullable<Scene>): LinesMesh;
  41099. }
  41100. }
  41101. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41102. import { IDisposable, Scene } from "babylonjs/scene";
  41103. import { Nullable } from "babylonjs/types";
  41104. import { Observable } from "babylonjs/Misc/observable";
  41105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41106. /**
  41107. * Renders a layer on top of an existing scene
  41108. */
  41109. export class UtilityLayerRenderer implements IDisposable {
  41110. /** the original scene that will be rendered on top of */
  41111. originalScene: Scene;
  41112. private _pointerCaptures;
  41113. private _lastPointerEvents;
  41114. private static _DefaultUtilityLayer;
  41115. private static _DefaultKeepDepthUtilityLayer;
  41116. /**
  41117. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41118. */
  41119. pickUtilitySceneFirst: boolean;
  41120. /**
  41121. * 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)
  41122. */
  41123. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41124. /**
  41125. * 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)
  41126. */
  41127. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41128. /**
  41129. * The scene that is rendered on top of the original scene
  41130. */
  41131. utilityLayerScene: Scene;
  41132. /**
  41133. * If the utility layer should automatically be rendered on top of existing scene
  41134. */
  41135. shouldRender: boolean;
  41136. /**
  41137. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41138. */
  41139. onlyCheckPointerDownEvents: boolean;
  41140. /**
  41141. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41142. */
  41143. processAllEvents: boolean;
  41144. /**
  41145. * Observable raised when the pointer move from the utility layer scene to the main scene
  41146. */
  41147. onPointerOutObservable: Observable<number>;
  41148. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41149. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41150. private _afterRenderObserver;
  41151. private _sceneDisposeObserver;
  41152. private _originalPointerObserver;
  41153. /**
  41154. * Instantiates a UtilityLayerRenderer
  41155. * @param originalScene the original scene that will be rendered on top of
  41156. * @param handleEvents boolean indicating if the utility layer should handle events
  41157. */
  41158. constructor(
  41159. /** the original scene that will be rendered on top of */
  41160. originalScene: Scene, handleEvents?: boolean);
  41161. private _notifyObservers;
  41162. /**
  41163. * Renders the utility layers scene on top of the original scene
  41164. */
  41165. render(): void;
  41166. /**
  41167. * Disposes of the renderer
  41168. */
  41169. dispose(): void;
  41170. private _updateCamera;
  41171. }
  41172. }
  41173. declare module "babylonjs/Gizmos/gizmo" {
  41174. import { Nullable } from "babylonjs/types";
  41175. import { IDisposable } from "babylonjs/scene";
  41176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41177. import { Mesh } from "babylonjs/Meshes/mesh";
  41178. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41179. /**
  41180. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41181. */
  41182. export class Gizmo implements IDisposable {
  41183. /** The utility layer the gizmo will be added to */
  41184. gizmoLayer: UtilityLayerRenderer;
  41185. /**
  41186. * The root mesh of the gizmo
  41187. */
  41188. _rootMesh: Mesh;
  41189. private _attachedMesh;
  41190. /**
  41191. * Ratio for the scale of the gizmo (Default: 1)
  41192. */
  41193. scaleRatio: number;
  41194. private _tmpMatrix;
  41195. /**
  41196. * If a custom mesh has been set (Default: false)
  41197. */
  41198. protected _customMeshSet: boolean;
  41199. /**
  41200. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41201. * * When set, interactions will be enabled
  41202. */
  41203. attachedMesh: Nullable<AbstractMesh>;
  41204. /**
  41205. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41206. * @param mesh The mesh to replace the default mesh of the gizmo
  41207. */
  41208. setCustomMesh(mesh: Mesh): void;
  41209. /**
  41210. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41211. */
  41212. updateGizmoRotationToMatchAttachedMesh: boolean;
  41213. /**
  41214. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41215. */
  41216. updateGizmoPositionToMatchAttachedMesh: boolean;
  41217. /**
  41218. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41219. */
  41220. protected _updateScale: boolean;
  41221. protected _interactionsEnabled: boolean;
  41222. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41223. private _beforeRenderObserver;
  41224. /**
  41225. * Creates a gizmo
  41226. * @param gizmoLayer The utility layer the gizmo will be added to
  41227. */
  41228. constructor(
  41229. /** The utility layer the gizmo will be added to */
  41230. gizmoLayer?: UtilityLayerRenderer);
  41231. private _tempVector;
  41232. /**
  41233. * @hidden
  41234. * Updates the gizmo to match the attached mesh's position/rotation
  41235. */
  41236. protected _update(): void;
  41237. /**
  41238. * Disposes of the gizmo
  41239. */
  41240. dispose(): void;
  41241. }
  41242. }
  41243. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41244. import { Observable } from "babylonjs/Misc/observable";
  41245. import { Nullable } from "babylonjs/types";
  41246. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41247. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41249. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41250. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41251. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41252. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41253. import { Scene } from "babylonjs/scene";
  41254. /**
  41255. * Single axis drag gizmo
  41256. */
  41257. export class AxisDragGizmo extends Gizmo {
  41258. /**
  41259. * Drag behavior responsible for the gizmos dragging interactions
  41260. */
  41261. dragBehavior: PointerDragBehavior;
  41262. private _pointerObserver;
  41263. /**
  41264. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41265. */
  41266. snapDistance: number;
  41267. /**
  41268. * Event that fires each time the gizmo snaps to a new location.
  41269. * * snapDistance is the the change in distance
  41270. */
  41271. onSnapObservable: Observable<{
  41272. snapDistance: number;
  41273. }>;
  41274. /** @hidden */
  41275. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41276. /** @hidden */
  41277. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41278. /**
  41279. * Creates an AxisDragGizmo
  41280. * @param gizmoLayer The utility layer the gizmo will be added to
  41281. * @param dragAxis The axis which the gizmo will be able to drag on
  41282. * @param color The color of the gizmo
  41283. */
  41284. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41285. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41286. /**
  41287. * Disposes of the gizmo
  41288. */
  41289. dispose(): void;
  41290. }
  41291. }
  41292. declare module "babylonjs/Debug/axesViewer" {
  41293. import { Vector3 } from "babylonjs/Maths/math";
  41294. import { Nullable } from "babylonjs/types";
  41295. import { Scene } from "babylonjs/scene";
  41296. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41297. /**
  41298. * The Axes viewer will show 3 axes in a specific point in space
  41299. */
  41300. export class AxesViewer {
  41301. private _xAxis;
  41302. private _yAxis;
  41303. private _zAxis;
  41304. private _scaleLinesFactor;
  41305. private _instanced;
  41306. /**
  41307. * Gets the hosting scene
  41308. */
  41309. scene: Scene;
  41310. /**
  41311. * Gets or sets a number used to scale line length
  41312. */
  41313. scaleLines: number;
  41314. /** Gets the node hierarchy used to render x-axis */
  41315. readonly xAxis: TransformNode;
  41316. /** Gets the node hierarchy used to render y-axis */
  41317. readonly yAxis: TransformNode;
  41318. /** Gets the node hierarchy used to render z-axis */
  41319. readonly zAxis: TransformNode;
  41320. /**
  41321. * Creates a new AxesViewer
  41322. * @param scene defines the hosting scene
  41323. * @param scaleLines defines a number used to scale line length (1 by default)
  41324. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41325. * @param xAxis defines the node hierarchy used to render the x-axis
  41326. * @param yAxis defines the node hierarchy used to render the y-axis
  41327. * @param zAxis defines the node hierarchy used to render the z-axis
  41328. */
  41329. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41330. /**
  41331. * Force the viewer to update
  41332. * @param position defines the position of the viewer
  41333. * @param xaxis defines the x axis of the viewer
  41334. * @param yaxis defines the y axis of the viewer
  41335. * @param zaxis defines the z axis of the viewer
  41336. */
  41337. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41338. /**
  41339. * Creates an instance of this axes viewer.
  41340. * @returns a new axes viewer with instanced meshes
  41341. */
  41342. createInstance(): AxesViewer;
  41343. /** Releases resources */
  41344. dispose(): void;
  41345. private static _SetRenderingGroupId;
  41346. }
  41347. }
  41348. declare module "babylonjs/Debug/boneAxesViewer" {
  41349. import { Nullable } from "babylonjs/types";
  41350. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41351. import { Vector3 } from "babylonjs/Maths/math";
  41352. import { Mesh } from "babylonjs/Meshes/mesh";
  41353. import { Bone } from "babylonjs/Bones/bone";
  41354. import { Scene } from "babylonjs/scene";
  41355. /**
  41356. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41357. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41358. */
  41359. export class BoneAxesViewer extends AxesViewer {
  41360. /**
  41361. * Gets or sets the target mesh where to display the axes viewer
  41362. */
  41363. mesh: Nullable<Mesh>;
  41364. /**
  41365. * Gets or sets the target bone where to display the axes viewer
  41366. */
  41367. bone: Nullable<Bone>;
  41368. /** Gets current position */
  41369. pos: Vector3;
  41370. /** Gets direction of X axis */
  41371. xaxis: Vector3;
  41372. /** Gets direction of Y axis */
  41373. yaxis: Vector3;
  41374. /** Gets direction of Z axis */
  41375. zaxis: Vector3;
  41376. /**
  41377. * Creates a new BoneAxesViewer
  41378. * @param scene defines the hosting scene
  41379. * @param bone defines the target bone
  41380. * @param mesh defines the target mesh
  41381. * @param scaleLines defines a scaling factor for line length (1 by default)
  41382. */
  41383. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41384. /**
  41385. * Force the viewer to update
  41386. */
  41387. update(): void;
  41388. /** Releases resources */
  41389. dispose(): void;
  41390. }
  41391. }
  41392. declare module "babylonjs/Debug/debugLayer" {
  41393. import { Observable } from "babylonjs/Misc/observable";
  41394. import { Scene } from "babylonjs/scene";
  41395. /**
  41396. * Interface used to define scene explorer extensibility option
  41397. */
  41398. export interface IExplorerExtensibilityOption {
  41399. /**
  41400. * Define the option label
  41401. */
  41402. label: string;
  41403. /**
  41404. * Defines the action to execute on click
  41405. */
  41406. action: (entity: any) => void;
  41407. }
  41408. /**
  41409. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41410. */
  41411. export interface IExplorerExtensibilityGroup {
  41412. /**
  41413. * Defines a predicate to test if a given type mut be extended
  41414. */
  41415. predicate: (entity: any) => boolean;
  41416. /**
  41417. * Gets the list of options added to a type
  41418. */
  41419. entries: IExplorerExtensibilityOption[];
  41420. }
  41421. /**
  41422. * Interface used to define the options to use to create the Inspector
  41423. */
  41424. export interface IInspectorOptions {
  41425. /**
  41426. * Display in overlay mode (default: false)
  41427. */
  41428. overlay?: boolean;
  41429. /**
  41430. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41431. */
  41432. globalRoot?: HTMLElement;
  41433. /**
  41434. * Display the Scene explorer
  41435. */
  41436. showExplorer?: boolean;
  41437. /**
  41438. * Display the property inspector
  41439. */
  41440. showInspector?: boolean;
  41441. /**
  41442. * Display in embed mode (both panes on the right)
  41443. */
  41444. embedMode?: boolean;
  41445. /**
  41446. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41447. */
  41448. handleResize?: boolean;
  41449. /**
  41450. * Allow the panes to popup (default: true)
  41451. */
  41452. enablePopup?: boolean;
  41453. /**
  41454. * Allow the panes to be closed by users (default: true)
  41455. */
  41456. enableClose?: boolean;
  41457. /**
  41458. * Optional list of extensibility entries
  41459. */
  41460. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41461. /**
  41462. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41463. */
  41464. inspectorURL?: string;
  41465. }
  41466. module "babylonjs/scene" {
  41467. interface Scene {
  41468. /**
  41469. * @hidden
  41470. * Backing field
  41471. */
  41472. _debugLayer: DebugLayer;
  41473. /**
  41474. * Gets the debug layer (aka Inspector) associated with the scene
  41475. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41476. */
  41477. debugLayer: DebugLayer;
  41478. }
  41479. }
  41480. /**
  41481. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41482. * what is happening in your scene
  41483. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41484. */
  41485. export class DebugLayer {
  41486. /**
  41487. * Define the url to get the inspector script from.
  41488. * By default it uses the babylonjs CDN.
  41489. * @ignoreNaming
  41490. */
  41491. static InspectorURL: string;
  41492. private _scene;
  41493. private BJSINSPECTOR;
  41494. /**
  41495. * Observable triggered when a property is changed through the inspector.
  41496. */
  41497. onPropertyChangedObservable: Observable<{
  41498. object: any;
  41499. property: string;
  41500. value: any;
  41501. initialValue: any;
  41502. }>;
  41503. /**
  41504. * Instantiates a new debug layer.
  41505. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41506. * what is happening in your scene
  41507. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41508. * @param scene Defines the scene to inspect
  41509. */
  41510. constructor(scene: Scene);
  41511. /** Creates the inspector window. */
  41512. private _createInspector;
  41513. /**
  41514. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41515. * @param entity defines the entity to select
  41516. * @param lineContainerTitle defines the specific block to highlight
  41517. */
  41518. select(entity: any, lineContainerTitle?: string): void;
  41519. /** Get the inspector from bundle or global */
  41520. private _getGlobalInspector;
  41521. /**
  41522. * Get if the inspector is visible or not.
  41523. * @returns true if visible otherwise, false
  41524. */
  41525. isVisible(): boolean;
  41526. /**
  41527. * Hide the inspector and close its window.
  41528. */
  41529. hide(): void;
  41530. /**
  41531. * Launch the debugLayer.
  41532. * @param config Define the configuration of the inspector
  41533. * @return a promise fulfilled when the debug layer is visible
  41534. */
  41535. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41536. }
  41537. }
  41538. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41539. import { Nullable } from "babylonjs/types";
  41540. import { Scene } from "babylonjs/scene";
  41541. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41542. import { Mesh } from "babylonjs/Meshes/mesh";
  41543. /**
  41544. * Class containing static functions to help procedurally build meshes
  41545. */
  41546. export class BoxBuilder {
  41547. /**
  41548. * Creates a box mesh
  41549. * * The parameter `size` sets the size (float) of each box side (default 1)
  41550. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41551. * * 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)
  41552. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41553. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41554. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41556. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41557. * @param name defines the name of the mesh
  41558. * @param options defines the options used to create the mesh
  41559. * @param scene defines the hosting scene
  41560. * @returns the box mesh
  41561. */
  41562. static CreateBox(name: string, options: {
  41563. size?: number;
  41564. width?: number;
  41565. height?: number;
  41566. depth?: number;
  41567. faceUV?: Vector4[];
  41568. faceColors?: Color4[];
  41569. sideOrientation?: number;
  41570. frontUVs?: Vector4;
  41571. backUVs?: Vector4;
  41572. updatable?: boolean;
  41573. }, scene?: Nullable<Scene>): Mesh;
  41574. }
  41575. }
  41576. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41577. import { Vector4 } from "babylonjs/Maths/math";
  41578. import { Mesh } from "babylonjs/Meshes/mesh";
  41579. /**
  41580. * Class containing static functions to help procedurally build meshes
  41581. */
  41582. export class SphereBuilder {
  41583. /**
  41584. * Creates a sphere mesh
  41585. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41586. * * 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`)
  41587. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41588. * * 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
  41589. * * 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)
  41590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41591. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41593. * @param name defines the name of the mesh
  41594. * @param options defines the options used to create the mesh
  41595. * @param scene defines the hosting scene
  41596. * @returns the sphere mesh
  41597. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41598. */
  41599. static CreateSphere(name: string, options: {
  41600. segments?: number;
  41601. diameter?: number;
  41602. diameterX?: number;
  41603. diameterY?: number;
  41604. diameterZ?: number;
  41605. arc?: number;
  41606. slice?: number;
  41607. sideOrientation?: number;
  41608. frontUVs?: Vector4;
  41609. backUVs?: Vector4;
  41610. updatable?: boolean;
  41611. }, scene: any): Mesh;
  41612. }
  41613. }
  41614. declare module "babylonjs/Debug/physicsViewer" {
  41615. import { Nullable } from "babylonjs/types";
  41616. import { Scene } from "babylonjs/scene";
  41617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41618. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41619. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41620. /**
  41621. * Used to show the physics impostor around the specific mesh
  41622. */
  41623. export class PhysicsViewer {
  41624. /** @hidden */
  41625. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41626. /** @hidden */
  41627. protected _meshes: Array<Nullable<AbstractMesh>>;
  41628. /** @hidden */
  41629. protected _scene: Nullable<Scene>;
  41630. /** @hidden */
  41631. protected _numMeshes: number;
  41632. /** @hidden */
  41633. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41634. private _renderFunction;
  41635. private _utilityLayer;
  41636. private _debugBoxMesh;
  41637. private _debugSphereMesh;
  41638. private _debugMaterial;
  41639. /**
  41640. * Creates a new PhysicsViewer
  41641. * @param scene defines the hosting scene
  41642. */
  41643. constructor(scene: Scene);
  41644. /** @hidden */
  41645. protected _updateDebugMeshes(): void;
  41646. /**
  41647. * Renders a specified physic impostor
  41648. * @param impostor defines the impostor to render
  41649. * @returns the new debug mesh used to render the impostor
  41650. */
  41651. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41652. /**
  41653. * Hides a specified physic impostor
  41654. * @param impostor defines the impostor to hide
  41655. */
  41656. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41657. private _getDebugMaterial;
  41658. private _getDebugBoxMesh;
  41659. private _getDebugSphereMesh;
  41660. private _getDebugMesh;
  41661. /** Releases all resources */
  41662. dispose(): void;
  41663. }
  41664. }
  41665. declare module "babylonjs/Debug/rayHelper" {
  41666. import { Nullable } from "babylonjs/types";
  41667. import { Ray } from "babylonjs/Culling/ray";
  41668. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41669. import { Scene } from "babylonjs/scene";
  41670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41671. import "babylonjs/Meshes/Builders/linesBuilder";
  41672. /**
  41673. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41674. * in order to better appreciate the issue one might have.
  41675. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41676. */
  41677. export class RayHelper {
  41678. /**
  41679. * Defines the ray we are currently tryin to visualize.
  41680. */
  41681. ray: Nullable<Ray>;
  41682. private _renderPoints;
  41683. private _renderLine;
  41684. private _renderFunction;
  41685. private _scene;
  41686. private _updateToMeshFunction;
  41687. private _attachedToMesh;
  41688. private _meshSpaceDirection;
  41689. private _meshSpaceOrigin;
  41690. /**
  41691. * Helper function to create a colored helper in a scene in one line.
  41692. * @param ray Defines the ray we are currently tryin to visualize
  41693. * @param scene Defines the scene the ray is used in
  41694. * @param color Defines the color we want to see the ray in
  41695. * @returns The newly created ray helper.
  41696. */
  41697. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41698. /**
  41699. * Instantiate a new ray helper.
  41700. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41701. * in order to better appreciate the issue one might have.
  41702. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41703. * @param ray Defines the ray we are currently tryin to visualize
  41704. */
  41705. constructor(ray: Ray);
  41706. /**
  41707. * Shows the ray we are willing to debug.
  41708. * @param scene Defines the scene the ray needs to be rendered in
  41709. * @param color Defines the color the ray needs to be rendered in
  41710. */
  41711. show(scene: Scene, color?: Color3): void;
  41712. /**
  41713. * Hides the ray we are debugging.
  41714. */
  41715. hide(): void;
  41716. private _render;
  41717. /**
  41718. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41719. * @param mesh Defines the mesh we want the helper attached to
  41720. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41721. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41722. * @param length Defines the length of the ray
  41723. */
  41724. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41725. /**
  41726. * Detach the ray helper from the mesh it has previously been attached to.
  41727. */
  41728. detachFromMesh(): void;
  41729. private _updateToMesh;
  41730. /**
  41731. * Dispose the helper and release its associated resources.
  41732. */
  41733. dispose(): void;
  41734. }
  41735. }
  41736. declare module "babylonjs/Debug/skeletonViewer" {
  41737. import { Color3 } from "babylonjs/Maths/math";
  41738. import { Scene } from "babylonjs/scene";
  41739. import { Nullable } from "babylonjs/types";
  41740. import { Skeleton } from "babylonjs/Bones/skeleton";
  41741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41742. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41743. /**
  41744. * Class used to render a debug view of a given skeleton
  41745. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41746. */
  41747. export class SkeletonViewer {
  41748. /** defines the skeleton to render */
  41749. skeleton: Skeleton;
  41750. /** defines the mesh attached to the skeleton */
  41751. mesh: AbstractMesh;
  41752. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41753. autoUpdateBonesMatrices: boolean;
  41754. /** defines the rendering group id to use with the viewer */
  41755. renderingGroupId: number;
  41756. /** Gets or sets the color used to render the skeleton */
  41757. color: Color3;
  41758. private _scene;
  41759. private _debugLines;
  41760. private _debugMesh;
  41761. private _isEnabled;
  41762. private _renderFunction;
  41763. private _utilityLayer;
  41764. /**
  41765. * Returns the mesh used to render the bones
  41766. */
  41767. readonly debugMesh: Nullable<LinesMesh>;
  41768. /**
  41769. * Creates a new SkeletonViewer
  41770. * @param skeleton defines the skeleton to render
  41771. * @param mesh defines the mesh attached to the skeleton
  41772. * @param scene defines the hosting scene
  41773. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41774. * @param renderingGroupId defines the rendering group id to use with the viewer
  41775. */
  41776. constructor(
  41777. /** defines the skeleton to render */
  41778. skeleton: Skeleton,
  41779. /** defines the mesh attached to the skeleton */
  41780. mesh: AbstractMesh, scene: Scene,
  41781. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41782. autoUpdateBonesMatrices?: boolean,
  41783. /** defines the rendering group id to use with the viewer */
  41784. renderingGroupId?: number);
  41785. /** Gets or sets a boolean indicating if the viewer is enabled */
  41786. isEnabled: boolean;
  41787. private _getBonePosition;
  41788. private _getLinesForBonesWithLength;
  41789. private _getLinesForBonesNoLength;
  41790. /** Update the viewer to sync with current skeleton state */
  41791. update(): void;
  41792. /** Release associated resources */
  41793. dispose(): void;
  41794. }
  41795. }
  41796. declare module "babylonjs/Debug/index" {
  41797. export * from "babylonjs/Debug/axesViewer";
  41798. export * from "babylonjs/Debug/boneAxesViewer";
  41799. export * from "babylonjs/Debug/debugLayer";
  41800. export * from "babylonjs/Debug/physicsViewer";
  41801. export * from "babylonjs/Debug/rayHelper";
  41802. export * from "babylonjs/Debug/skeletonViewer";
  41803. }
  41804. declare module "babylonjs/Engines/nullEngine" {
  41805. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41806. import { Scene } from "babylonjs/scene";
  41807. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41808. import { Engine } from "babylonjs/Engines/engine";
  41809. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41810. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41811. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41812. import { Effect } from "babylonjs/Materials/effect";
  41813. /**
  41814. * Options to create the null engine
  41815. */
  41816. export class NullEngineOptions {
  41817. /**
  41818. * Render width (Default: 512)
  41819. */
  41820. renderWidth: number;
  41821. /**
  41822. * Render height (Default: 256)
  41823. */
  41824. renderHeight: number;
  41825. /**
  41826. * Texture size (Default: 512)
  41827. */
  41828. textureSize: number;
  41829. /**
  41830. * If delta time between frames should be constant
  41831. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41832. */
  41833. deterministicLockstep: boolean;
  41834. /**
  41835. * Maximum about of steps between frames (Default: 4)
  41836. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41837. */
  41838. lockstepMaxSteps: number;
  41839. }
  41840. /**
  41841. * The null engine class provides support for headless version of babylon.js.
  41842. * This can be used in server side scenario or for testing purposes
  41843. */
  41844. export class NullEngine extends Engine {
  41845. private _options;
  41846. /**
  41847. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41848. */
  41849. isDeterministicLockStep(): boolean;
  41850. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41851. getLockstepMaxSteps(): number;
  41852. /**
  41853. * Sets hardware scaling, used to save performance if needed
  41854. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41855. */
  41856. getHardwareScalingLevel(): number;
  41857. constructor(options?: NullEngineOptions);
  41858. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41859. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41860. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41861. getRenderWidth(useScreen?: boolean): number;
  41862. getRenderHeight(useScreen?: boolean): number;
  41863. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41864. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41865. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41866. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41867. bindSamplers(effect: Effect): void;
  41868. enableEffect(effect: Effect): void;
  41869. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41870. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41871. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41872. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41873. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41874. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41875. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41876. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41877. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41878. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41879. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41880. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41881. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41882. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41883. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41884. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41885. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41886. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41887. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41888. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41889. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41890. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41891. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41892. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41893. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41894. bindBuffers(vertexBuffers: {
  41895. [key: string]: VertexBuffer;
  41896. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41897. wipeCaches(bruteForce?: boolean): void;
  41898. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41899. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41900. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41901. /** @hidden */
  41902. _createTexture(): WebGLTexture;
  41903. /** @hidden */
  41904. _releaseTexture(texture: InternalTexture): void;
  41905. 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;
  41906. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41907. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41908. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41909. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41910. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41911. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41912. areAllEffectsReady(): boolean;
  41913. /**
  41914. * @hidden
  41915. * Get the current error code of the webGL context
  41916. * @returns the error code
  41917. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41918. */
  41919. getError(): number;
  41920. /** @hidden */
  41921. _getUnpackAlignement(): number;
  41922. /** @hidden */
  41923. _unpackFlipY(value: boolean): void;
  41924. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41925. /**
  41926. * Updates a dynamic vertex buffer.
  41927. * @param vertexBuffer the vertex buffer to update
  41928. * @param data the data used to update the vertex buffer
  41929. * @param byteOffset the byte offset of the data (optional)
  41930. * @param byteLength the byte length of the data (optional)
  41931. */
  41932. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41933. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41934. /** @hidden */
  41935. _bindTexture(channel: number, texture: InternalTexture): void;
  41936. /** @hidden */
  41937. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41938. releaseEffects(): void;
  41939. displayLoadingUI(): void;
  41940. hideLoadingUI(): void;
  41941. /** @hidden */
  41942. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41943. /** @hidden */
  41944. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41945. /** @hidden */
  41946. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41947. /** @hidden */
  41948. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41949. }
  41950. }
  41951. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  41952. import { Nullable, int } from "babylonjs/types";
  41953. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  41954. /** @hidden */
  41955. export class _OcclusionDataStorage {
  41956. /** @hidden */
  41957. occlusionInternalRetryCounter: number;
  41958. /** @hidden */
  41959. isOcclusionQueryInProgress: boolean;
  41960. /** @hidden */
  41961. isOccluded: boolean;
  41962. /** @hidden */
  41963. occlusionRetryCount: number;
  41964. /** @hidden */
  41965. occlusionType: number;
  41966. /** @hidden */
  41967. occlusionQueryAlgorithmType: number;
  41968. }
  41969. module "babylonjs/Engines/engine" {
  41970. interface Engine {
  41971. /**
  41972. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41973. * @return the new query
  41974. */
  41975. createQuery(): WebGLQuery;
  41976. /**
  41977. * Delete and release a webGL query
  41978. * @param query defines the query to delete
  41979. * @return the current engine
  41980. */
  41981. deleteQuery(query: WebGLQuery): Engine;
  41982. /**
  41983. * Check if a given query has resolved and got its value
  41984. * @param query defines the query to check
  41985. * @returns true if the query got its value
  41986. */
  41987. isQueryResultAvailable(query: WebGLQuery): boolean;
  41988. /**
  41989. * Gets the value of a given query
  41990. * @param query defines the query to check
  41991. * @returns the value of the query
  41992. */
  41993. getQueryResult(query: WebGLQuery): number;
  41994. /**
  41995. * Initiates an occlusion query
  41996. * @param algorithmType defines the algorithm to use
  41997. * @param query defines the query to use
  41998. * @returns the current engine
  41999. * @see http://doc.babylonjs.com/features/occlusionquery
  42000. */
  42001. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42002. /**
  42003. * Ends an occlusion query
  42004. * @see http://doc.babylonjs.com/features/occlusionquery
  42005. * @param algorithmType defines the algorithm to use
  42006. * @returns the current engine
  42007. */
  42008. endOcclusionQuery(algorithmType: number): Engine;
  42009. /**
  42010. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42011. * Please note that only one query can be issued at a time
  42012. * @returns a time token used to track the time span
  42013. */
  42014. startTimeQuery(): Nullable<_TimeToken>;
  42015. /**
  42016. * Ends a time query
  42017. * @param token defines the token used to measure the time span
  42018. * @returns the time spent (in ns)
  42019. */
  42020. endTimeQuery(token: _TimeToken): int;
  42021. /** @hidden */
  42022. _currentNonTimestampToken: Nullable<_TimeToken>;
  42023. /** @hidden */
  42024. _createTimeQuery(): WebGLQuery;
  42025. /** @hidden */
  42026. _deleteTimeQuery(query: WebGLQuery): void;
  42027. /** @hidden */
  42028. _getGlAlgorithmType(algorithmType: number): number;
  42029. /** @hidden */
  42030. _getTimeQueryResult(query: WebGLQuery): any;
  42031. /** @hidden */
  42032. _getTimeQueryAvailability(query: WebGLQuery): any;
  42033. }
  42034. }
  42035. module "babylonjs/Meshes/abstractMesh" {
  42036. interface AbstractMesh {
  42037. /**
  42038. * Backing filed
  42039. * @hidden
  42040. */
  42041. __occlusionDataStorage: _OcclusionDataStorage;
  42042. /**
  42043. * Access property
  42044. * @hidden
  42045. */
  42046. _occlusionDataStorage: _OcclusionDataStorage;
  42047. /**
  42048. * 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.
  42049. * The default value is -1 which means don't break the query and wait till the result
  42050. * @see http://doc.babylonjs.com/features/occlusionquery
  42051. */
  42052. occlusionRetryCount: number;
  42053. /**
  42054. * 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:
  42055. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42056. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42057. * * 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.
  42058. * @see http://doc.babylonjs.com/features/occlusionquery
  42059. */
  42060. occlusionType: number;
  42061. /**
  42062. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42063. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42064. * * 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.
  42065. * @see http://doc.babylonjs.com/features/occlusionquery
  42066. */
  42067. occlusionQueryAlgorithmType: number;
  42068. /**
  42069. * 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
  42070. * @see http://doc.babylonjs.com/features/occlusionquery
  42071. */
  42072. isOccluded: boolean;
  42073. /**
  42074. * Flag to check the progress status of the query
  42075. * @see http://doc.babylonjs.com/features/occlusionquery
  42076. */
  42077. isOcclusionQueryInProgress: boolean;
  42078. }
  42079. }
  42080. }
  42081. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42082. import { Nullable } from "babylonjs/types";
  42083. /** @hidden */
  42084. export var _forceTransformFeedbackToBundle: boolean;
  42085. module "babylonjs/Engines/engine" {
  42086. interface Engine {
  42087. /**
  42088. * Creates a webGL transform feedback object
  42089. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42090. * @returns the webGL transform feedback object
  42091. */
  42092. createTransformFeedback(): WebGLTransformFeedback;
  42093. /**
  42094. * Delete a webGL transform feedback object
  42095. * @param value defines the webGL transform feedback object to delete
  42096. */
  42097. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42098. /**
  42099. * Bind a webGL transform feedback object to the webgl context
  42100. * @param value defines the webGL transform feedback object to bind
  42101. */
  42102. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42103. /**
  42104. * Begins a transform feedback operation
  42105. * @param usePoints defines if points or triangles must be used
  42106. */
  42107. beginTransformFeedback(usePoints: boolean): void;
  42108. /**
  42109. * Ends a transform feedback operation
  42110. */
  42111. endTransformFeedback(): void;
  42112. /**
  42113. * Specify the varyings to use with transform feedback
  42114. * @param program defines the associated webGL program
  42115. * @param value defines the list of strings representing the varying names
  42116. */
  42117. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42118. /**
  42119. * Bind a webGL buffer for a transform feedback operation
  42120. * @param value defines the webGL buffer to bind
  42121. */
  42122. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42123. }
  42124. }
  42125. }
  42126. declare module "babylonjs/Engines/Extensions/index" {
  42127. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42128. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42129. }
  42130. declare module "babylonjs/Engines/index" {
  42131. export * from "babylonjs/Engines/constants";
  42132. export * from "babylonjs/Engines/engine";
  42133. export * from "babylonjs/Engines/engineStore";
  42134. export * from "babylonjs/Engines/nullEngine";
  42135. export * from "babylonjs/Engines/Extensions/index";
  42136. }
  42137. declare module "babylonjs/Events/clipboardEvents" {
  42138. /**
  42139. * Gather the list of clipboard event types as constants.
  42140. */
  42141. export class ClipboardEventTypes {
  42142. /**
  42143. * The clipboard event is fired when a copy command is active (pressed).
  42144. */
  42145. static readonly COPY: number;
  42146. /**
  42147. * The clipboard event is fired when a cut command is active (pressed).
  42148. */
  42149. static readonly CUT: number;
  42150. /**
  42151. * The clipboard event is fired when a paste command is active (pressed).
  42152. */
  42153. static readonly PASTE: number;
  42154. }
  42155. /**
  42156. * This class is used to store clipboard related info for the onClipboardObservable event.
  42157. */
  42158. export class ClipboardInfo {
  42159. /**
  42160. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42161. */
  42162. type: number;
  42163. /**
  42164. * Defines the related dom event
  42165. */
  42166. event: ClipboardEvent;
  42167. /**
  42168. *Creates an instance of ClipboardInfo.
  42169. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42170. * @param event Defines the related dom event
  42171. */
  42172. constructor(
  42173. /**
  42174. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42175. */
  42176. type: number,
  42177. /**
  42178. * Defines the related dom event
  42179. */
  42180. event: ClipboardEvent);
  42181. /**
  42182. * Get the clipboard event's type from the keycode.
  42183. * @param keyCode Defines the keyCode for the current keyboard event.
  42184. * @return {number}
  42185. */
  42186. static GetTypeFromCharacter(keyCode: number): number;
  42187. }
  42188. }
  42189. declare module "babylonjs/Events/index" {
  42190. export * from "babylonjs/Events/keyboardEvents";
  42191. export * from "babylonjs/Events/pointerEvents";
  42192. export * from "babylonjs/Events/clipboardEvents";
  42193. }
  42194. declare module "babylonjs/Loading/sceneLoader" {
  42195. import { Observable } from "babylonjs/Misc/observable";
  42196. import { Nullable } from "babylonjs/types";
  42197. import { Scene } from "babylonjs/scene";
  42198. import { Engine } from "babylonjs/Engines/engine";
  42199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42200. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42201. import { AssetContainer } from "babylonjs/assetContainer";
  42202. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42203. import { Skeleton } from "babylonjs/Bones/skeleton";
  42204. /**
  42205. * Class used to represent data loading progression
  42206. */
  42207. export class SceneLoaderProgressEvent {
  42208. /** defines if data length to load can be evaluated */
  42209. readonly lengthComputable: boolean;
  42210. /** defines the loaded data length */
  42211. readonly loaded: number;
  42212. /** defines the data length to load */
  42213. readonly total: number;
  42214. /**
  42215. * Create a new progress event
  42216. * @param lengthComputable defines if data length to load can be evaluated
  42217. * @param loaded defines the loaded data length
  42218. * @param total defines the data length to load
  42219. */
  42220. constructor(
  42221. /** defines if data length to load can be evaluated */
  42222. lengthComputable: boolean,
  42223. /** defines the loaded data length */
  42224. loaded: number,
  42225. /** defines the data length to load */
  42226. total: number);
  42227. /**
  42228. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42229. * @param event defines the source event
  42230. * @returns a new SceneLoaderProgressEvent
  42231. */
  42232. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42233. }
  42234. /**
  42235. * Interface used by SceneLoader plugins to define supported file extensions
  42236. */
  42237. export interface ISceneLoaderPluginExtensions {
  42238. /**
  42239. * Defines the list of supported extensions
  42240. */
  42241. [extension: string]: {
  42242. isBinary: boolean;
  42243. };
  42244. }
  42245. /**
  42246. * Interface used by SceneLoader plugin factory
  42247. */
  42248. export interface ISceneLoaderPluginFactory {
  42249. /**
  42250. * Defines the name of the factory
  42251. */
  42252. name: string;
  42253. /**
  42254. * Function called to create a new plugin
  42255. * @return the new plugin
  42256. */
  42257. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42258. /**
  42259. * Boolean indicating if the plugin can direct load specific data
  42260. */
  42261. canDirectLoad?: (data: string) => boolean;
  42262. }
  42263. /**
  42264. * Interface used to define a SceneLoader plugin
  42265. */
  42266. export interface ISceneLoaderPlugin {
  42267. /**
  42268. * The friendly name of this plugin.
  42269. */
  42270. name: string;
  42271. /**
  42272. * The file extensions supported by this plugin.
  42273. */
  42274. extensions: string | ISceneLoaderPluginExtensions;
  42275. /**
  42276. * Import meshes into a scene.
  42277. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42278. * @param scene The scene to import into
  42279. * @param data The data to import
  42280. * @param rootUrl The root url for scene and resources
  42281. * @param meshes The meshes array to import into
  42282. * @param particleSystems The particle systems array to import into
  42283. * @param skeletons The skeletons array to import into
  42284. * @param onError The callback when import fails
  42285. * @returns True if successful or false otherwise
  42286. */
  42287. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42288. /**
  42289. * Load into a scene.
  42290. * @param scene The scene to load into
  42291. * @param data The data to import
  42292. * @param rootUrl The root url for scene and resources
  42293. * @param onError The callback when import fails
  42294. * @returns true if successful or false otherwise
  42295. */
  42296. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42297. /**
  42298. * The callback that returns true if the data can be directly loaded.
  42299. */
  42300. canDirectLoad?: (data: string) => boolean;
  42301. /**
  42302. * The callback that allows custom handling of the root url based on the response url.
  42303. */
  42304. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42305. /**
  42306. * Load into an asset container.
  42307. * @param scene The scene to load into
  42308. * @param data The data to import
  42309. * @param rootUrl The root url for scene and resources
  42310. * @param onError The callback when import fails
  42311. * @returns The loaded asset container
  42312. */
  42313. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42314. }
  42315. /**
  42316. * Interface used to define an async SceneLoader plugin
  42317. */
  42318. export interface ISceneLoaderPluginAsync {
  42319. /**
  42320. * The friendly name of this plugin.
  42321. */
  42322. name: string;
  42323. /**
  42324. * The file extensions supported by this plugin.
  42325. */
  42326. extensions: string | ISceneLoaderPluginExtensions;
  42327. /**
  42328. * Import meshes into a scene.
  42329. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42330. * @param scene The scene to import into
  42331. * @param data The data to import
  42332. * @param rootUrl The root url for scene and resources
  42333. * @param onProgress The callback when the load progresses
  42334. * @param fileName Defines the name of the file to load
  42335. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42336. */
  42337. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42338. meshes: AbstractMesh[];
  42339. particleSystems: IParticleSystem[];
  42340. skeletons: Skeleton[];
  42341. animationGroups: AnimationGroup[];
  42342. }>;
  42343. /**
  42344. * Load into a scene.
  42345. * @param scene The scene to load into
  42346. * @param data The data to import
  42347. * @param rootUrl The root url for scene and resources
  42348. * @param onProgress The callback when the load progresses
  42349. * @param fileName Defines the name of the file to load
  42350. * @returns Nothing
  42351. */
  42352. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42353. /**
  42354. * The callback that returns true if the data can be directly loaded.
  42355. */
  42356. canDirectLoad?: (data: string) => boolean;
  42357. /**
  42358. * The callback that allows custom handling of the root url based on the response url.
  42359. */
  42360. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42361. /**
  42362. * Load into an asset container.
  42363. * @param scene The scene to load into
  42364. * @param data The data to import
  42365. * @param rootUrl The root url for scene and resources
  42366. * @param onProgress The callback when the load progresses
  42367. * @param fileName Defines the name of the file to load
  42368. * @returns The loaded asset container
  42369. */
  42370. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42371. }
  42372. /**
  42373. * Class used to load scene from various file formats using registered plugins
  42374. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42375. */
  42376. export class SceneLoader {
  42377. /**
  42378. * No logging while loading
  42379. */
  42380. static readonly NO_LOGGING: number;
  42381. /**
  42382. * Minimal logging while loading
  42383. */
  42384. static readonly MINIMAL_LOGGING: number;
  42385. /**
  42386. * Summary logging while loading
  42387. */
  42388. static readonly SUMMARY_LOGGING: number;
  42389. /**
  42390. * Detailled logging while loading
  42391. */
  42392. static readonly DETAILED_LOGGING: number;
  42393. /**
  42394. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42395. */
  42396. static ForceFullSceneLoadingForIncremental: boolean;
  42397. /**
  42398. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42399. */
  42400. static ShowLoadingScreen: boolean;
  42401. /**
  42402. * Defines the current logging level (while loading the scene)
  42403. * @ignorenaming
  42404. */
  42405. static loggingLevel: number;
  42406. /**
  42407. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42408. */
  42409. static CleanBoneMatrixWeights: boolean;
  42410. /**
  42411. * Event raised when a plugin is used to load a scene
  42412. */
  42413. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42414. private static _registeredPlugins;
  42415. private static _getDefaultPlugin;
  42416. private static _getPluginForExtension;
  42417. private static _getPluginForDirectLoad;
  42418. private static _getPluginForFilename;
  42419. private static _getDirectLoad;
  42420. private static _loadData;
  42421. private static _getFileInfo;
  42422. /**
  42423. * Gets a plugin that can load the given extension
  42424. * @param extension defines the extension to load
  42425. * @returns a plugin or null if none works
  42426. */
  42427. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42428. /**
  42429. * Gets a boolean indicating that the given extension can be loaded
  42430. * @param extension defines the extension to load
  42431. * @returns true if the extension is supported
  42432. */
  42433. static IsPluginForExtensionAvailable(extension: string): boolean;
  42434. /**
  42435. * Adds a new plugin to the list of registered plugins
  42436. * @param plugin defines the plugin to add
  42437. */
  42438. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42439. /**
  42440. * Import meshes into a scene
  42441. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42442. * @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)
  42443. * @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)
  42444. * @param scene the instance of BABYLON.Scene to append to
  42445. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42446. * @param onProgress a callback with a progress event for each file being loaded
  42447. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42448. * @param pluginExtension the extension used to determine the plugin
  42449. * @returns The loaded plugin
  42450. */
  42451. 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>;
  42452. /**
  42453. * Import meshes into a scene
  42454. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42455. * @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)
  42456. * @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)
  42457. * @param scene the instance of BABYLON.Scene to append to
  42458. * @param onProgress a callback with a progress event for each file being loaded
  42459. * @param pluginExtension the extension used to determine the plugin
  42460. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42461. */
  42462. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42463. meshes: AbstractMesh[];
  42464. particleSystems: IParticleSystem[];
  42465. skeletons: Skeleton[];
  42466. animationGroups: AnimationGroup[];
  42467. }>;
  42468. /**
  42469. * Load a scene
  42470. * @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)
  42471. * @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)
  42472. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42473. * @param onSuccess a callback with the scene when import succeeds
  42474. * @param onProgress a callback with a progress event for each file being loaded
  42475. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42476. * @param pluginExtension the extension used to determine the plugin
  42477. * @returns The loaded plugin
  42478. */
  42479. 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>;
  42480. /**
  42481. * Load a scene
  42482. * @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)
  42483. * @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)
  42484. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42485. * @param onProgress a callback with a progress event for each file being loaded
  42486. * @param pluginExtension the extension used to determine the plugin
  42487. * @returns The loaded scene
  42488. */
  42489. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42490. /**
  42491. * Append a scene
  42492. * @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)
  42493. * @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)
  42494. * @param scene is the instance of BABYLON.Scene to append to
  42495. * @param onSuccess a callback with the scene when import succeeds
  42496. * @param onProgress a callback with a progress event for each file being loaded
  42497. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42498. * @param pluginExtension the extension used to determine the plugin
  42499. * @returns The loaded plugin
  42500. */
  42501. 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>;
  42502. /**
  42503. * Append a scene
  42504. * @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)
  42505. * @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)
  42506. * @param scene is the instance of BABYLON.Scene to append to
  42507. * @param onProgress a callback with a progress event for each file being loaded
  42508. * @param pluginExtension the extension used to determine the plugin
  42509. * @returns The given scene
  42510. */
  42511. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42512. /**
  42513. * Load a scene into an asset container
  42514. * @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)
  42515. * @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)
  42516. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42517. * @param onSuccess a callback with the scene when import succeeds
  42518. * @param onProgress a callback with a progress event for each file being loaded
  42519. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42520. * @param pluginExtension the extension used to determine the plugin
  42521. * @returns The loaded plugin
  42522. */
  42523. 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>;
  42524. /**
  42525. * Load a scene into an asset container
  42526. * @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)
  42527. * @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)
  42528. * @param scene is the instance of Scene to append to
  42529. * @param onProgress a callback with a progress event for each file being loaded
  42530. * @param pluginExtension the extension used to determine the plugin
  42531. * @returns The loaded asset container
  42532. */
  42533. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42534. }
  42535. }
  42536. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42537. import { Scene } from "babylonjs/scene";
  42538. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42539. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42540. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42541. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42542. /**
  42543. * Google Daydream controller
  42544. */
  42545. export class DaydreamController extends WebVRController {
  42546. /**
  42547. * Base Url for the controller model.
  42548. */
  42549. static MODEL_BASE_URL: string;
  42550. /**
  42551. * File name for the controller model.
  42552. */
  42553. static MODEL_FILENAME: string;
  42554. /**
  42555. * Gamepad Id prefix used to identify Daydream Controller.
  42556. */
  42557. static readonly GAMEPAD_ID_PREFIX: string;
  42558. /**
  42559. * Creates a new DaydreamController from a gamepad
  42560. * @param vrGamepad the gamepad that the controller should be created from
  42561. */
  42562. constructor(vrGamepad: any);
  42563. /**
  42564. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42565. * @param scene scene in which to add meshes
  42566. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42567. */
  42568. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42569. /**
  42570. * Called once for each button that changed state since the last frame
  42571. * @param buttonIdx Which button index changed
  42572. * @param state New state of the button
  42573. * @param changes Which properties on the state changed since last frame
  42574. */
  42575. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42576. }
  42577. }
  42578. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42579. import { Scene } from "babylonjs/scene";
  42580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42581. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42582. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42583. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42584. /**
  42585. * Gear VR Controller
  42586. */
  42587. export class GearVRController extends WebVRController {
  42588. /**
  42589. * Base Url for the controller model.
  42590. */
  42591. static MODEL_BASE_URL: string;
  42592. /**
  42593. * File name for the controller model.
  42594. */
  42595. static MODEL_FILENAME: string;
  42596. /**
  42597. * Gamepad Id prefix used to identify this controller.
  42598. */
  42599. static readonly GAMEPAD_ID_PREFIX: string;
  42600. private readonly _buttonIndexToObservableNameMap;
  42601. /**
  42602. * Creates a new GearVRController from a gamepad
  42603. * @param vrGamepad the gamepad that the controller should be created from
  42604. */
  42605. constructor(vrGamepad: any);
  42606. /**
  42607. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42608. * @param scene scene in which to add meshes
  42609. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42610. */
  42611. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42612. /**
  42613. * Called once for each button that changed state since the last frame
  42614. * @param buttonIdx Which button index changed
  42615. * @param state New state of the button
  42616. * @param changes Which properties on the state changed since last frame
  42617. */
  42618. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42619. }
  42620. }
  42621. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42622. import { Scene } from "babylonjs/scene";
  42623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42624. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42625. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42626. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42627. /**
  42628. * Generic Controller
  42629. */
  42630. export class GenericController extends WebVRController {
  42631. /**
  42632. * Base Url for the controller model.
  42633. */
  42634. static readonly MODEL_BASE_URL: string;
  42635. /**
  42636. * File name for the controller model.
  42637. */
  42638. static readonly MODEL_FILENAME: string;
  42639. /**
  42640. * Creates a new GenericController from a gamepad
  42641. * @param vrGamepad the gamepad that the controller should be created from
  42642. */
  42643. constructor(vrGamepad: any);
  42644. /**
  42645. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42646. * @param scene scene in which to add meshes
  42647. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42648. */
  42649. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42650. /**
  42651. * Called once for each button that changed state since the last frame
  42652. * @param buttonIdx Which button index changed
  42653. * @param state New state of the button
  42654. * @param changes Which properties on the state changed since last frame
  42655. */
  42656. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42657. }
  42658. }
  42659. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42660. import { Observable } from "babylonjs/Misc/observable";
  42661. import { Scene } from "babylonjs/scene";
  42662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42663. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42664. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42665. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42666. /**
  42667. * Oculus Touch Controller
  42668. */
  42669. export class OculusTouchController extends WebVRController {
  42670. /**
  42671. * Base Url for the controller model.
  42672. */
  42673. static MODEL_BASE_URL: string;
  42674. /**
  42675. * File name for the left controller model.
  42676. */
  42677. static MODEL_LEFT_FILENAME: string;
  42678. /**
  42679. * File name for the right controller model.
  42680. */
  42681. static MODEL_RIGHT_FILENAME: string;
  42682. /**
  42683. * Fired when the secondary trigger on this controller is modified
  42684. */
  42685. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42686. /**
  42687. * Fired when the thumb rest on this controller is modified
  42688. */
  42689. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42690. /**
  42691. * Creates a new OculusTouchController from a gamepad
  42692. * @param vrGamepad the gamepad that the controller should be created from
  42693. */
  42694. constructor(vrGamepad: any);
  42695. /**
  42696. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42697. * @param scene scene in which to add meshes
  42698. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42699. */
  42700. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42701. /**
  42702. * Fired when the A button on this controller is modified
  42703. */
  42704. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42705. /**
  42706. * Fired when the B button on this controller is modified
  42707. */
  42708. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42709. /**
  42710. * Fired when the X button on this controller is modified
  42711. */
  42712. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42713. /**
  42714. * Fired when the Y button on this controller is modified
  42715. */
  42716. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42717. /**
  42718. * Called once for each button that changed state since the last frame
  42719. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42720. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42721. * 2) secondary trigger (same)
  42722. * 3) A (right) X (left), touch, pressed = value
  42723. * 4) B / Y
  42724. * 5) thumb rest
  42725. * @param buttonIdx Which button index changed
  42726. * @param state New state of the button
  42727. * @param changes Which properties on the state changed since last frame
  42728. */
  42729. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42730. }
  42731. }
  42732. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42733. import { Scene } from "babylonjs/scene";
  42734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42735. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42736. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42737. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42738. import { Observable } from "babylonjs/Misc/observable";
  42739. /**
  42740. * Vive Controller
  42741. */
  42742. export class ViveController extends WebVRController {
  42743. /**
  42744. * Base Url for the controller model.
  42745. */
  42746. static MODEL_BASE_URL: string;
  42747. /**
  42748. * File name for the controller model.
  42749. */
  42750. static MODEL_FILENAME: string;
  42751. /**
  42752. * Creates a new ViveController from a gamepad
  42753. * @param vrGamepad the gamepad that the controller should be created from
  42754. */
  42755. constructor(vrGamepad: any);
  42756. /**
  42757. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42758. * @param scene scene in which to add meshes
  42759. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42760. */
  42761. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42762. /**
  42763. * Fired when the left button on this controller is modified
  42764. */
  42765. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42766. /**
  42767. * Fired when the right button on this controller is modified
  42768. */
  42769. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42770. /**
  42771. * Fired when the menu button on this controller is modified
  42772. */
  42773. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42774. /**
  42775. * Called once for each button that changed state since the last frame
  42776. * Vive mapping:
  42777. * 0: touchpad
  42778. * 1: trigger
  42779. * 2: left AND right buttons
  42780. * 3: menu button
  42781. * @param buttonIdx Which button index changed
  42782. * @param state New state of the button
  42783. * @param changes Which properties on the state changed since last frame
  42784. */
  42785. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42786. }
  42787. }
  42788. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42789. import { Observable } from "babylonjs/Misc/observable";
  42790. import { Scene } from "babylonjs/scene";
  42791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42792. import { Ray } from "babylonjs/Culling/ray";
  42793. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42794. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42795. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42796. /**
  42797. * Defines the WindowsMotionController object that the state of the windows motion controller
  42798. */
  42799. export class WindowsMotionController extends WebVRController {
  42800. /**
  42801. * The base url used to load the left and right controller models
  42802. */
  42803. static MODEL_BASE_URL: string;
  42804. /**
  42805. * The name of the left controller model file
  42806. */
  42807. static MODEL_LEFT_FILENAME: string;
  42808. /**
  42809. * The name of the right controller model file
  42810. */
  42811. static MODEL_RIGHT_FILENAME: string;
  42812. /**
  42813. * The controller name prefix for this controller type
  42814. */
  42815. static readonly GAMEPAD_ID_PREFIX: string;
  42816. /**
  42817. * The controller id pattern for this controller type
  42818. */
  42819. private static readonly GAMEPAD_ID_PATTERN;
  42820. private _loadedMeshInfo;
  42821. private readonly _mapping;
  42822. /**
  42823. * Fired when the trackpad on this controller is clicked
  42824. */
  42825. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42826. /**
  42827. * Fired when the trackpad on this controller is modified
  42828. */
  42829. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42830. /**
  42831. * The current x and y values of this controller's trackpad
  42832. */
  42833. trackpad: StickValues;
  42834. /**
  42835. * Creates a new WindowsMotionController from a gamepad
  42836. * @param vrGamepad the gamepad that the controller should be created from
  42837. */
  42838. constructor(vrGamepad: any);
  42839. /**
  42840. * Fired when the trigger on this controller is modified
  42841. */
  42842. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42843. /**
  42844. * Fired when the menu button on this controller is modified
  42845. */
  42846. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42847. /**
  42848. * Fired when the grip button on this controller is modified
  42849. */
  42850. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42851. /**
  42852. * Fired when the thumbstick button on this controller is modified
  42853. */
  42854. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42855. /**
  42856. * Fired when the touchpad button on this controller is modified
  42857. */
  42858. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42859. /**
  42860. * Fired when the touchpad values on this controller are modified
  42861. */
  42862. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42863. private _updateTrackpad;
  42864. /**
  42865. * Called once per frame by the engine.
  42866. */
  42867. update(): void;
  42868. /**
  42869. * Called once for each button that changed state since the last frame
  42870. * @param buttonIdx Which button index changed
  42871. * @param state New state of the button
  42872. * @param changes Which properties on the state changed since last frame
  42873. */
  42874. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42875. /**
  42876. * Moves the buttons on the controller mesh based on their current state
  42877. * @param buttonName the name of the button to move
  42878. * @param buttonValue the value of the button which determines the buttons new position
  42879. */
  42880. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42881. /**
  42882. * Moves the axis on the controller mesh based on its current state
  42883. * @param axis the index of the axis
  42884. * @param axisValue the value of the axis which determines the meshes new position
  42885. * @hidden
  42886. */
  42887. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42888. /**
  42889. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42890. * @param scene scene in which to add meshes
  42891. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42892. */
  42893. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42894. /**
  42895. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42896. * can be transformed by button presses and axes values, based on this._mapping.
  42897. *
  42898. * @param scene scene in which the meshes exist
  42899. * @param meshes list of meshes that make up the controller model to process
  42900. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42901. */
  42902. private processModel;
  42903. private createMeshInfo;
  42904. /**
  42905. * Gets the ray of the controller in the direction the controller is pointing
  42906. * @param length the length the resulting ray should be
  42907. * @returns a ray in the direction the controller is pointing
  42908. */
  42909. getForwardRay(length?: number): Ray;
  42910. /**
  42911. * Disposes of the controller
  42912. */
  42913. dispose(): void;
  42914. }
  42915. }
  42916. declare module "babylonjs/Gamepads/Controllers/index" {
  42917. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  42918. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  42919. export * from "babylonjs/Gamepads/Controllers/genericController";
  42920. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  42921. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42922. export * from "babylonjs/Gamepads/Controllers/viveController";
  42923. export * from "babylonjs/Gamepads/Controllers/webVRController";
  42924. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  42925. }
  42926. declare module "babylonjs/Gamepads/index" {
  42927. export * from "babylonjs/Gamepads/Controllers/index";
  42928. export * from "babylonjs/Gamepads/gamepad";
  42929. export * from "babylonjs/Gamepads/gamepadManager";
  42930. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  42931. export * from "babylonjs/Gamepads/xboxGamepad";
  42932. }
  42933. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  42934. import { Observable } from "babylonjs/Misc/observable";
  42935. import { Nullable } from "babylonjs/types";
  42936. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42938. import { Mesh } from "babylonjs/Meshes/mesh";
  42939. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42940. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42941. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42942. /**
  42943. * Single axis scale gizmo
  42944. */
  42945. export class AxisScaleGizmo extends Gizmo {
  42946. private _coloredMaterial;
  42947. /**
  42948. * Drag behavior responsible for the gizmos dragging interactions
  42949. */
  42950. dragBehavior: PointerDragBehavior;
  42951. private _pointerObserver;
  42952. /**
  42953. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42954. */
  42955. snapDistance: number;
  42956. /**
  42957. * Event that fires each time the gizmo snaps to a new location.
  42958. * * snapDistance is the the change in distance
  42959. */
  42960. onSnapObservable: Observable<{
  42961. snapDistance: number;
  42962. }>;
  42963. /**
  42964. * If the scaling operation should be done on all axis (default: false)
  42965. */
  42966. uniformScaling: boolean;
  42967. /**
  42968. * Creates an AxisScaleGizmo
  42969. * @param gizmoLayer The utility layer the gizmo will be added to
  42970. * @param dragAxis The axis which the gizmo will be able to scale on
  42971. * @param color The color of the gizmo
  42972. */
  42973. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42974. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42975. /**
  42976. * Disposes of the gizmo
  42977. */
  42978. dispose(): void;
  42979. /**
  42980. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42981. * @param mesh The mesh to replace the default mesh of the gizmo
  42982. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42983. */
  42984. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42985. }
  42986. }
  42987. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  42988. import { Observable } from "babylonjs/Misc/observable";
  42989. import { Nullable } from "babylonjs/types";
  42990. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42992. import { Mesh } from "babylonjs/Meshes/mesh";
  42993. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42994. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42995. import "babylonjs/Meshes/Builders/boxBuilder";
  42996. /**
  42997. * Bounding box gizmo
  42998. */
  42999. export class BoundingBoxGizmo extends Gizmo {
  43000. private _lineBoundingBox;
  43001. private _rotateSpheresParent;
  43002. private _scaleBoxesParent;
  43003. private _boundingDimensions;
  43004. private _renderObserver;
  43005. private _pointerObserver;
  43006. private _scaleDragSpeed;
  43007. private _tmpQuaternion;
  43008. private _tmpVector;
  43009. private _tmpRotationMatrix;
  43010. /**
  43011. * 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)
  43012. */
  43013. ignoreChildren: boolean;
  43014. /**
  43015. * 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)
  43016. */
  43017. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43018. /**
  43019. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43020. */
  43021. rotationSphereSize: number;
  43022. /**
  43023. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43024. */
  43025. scaleBoxSize: number;
  43026. /**
  43027. * 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)
  43028. */
  43029. fixedDragMeshScreenSize: boolean;
  43030. /**
  43031. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43032. */
  43033. fixedDragMeshScreenSizeDistanceFactor: number;
  43034. /**
  43035. * Fired when a rotation sphere or scale box is dragged
  43036. */
  43037. onDragStartObservable: Observable<{}>;
  43038. /**
  43039. * Fired when a scale box is dragged
  43040. */
  43041. onScaleBoxDragObservable: Observable<{}>;
  43042. /**
  43043. * Fired when a scale box drag is ended
  43044. */
  43045. onScaleBoxDragEndObservable: Observable<{}>;
  43046. /**
  43047. * Fired when a rotation sphere is dragged
  43048. */
  43049. onRotationSphereDragObservable: Observable<{}>;
  43050. /**
  43051. * Fired when a rotation sphere drag is ended
  43052. */
  43053. onRotationSphereDragEndObservable: Observable<{}>;
  43054. /**
  43055. * 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)
  43056. */
  43057. scalePivot: Nullable<Vector3>;
  43058. private _anchorMesh;
  43059. private _existingMeshScale;
  43060. private _dragMesh;
  43061. private pointerDragBehavior;
  43062. private coloredMaterial;
  43063. private hoverColoredMaterial;
  43064. /**
  43065. * Sets the color of the bounding box gizmo
  43066. * @param color the color to set
  43067. */
  43068. setColor(color: Color3): void;
  43069. /**
  43070. * Creates an BoundingBoxGizmo
  43071. * @param gizmoLayer The utility layer the gizmo will be added to
  43072. * @param color The color of the gizmo
  43073. */
  43074. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43075. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43076. private _selectNode;
  43077. /**
  43078. * Updates the bounding box information for the Gizmo
  43079. */
  43080. updateBoundingBox(): void;
  43081. private _updateRotationSpheres;
  43082. private _updateScaleBoxes;
  43083. /**
  43084. * Enables rotation on the specified axis and disables rotation on the others
  43085. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43086. */
  43087. setEnabledRotationAxis(axis: string): void;
  43088. /**
  43089. * Enables/disables scaling
  43090. * @param enable if scaling should be enabled
  43091. */
  43092. setEnabledScaling(enable: boolean): void;
  43093. private _updateDummy;
  43094. /**
  43095. * Enables a pointer drag behavior on the bounding box of the gizmo
  43096. */
  43097. enableDragBehavior(): void;
  43098. /**
  43099. * Disposes of the gizmo
  43100. */
  43101. dispose(): void;
  43102. /**
  43103. * 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)
  43104. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43105. * @returns the bounding box mesh with the passed in mesh as a child
  43106. */
  43107. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43108. /**
  43109. * CustomMeshes are not supported by this gizmo
  43110. * @param mesh The mesh to replace the default mesh of the gizmo
  43111. */
  43112. setCustomMesh(mesh: Mesh): void;
  43113. }
  43114. }
  43115. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43116. import { Observable } from "babylonjs/Misc/observable";
  43117. import { Nullable } from "babylonjs/types";
  43118. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43120. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43121. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43122. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43123. import "babylonjs/Meshes/Builders/linesBuilder";
  43124. /**
  43125. * Single plane rotation gizmo
  43126. */
  43127. export class PlaneRotationGizmo extends Gizmo {
  43128. /**
  43129. * Drag behavior responsible for the gizmos dragging interactions
  43130. */
  43131. dragBehavior: PointerDragBehavior;
  43132. private _pointerObserver;
  43133. /**
  43134. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43135. */
  43136. snapDistance: number;
  43137. /**
  43138. * Event that fires each time the gizmo snaps to a new location.
  43139. * * snapDistance is the the change in distance
  43140. */
  43141. onSnapObservable: Observable<{
  43142. snapDistance: number;
  43143. }>;
  43144. /**
  43145. * Creates a PlaneRotationGizmo
  43146. * @param gizmoLayer The utility layer the gizmo will be added to
  43147. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43148. * @param color The color of the gizmo
  43149. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43150. */
  43151. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43152. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43153. /**
  43154. * Disposes of the gizmo
  43155. */
  43156. dispose(): void;
  43157. }
  43158. }
  43159. declare module "babylonjs/Gizmos/rotationGizmo" {
  43160. import { Observable } from "babylonjs/Misc/observable";
  43161. import { Nullable } from "babylonjs/types";
  43162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43163. import { Mesh } from "babylonjs/Meshes/mesh";
  43164. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43165. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43166. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43167. /**
  43168. * Gizmo that enables rotating a mesh along 3 axis
  43169. */
  43170. export class RotationGizmo extends Gizmo {
  43171. /**
  43172. * Internal gizmo used for interactions on the x axis
  43173. */
  43174. xGizmo: PlaneRotationGizmo;
  43175. /**
  43176. * Internal gizmo used for interactions on the y axis
  43177. */
  43178. yGizmo: PlaneRotationGizmo;
  43179. /**
  43180. * Internal gizmo used for interactions on the z axis
  43181. */
  43182. zGizmo: PlaneRotationGizmo;
  43183. /** Fires an event when any of it's sub gizmos are dragged */
  43184. onDragStartObservable: Observable<{}>;
  43185. /** Fires an event when any of it's sub gizmos are released from dragging */
  43186. onDragEndObservable: Observable<{}>;
  43187. attachedMesh: Nullable<AbstractMesh>;
  43188. /**
  43189. * Creates a RotationGizmo
  43190. * @param gizmoLayer The utility layer the gizmo will be added to
  43191. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43192. */
  43193. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43194. updateGizmoRotationToMatchAttachedMesh: boolean;
  43195. /**
  43196. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43197. */
  43198. snapDistance: number;
  43199. /**
  43200. * Ratio for the scale of the gizmo (Default: 1)
  43201. */
  43202. scaleRatio: number;
  43203. /**
  43204. * Disposes of the gizmo
  43205. */
  43206. dispose(): void;
  43207. /**
  43208. * CustomMeshes are not supported by this gizmo
  43209. * @param mesh The mesh to replace the default mesh of the gizmo
  43210. */
  43211. setCustomMesh(mesh: Mesh): void;
  43212. }
  43213. }
  43214. declare module "babylonjs/Gizmos/positionGizmo" {
  43215. import { Observable } from "babylonjs/Misc/observable";
  43216. import { Nullable } from "babylonjs/types";
  43217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43218. import { Mesh } from "babylonjs/Meshes/mesh";
  43219. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43220. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43221. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43222. /**
  43223. * Gizmo that enables dragging a mesh along 3 axis
  43224. */
  43225. export class PositionGizmo extends Gizmo {
  43226. /**
  43227. * Internal gizmo used for interactions on the x axis
  43228. */
  43229. xGizmo: AxisDragGizmo;
  43230. /**
  43231. * Internal gizmo used for interactions on the y axis
  43232. */
  43233. yGizmo: AxisDragGizmo;
  43234. /**
  43235. * Internal gizmo used for interactions on the z axis
  43236. */
  43237. zGizmo: AxisDragGizmo;
  43238. /** Fires an event when any of it's sub gizmos are dragged */
  43239. onDragStartObservable: Observable<{}>;
  43240. /** Fires an event when any of it's sub gizmos are released from dragging */
  43241. onDragEndObservable: Observable<{}>;
  43242. attachedMesh: Nullable<AbstractMesh>;
  43243. /**
  43244. * Creates a PositionGizmo
  43245. * @param gizmoLayer The utility layer the gizmo will be added to
  43246. */
  43247. constructor(gizmoLayer?: UtilityLayerRenderer);
  43248. updateGizmoRotationToMatchAttachedMesh: boolean;
  43249. /**
  43250. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43251. */
  43252. snapDistance: number;
  43253. /**
  43254. * Ratio for the scale of the gizmo (Default: 1)
  43255. */
  43256. scaleRatio: number;
  43257. /**
  43258. * Disposes of the gizmo
  43259. */
  43260. dispose(): void;
  43261. /**
  43262. * CustomMeshes are not supported by this gizmo
  43263. * @param mesh The mesh to replace the default mesh of the gizmo
  43264. */
  43265. setCustomMesh(mesh: Mesh): void;
  43266. }
  43267. }
  43268. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43269. import { Scene } from "babylonjs/scene";
  43270. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43271. import { Mesh } from "babylonjs/Meshes/mesh";
  43272. /**
  43273. * Class containing static functions to help procedurally build meshes
  43274. */
  43275. export class PolyhedronBuilder {
  43276. /**
  43277. * Creates a polyhedron mesh
  43278. * * 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
  43279. * * The parameter `size` (positive float, default 1) sets the polygon size
  43280. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43281. * * 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`
  43282. * * 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
  43283. * * 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)`)
  43284. * * 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
  43285. * * 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
  43286. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43287. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43289. * @param name defines the name of the mesh
  43290. * @param options defines the options used to create the mesh
  43291. * @param scene defines the hosting scene
  43292. * @returns the polyhedron mesh
  43293. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43294. */
  43295. static CreatePolyhedron(name: string, options: {
  43296. type?: number;
  43297. size?: number;
  43298. sizeX?: number;
  43299. sizeY?: number;
  43300. sizeZ?: number;
  43301. custom?: any;
  43302. faceUV?: Vector4[];
  43303. faceColors?: Color4[];
  43304. flat?: boolean;
  43305. updatable?: boolean;
  43306. sideOrientation?: number;
  43307. frontUVs?: Vector4;
  43308. backUVs?: Vector4;
  43309. }, scene: Scene): Mesh;
  43310. }
  43311. }
  43312. declare module "babylonjs/Gizmos/scaleGizmo" {
  43313. import { Observable } from "babylonjs/Misc/observable";
  43314. import { Nullable } from "babylonjs/types";
  43315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43316. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43317. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43318. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43319. /**
  43320. * Gizmo that enables scaling a mesh along 3 axis
  43321. */
  43322. export class ScaleGizmo extends Gizmo {
  43323. /**
  43324. * Internal gizmo used for interactions on the x axis
  43325. */
  43326. xGizmo: AxisScaleGizmo;
  43327. /**
  43328. * Internal gizmo used for interactions on the y axis
  43329. */
  43330. yGizmo: AxisScaleGizmo;
  43331. /**
  43332. * Internal gizmo used for interactions on the z axis
  43333. */
  43334. zGizmo: AxisScaleGizmo;
  43335. /**
  43336. * Internal gizmo used to scale all axis equally
  43337. */
  43338. uniformScaleGizmo: AxisScaleGizmo;
  43339. /** Fires an event when any of it's sub gizmos are dragged */
  43340. onDragStartObservable: Observable<{}>;
  43341. /** Fires an event when any of it's sub gizmos are released from dragging */
  43342. onDragEndObservable: Observable<{}>;
  43343. attachedMesh: Nullable<AbstractMesh>;
  43344. /**
  43345. * Creates a ScaleGizmo
  43346. * @param gizmoLayer The utility layer the gizmo will be added to
  43347. */
  43348. constructor(gizmoLayer?: UtilityLayerRenderer);
  43349. updateGizmoRotationToMatchAttachedMesh: boolean;
  43350. /**
  43351. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43352. */
  43353. snapDistance: number;
  43354. /**
  43355. * Ratio for the scale of the gizmo (Default: 1)
  43356. */
  43357. scaleRatio: number;
  43358. /**
  43359. * Disposes of the gizmo
  43360. */
  43361. dispose(): void;
  43362. }
  43363. }
  43364. declare module "babylonjs/Gizmos/gizmoManager" {
  43365. import { Observable } from "babylonjs/Misc/observable";
  43366. import { Nullable } from "babylonjs/types";
  43367. import { Scene, IDisposable } from "babylonjs/scene";
  43368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43369. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43370. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43371. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43372. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43373. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43374. /**
  43375. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43376. */
  43377. export class GizmoManager implements IDisposable {
  43378. private scene;
  43379. /**
  43380. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43381. */
  43382. gizmos: {
  43383. positionGizmo: Nullable<PositionGizmo>;
  43384. rotationGizmo: Nullable<RotationGizmo>;
  43385. scaleGizmo: Nullable<ScaleGizmo>;
  43386. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43387. };
  43388. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43389. clearGizmoOnEmptyPointerEvent: boolean;
  43390. /** Fires an event when the manager is attached to a mesh */
  43391. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43392. private _gizmosEnabled;
  43393. private _pointerObserver;
  43394. private _attachedMesh;
  43395. private _boundingBoxColor;
  43396. private _defaultUtilityLayer;
  43397. private _defaultKeepDepthUtilityLayer;
  43398. /**
  43399. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43400. */
  43401. boundingBoxDragBehavior: SixDofDragBehavior;
  43402. /**
  43403. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43404. */
  43405. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43406. /**
  43407. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43408. */
  43409. usePointerToAttachGizmos: boolean;
  43410. /**
  43411. * Instatiates a gizmo manager
  43412. * @param scene the scene to overlay the gizmos on top of
  43413. */
  43414. constructor(scene: Scene);
  43415. /**
  43416. * Attaches a set of gizmos to the specified mesh
  43417. * @param mesh The mesh the gizmo's should be attached to
  43418. */
  43419. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43420. /**
  43421. * If the position gizmo is enabled
  43422. */
  43423. positionGizmoEnabled: boolean;
  43424. /**
  43425. * If the rotation gizmo is enabled
  43426. */
  43427. rotationGizmoEnabled: boolean;
  43428. /**
  43429. * If the scale gizmo is enabled
  43430. */
  43431. scaleGizmoEnabled: boolean;
  43432. /**
  43433. * If the boundingBox gizmo is enabled
  43434. */
  43435. boundingBoxGizmoEnabled: boolean;
  43436. /**
  43437. * Disposes of the gizmo manager
  43438. */
  43439. dispose(): void;
  43440. }
  43441. }
  43442. declare module "babylonjs/Gizmos/lightGizmo" {
  43443. import { Nullable } from "babylonjs/types";
  43444. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43445. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43446. import { Light } from "babylonjs/Lights/light";
  43447. /**
  43448. * Gizmo that enables viewing a light
  43449. */
  43450. export class LightGizmo extends Gizmo {
  43451. private _box;
  43452. /**
  43453. * Creates a LightGizmo
  43454. * @param gizmoLayer The utility layer the gizmo will be added to
  43455. */
  43456. constructor(gizmoLayer?: UtilityLayerRenderer);
  43457. private _light;
  43458. /**
  43459. * The light that the gizmo is attached to
  43460. */
  43461. light: Nullable<Light>;
  43462. /**
  43463. * @hidden
  43464. * Updates the gizmo to match the attached mesh's position/rotation
  43465. */
  43466. protected _update(): void;
  43467. }
  43468. }
  43469. declare module "babylonjs/Gizmos/index" {
  43470. export * from "babylonjs/Gizmos/axisDragGizmo";
  43471. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43472. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43473. export * from "babylonjs/Gizmos/gizmo";
  43474. export * from "babylonjs/Gizmos/gizmoManager";
  43475. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43476. export * from "babylonjs/Gizmos/positionGizmo";
  43477. export * from "babylonjs/Gizmos/rotationGizmo";
  43478. export * from "babylonjs/Gizmos/scaleGizmo";
  43479. export * from "babylonjs/Gizmos/lightGizmo";
  43480. }
  43481. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43482. /** @hidden */
  43483. export var backgroundFragmentDeclaration: {
  43484. name: string;
  43485. shader: string;
  43486. };
  43487. }
  43488. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43489. /** @hidden */
  43490. export var backgroundUboDeclaration: {
  43491. name: string;
  43492. shader: string;
  43493. };
  43494. }
  43495. declare module "babylonjs/Shaders/background.fragment" {
  43496. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43497. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43498. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43499. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43500. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43501. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43502. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43503. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43504. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43505. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43506. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43507. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43508. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43509. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43510. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43511. /** @hidden */
  43512. export var backgroundPixelShader: {
  43513. name: string;
  43514. shader: string;
  43515. };
  43516. }
  43517. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43518. /** @hidden */
  43519. export var backgroundVertexDeclaration: {
  43520. name: string;
  43521. shader: string;
  43522. };
  43523. }
  43524. declare module "babylonjs/Shaders/background.vertex" {
  43525. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43526. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43527. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43528. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43529. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43530. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43531. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43532. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43533. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43534. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43535. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43536. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43537. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43538. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43539. /** @hidden */
  43540. export var backgroundVertexShader: {
  43541. name: string;
  43542. shader: string;
  43543. };
  43544. }
  43545. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43546. import { Nullable, int, float } from "babylonjs/types";
  43547. import { Scene } from "babylonjs/scene";
  43548. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43549. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43551. import { Mesh } from "babylonjs/Meshes/mesh";
  43552. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43553. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43554. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43555. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43556. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43557. import "babylonjs/Shaders/background.fragment";
  43558. import "babylonjs/Shaders/background.vertex";
  43559. /**
  43560. * Background material used to create an efficient environement around your scene.
  43561. */
  43562. export class BackgroundMaterial extends PushMaterial {
  43563. /**
  43564. * Standard reflectance value at parallel view angle.
  43565. */
  43566. static StandardReflectance0: number;
  43567. /**
  43568. * Standard reflectance value at grazing angle.
  43569. */
  43570. static StandardReflectance90: number;
  43571. protected _primaryColor: Color3;
  43572. /**
  43573. * Key light Color (multiply against the environement texture)
  43574. */
  43575. primaryColor: Color3;
  43576. protected __perceptualColor: Nullable<Color3>;
  43577. /**
  43578. * Experimental Internal Use Only.
  43579. *
  43580. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43581. * This acts as a helper to set the primary color to a more "human friendly" value.
  43582. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43583. * output color as close as possible from the chosen value.
  43584. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43585. * part of lighting setup.)
  43586. */
  43587. _perceptualColor: Nullable<Color3>;
  43588. protected _primaryColorShadowLevel: float;
  43589. /**
  43590. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43591. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43592. */
  43593. primaryColorShadowLevel: float;
  43594. protected _primaryColorHighlightLevel: float;
  43595. /**
  43596. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43597. * The primary color is used at the level chosen to define what the white area would look.
  43598. */
  43599. primaryColorHighlightLevel: float;
  43600. protected _reflectionTexture: Nullable<BaseTexture>;
  43601. /**
  43602. * Reflection Texture used in the material.
  43603. * Should be author in a specific way for the best result (refer to the documentation).
  43604. */
  43605. reflectionTexture: Nullable<BaseTexture>;
  43606. protected _reflectionBlur: float;
  43607. /**
  43608. * Reflection Texture level of blur.
  43609. *
  43610. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43611. * texture twice.
  43612. */
  43613. reflectionBlur: float;
  43614. protected _diffuseTexture: Nullable<BaseTexture>;
  43615. /**
  43616. * Diffuse Texture used in the material.
  43617. * Should be author in a specific way for the best result (refer to the documentation).
  43618. */
  43619. diffuseTexture: Nullable<BaseTexture>;
  43620. protected _shadowLights: Nullable<IShadowLight[]>;
  43621. /**
  43622. * Specify the list of lights casting shadow on the material.
  43623. * All scene shadow lights will be included if null.
  43624. */
  43625. shadowLights: Nullable<IShadowLight[]>;
  43626. protected _shadowLevel: float;
  43627. /**
  43628. * Helps adjusting the shadow to a softer level if required.
  43629. * 0 means black shadows and 1 means no shadows.
  43630. */
  43631. shadowLevel: float;
  43632. protected _sceneCenter: Vector3;
  43633. /**
  43634. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43635. * It is usually zero but might be interesting to modify according to your setup.
  43636. */
  43637. sceneCenter: Vector3;
  43638. protected _opacityFresnel: boolean;
  43639. /**
  43640. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43641. * This helps ensuring a nice transition when the camera goes under the ground.
  43642. */
  43643. opacityFresnel: boolean;
  43644. protected _reflectionFresnel: boolean;
  43645. /**
  43646. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43647. * This helps adding a mirror texture on the ground.
  43648. */
  43649. reflectionFresnel: boolean;
  43650. protected _reflectionFalloffDistance: number;
  43651. /**
  43652. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43653. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43654. */
  43655. reflectionFalloffDistance: number;
  43656. protected _reflectionAmount: number;
  43657. /**
  43658. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43659. */
  43660. reflectionAmount: number;
  43661. protected _reflectionReflectance0: number;
  43662. /**
  43663. * This specifies the weight of the reflection at grazing angle.
  43664. */
  43665. reflectionReflectance0: number;
  43666. protected _reflectionReflectance90: number;
  43667. /**
  43668. * This specifies the weight of the reflection at a perpendicular point of view.
  43669. */
  43670. reflectionReflectance90: number;
  43671. /**
  43672. * Sets the reflection reflectance fresnel values according to the default standard
  43673. * empirically know to work well :-)
  43674. */
  43675. reflectionStandardFresnelWeight: number;
  43676. protected _useRGBColor: boolean;
  43677. /**
  43678. * Helps to directly use the maps channels instead of their level.
  43679. */
  43680. useRGBColor: boolean;
  43681. protected _enableNoise: boolean;
  43682. /**
  43683. * This helps reducing the banding effect that could occur on the background.
  43684. */
  43685. enableNoise: boolean;
  43686. /**
  43687. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43688. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43689. * Recommended to be keep at 1.0 except for special cases.
  43690. */
  43691. fovMultiplier: number;
  43692. private _fovMultiplier;
  43693. /**
  43694. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43695. */
  43696. useEquirectangularFOV: boolean;
  43697. private _maxSimultaneousLights;
  43698. /**
  43699. * Number of Simultaneous lights allowed on the material.
  43700. */
  43701. maxSimultaneousLights: int;
  43702. /**
  43703. * Default configuration related to image processing available in the Background Material.
  43704. */
  43705. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43706. /**
  43707. * Keep track of the image processing observer to allow dispose and replace.
  43708. */
  43709. private _imageProcessingObserver;
  43710. /**
  43711. * Attaches a new image processing configuration to the PBR Material.
  43712. * @param configuration (if null the scene configuration will be use)
  43713. */
  43714. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43715. /**
  43716. * Gets the image processing configuration used either in this material.
  43717. */
  43718. /**
  43719. * Sets the Default image processing configuration used either in the this material.
  43720. *
  43721. * If sets to null, the scene one is in use.
  43722. */
  43723. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43724. /**
  43725. * Gets wether the color curves effect is enabled.
  43726. */
  43727. /**
  43728. * Sets wether the color curves effect is enabled.
  43729. */
  43730. cameraColorCurvesEnabled: boolean;
  43731. /**
  43732. * Gets wether the color grading effect is enabled.
  43733. */
  43734. /**
  43735. * Gets wether the color grading effect is enabled.
  43736. */
  43737. cameraColorGradingEnabled: boolean;
  43738. /**
  43739. * Gets wether tonemapping is enabled or not.
  43740. */
  43741. /**
  43742. * Sets wether tonemapping is enabled or not
  43743. */
  43744. cameraToneMappingEnabled: boolean;
  43745. /**
  43746. * The camera exposure used on this material.
  43747. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43748. * This corresponds to a photographic exposure.
  43749. */
  43750. /**
  43751. * The camera exposure used on this material.
  43752. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43753. * This corresponds to a photographic exposure.
  43754. */
  43755. cameraExposure: float;
  43756. /**
  43757. * Gets The camera contrast used on this material.
  43758. */
  43759. /**
  43760. * Sets The camera contrast used on this material.
  43761. */
  43762. cameraContrast: float;
  43763. /**
  43764. * Gets the Color Grading 2D Lookup Texture.
  43765. */
  43766. /**
  43767. * Sets the Color Grading 2D Lookup Texture.
  43768. */
  43769. cameraColorGradingTexture: Nullable<BaseTexture>;
  43770. /**
  43771. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43772. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43773. * 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;
  43774. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43775. */
  43776. /**
  43777. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43778. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43779. * 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;
  43780. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43781. */
  43782. cameraColorCurves: Nullable<ColorCurves>;
  43783. /**
  43784. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43785. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43786. */
  43787. switchToBGR: boolean;
  43788. private _renderTargets;
  43789. private _reflectionControls;
  43790. private _white;
  43791. private _primaryShadowColor;
  43792. private _primaryHighlightColor;
  43793. /**
  43794. * Instantiates a Background Material in the given scene
  43795. * @param name The friendly name of the material
  43796. * @param scene The scene to add the material to
  43797. */
  43798. constructor(name: string, scene: Scene);
  43799. /**
  43800. * Gets a boolean indicating that current material needs to register RTT
  43801. */
  43802. readonly hasRenderTargetTextures: boolean;
  43803. /**
  43804. * The entire material has been created in order to prevent overdraw.
  43805. * @returns false
  43806. */
  43807. needAlphaTesting(): boolean;
  43808. /**
  43809. * The entire material has been created in order to prevent overdraw.
  43810. * @returns true if blending is enable
  43811. */
  43812. needAlphaBlending(): boolean;
  43813. /**
  43814. * Checks wether the material is ready to be rendered for a given mesh.
  43815. * @param mesh The mesh to render
  43816. * @param subMesh The submesh to check against
  43817. * @param useInstances Specify wether or not the material is used with instances
  43818. * @returns true if all the dependencies are ready (Textures, Effects...)
  43819. */
  43820. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43821. /**
  43822. * Compute the primary color according to the chosen perceptual color.
  43823. */
  43824. private _computePrimaryColorFromPerceptualColor;
  43825. /**
  43826. * Compute the highlights and shadow colors according to their chosen levels.
  43827. */
  43828. private _computePrimaryColors;
  43829. /**
  43830. * Build the uniform buffer used in the material.
  43831. */
  43832. buildUniformLayout(): void;
  43833. /**
  43834. * Unbind the material.
  43835. */
  43836. unbind(): void;
  43837. /**
  43838. * Bind only the world matrix to the material.
  43839. * @param world The world matrix to bind.
  43840. */
  43841. bindOnlyWorldMatrix(world: Matrix): void;
  43842. /**
  43843. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43844. * @param world The world matrix to bind.
  43845. * @param subMesh The submesh to bind for.
  43846. */
  43847. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43848. /**
  43849. * Dispose the material.
  43850. * @param forceDisposeEffect Force disposal of the associated effect.
  43851. * @param forceDisposeTextures Force disposal of the associated textures.
  43852. */
  43853. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43854. /**
  43855. * Clones the material.
  43856. * @param name The cloned name.
  43857. * @returns The cloned material.
  43858. */
  43859. clone(name: string): BackgroundMaterial;
  43860. /**
  43861. * Serializes the current material to its JSON representation.
  43862. * @returns The JSON representation.
  43863. */
  43864. serialize(): any;
  43865. /**
  43866. * Gets the class name of the material
  43867. * @returns "BackgroundMaterial"
  43868. */
  43869. getClassName(): string;
  43870. /**
  43871. * Parse a JSON input to create back a background material.
  43872. * @param source The JSON data to parse
  43873. * @param scene The scene to create the parsed material in
  43874. * @param rootUrl The root url of the assets the material depends upon
  43875. * @returns the instantiated BackgroundMaterial.
  43876. */
  43877. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43878. }
  43879. }
  43880. declare module "babylonjs/Helpers/environmentHelper" {
  43881. import { Observable } from "babylonjs/Misc/observable";
  43882. import { Nullable } from "babylonjs/types";
  43883. import { Scene } from "babylonjs/scene";
  43884. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43886. import { Mesh } from "babylonjs/Meshes/mesh";
  43887. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43888. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43889. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43890. import "babylonjs/Meshes/Builders/planeBuilder";
  43891. import "babylonjs/Meshes/Builders/boxBuilder";
  43892. /**
  43893. * Represents the different options available during the creation of
  43894. * a Environment helper.
  43895. *
  43896. * This can control the default ground, skybox and image processing setup of your scene.
  43897. */
  43898. export interface IEnvironmentHelperOptions {
  43899. /**
  43900. * Specifies wether or not to create a ground.
  43901. * True by default.
  43902. */
  43903. createGround: boolean;
  43904. /**
  43905. * Specifies the ground size.
  43906. * 15 by default.
  43907. */
  43908. groundSize: number;
  43909. /**
  43910. * The texture used on the ground for the main color.
  43911. * Comes from the BabylonJS CDN by default.
  43912. *
  43913. * Remarks: Can be either a texture or a url.
  43914. */
  43915. groundTexture: string | BaseTexture;
  43916. /**
  43917. * The color mixed in the ground texture by default.
  43918. * BabylonJS clearColor by default.
  43919. */
  43920. groundColor: Color3;
  43921. /**
  43922. * Specifies the ground opacity.
  43923. * 1 by default.
  43924. */
  43925. groundOpacity: number;
  43926. /**
  43927. * Enables the ground to receive shadows.
  43928. * True by default.
  43929. */
  43930. enableGroundShadow: boolean;
  43931. /**
  43932. * Helps preventing the shadow to be fully black on the ground.
  43933. * 0.5 by default.
  43934. */
  43935. groundShadowLevel: number;
  43936. /**
  43937. * Creates a mirror texture attach to the ground.
  43938. * false by default.
  43939. */
  43940. enableGroundMirror: boolean;
  43941. /**
  43942. * Specifies the ground mirror size ratio.
  43943. * 0.3 by default as the default kernel is 64.
  43944. */
  43945. groundMirrorSizeRatio: number;
  43946. /**
  43947. * Specifies the ground mirror blur kernel size.
  43948. * 64 by default.
  43949. */
  43950. groundMirrorBlurKernel: number;
  43951. /**
  43952. * Specifies the ground mirror visibility amount.
  43953. * 1 by default
  43954. */
  43955. groundMirrorAmount: number;
  43956. /**
  43957. * Specifies the ground mirror reflectance weight.
  43958. * This uses the standard weight of the background material to setup the fresnel effect
  43959. * of the mirror.
  43960. * 1 by default.
  43961. */
  43962. groundMirrorFresnelWeight: number;
  43963. /**
  43964. * Specifies the ground mirror Falloff distance.
  43965. * This can helps reducing the size of the reflection.
  43966. * 0 by Default.
  43967. */
  43968. groundMirrorFallOffDistance: number;
  43969. /**
  43970. * Specifies the ground mirror texture type.
  43971. * Unsigned Int by Default.
  43972. */
  43973. groundMirrorTextureType: number;
  43974. /**
  43975. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43976. * the shown objects.
  43977. */
  43978. groundYBias: number;
  43979. /**
  43980. * Specifies wether or not to create a skybox.
  43981. * True by default.
  43982. */
  43983. createSkybox: boolean;
  43984. /**
  43985. * Specifies the skybox size.
  43986. * 20 by default.
  43987. */
  43988. skyboxSize: number;
  43989. /**
  43990. * The texture used on the skybox for the main color.
  43991. * Comes from the BabylonJS CDN by default.
  43992. *
  43993. * Remarks: Can be either a texture or a url.
  43994. */
  43995. skyboxTexture: string | BaseTexture;
  43996. /**
  43997. * The color mixed in the skybox texture by default.
  43998. * BabylonJS clearColor by default.
  43999. */
  44000. skyboxColor: Color3;
  44001. /**
  44002. * The background rotation around the Y axis of the scene.
  44003. * This helps aligning the key lights of your scene with the background.
  44004. * 0 by default.
  44005. */
  44006. backgroundYRotation: number;
  44007. /**
  44008. * Compute automatically the size of the elements to best fit with the scene.
  44009. */
  44010. sizeAuto: boolean;
  44011. /**
  44012. * Default position of the rootMesh if autoSize is not true.
  44013. */
  44014. rootPosition: Vector3;
  44015. /**
  44016. * Sets up the image processing in the scene.
  44017. * true by default.
  44018. */
  44019. setupImageProcessing: boolean;
  44020. /**
  44021. * The texture used as your environment texture in the scene.
  44022. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44023. *
  44024. * Remarks: Can be either a texture or a url.
  44025. */
  44026. environmentTexture: string | BaseTexture;
  44027. /**
  44028. * The value of the exposure to apply to the scene.
  44029. * 0.6 by default if setupImageProcessing is true.
  44030. */
  44031. cameraExposure: number;
  44032. /**
  44033. * The value of the contrast to apply to the scene.
  44034. * 1.6 by default if setupImageProcessing is true.
  44035. */
  44036. cameraContrast: number;
  44037. /**
  44038. * Specifies wether or not tonemapping should be enabled in the scene.
  44039. * true by default if setupImageProcessing is true.
  44040. */
  44041. toneMappingEnabled: boolean;
  44042. }
  44043. /**
  44044. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44045. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44046. * It also helps with the default setup of your imageProcessing configuration.
  44047. */
  44048. export class EnvironmentHelper {
  44049. /**
  44050. * Default ground texture URL.
  44051. */
  44052. private static _groundTextureCDNUrl;
  44053. /**
  44054. * Default skybox texture URL.
  44055. */
  44056. private static _skyboxTextureCDNUrl;
  44057. /**
  44058. * Default environment texture URL.
  44059. */
  44060. private static _environmentTextureCDNUrl;
  44061. /**
  44062. * Creates the default options for the helper.
  44063. */
  44064. private static _getDefaultOptions;
  44065. private _rootMesh;
  44066. /**
  44067. * Gets the root mesh created by the helper.
  44068. */
  44069. readonly rootMesh: Mesh;
  44070. private _skybox;
  44071. /**
  44072. * Gets the skybox created by the helper.
  44073. */
  44074. readonly skybox: Nullable<Mesh>;
  44075. private _skyboxTexture;
  44076. /**
  44077. * Gets the skybox texture created by the helper.
  44078. */
  44079. readonly skyboxTexture: Nullable<BaseTexture>;
  44080. private _skyboxMaterial;
  44081. /**
  44082. * Gets the skybox material created by the helper.
  44083. */
  44084. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44085. private _ground;
  44086. /**
  44087. * Gets the ground mesh created by the helper.
  44088. */
  44089. readonly ground: Nullable<Mesh>;
  44090. private _groundTexture;
  44091. /**
  44092. * Gets the ground texture created by the helper.
  44093. */
  44094. readonly groundTexture: Nullable<BaseTexture>;
  44095. private _groundMirror;
  44096. /**
  44097. * Gets the ground mirror created by the helper.
  44098. */
  44099. readonly groundMirror: Nullable<MirrorTexture>;
  44100. /**
  44101. * Gets the ground mirror render list to helps pushing the meshes
  44102. * you wish in the ground reflection.
  44103. */
  44104. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44105. private _groundMaterial;
  44106. /**
  44107. * Gets the ground material created by the helper.
  44108. */
  44109. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44110. /**
  44111. * Stores the creation options.
  44112. */
  44113. private readonly _scene;
  44114. private _options;
  44115. /**
  44116. * This observable will be notified with any error during the creation of the environment,
  44117. * mainly texture creation errors.
  44118. */
  44119. onErrorObservable: Observable<{
  44120. message?: string;
  44121. exception?: any;
  44122. }>;
  44123. /**
  44124. * constructor
  44125. * @param options Defines the options we want to customize the helper
  44126. * @param scene The scene to add the material to
  44127. */
  44128. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44129. /**
  44130. * Updates the background according to the new options
  44131. * @param options
  44132. */
  44133. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44134. /**
  44135. * Sets the primary color of all the available elements.
  44136. * @param color the main color to affect to the ground and the background
  44137. */
  44138. setMainColor(color: Color3): void;
  44139. /**
  44140. * Setup the image processing according to the specified options.
  44141. */
  44142. private _setupImageProcessing;
  44143. /**
  44144. * Setup the environment texture according to the specified options.
  44145. */
  44146. private _setupEnvironmentTexture;
  44147. /**
  44148. * Setup the background according to the specified options.
  44149. */
  44150. private _setupBackground;
  44151. /**
  44152. * Get the scene sizes according to the setup.
  44153. */
  44154. private _getSceneSize;
  44155. /**
  44156. * Setup the ground according to the specified options.
  44157. */
  44158. private _setupGround;
  44159. /**
  44160. * Setup the ground material according to the specified options.
  44161. */
  44162. private _setupGroundMaterial;
  44163. /**
  44164. * Setup the ground diffuse texture according to the specified options.
  44165. */
  44166. private _setupGroundDiffuseTexture;
  44167. /**
  44168. * Setup the ground mirror texture according to the specified options.
  44169. */
  44170. private _setupGroundMirrorTexture;
  44171. /**
  44172. * Setup the ground to receive the mirror texture.
  44173. */
  44174. private _setupMirrorInGroundMaterial;
  44175. /**
  44176. * Setup the skybox according to the specified options.
  44177. */
  44178. private _setupSkybox;
  44179. /**
  44180. * Setup the skybox material according to the specified options.
  44181. */
  44182. private _setupSkyboxMaterial;
  44183. /**
  44184. * Setup the skybox reflection texture according to the specified options.
  44185. */
  44186. private _setupSkyboxReflectionTexture;
  44187. private _errorHandler;
  44188. /**
  44189. * Dispose all the elements created by the Helper.
  44190. */
  44191. dispose(): void;
  44192. }
  44193. }
  44194. declare module "babylonjs/Helpers/photoDome" {
  44195. import { Observable } from "babylonjs/Misc/observable";
  44196. import { Nullable } from "babylonjs/types";
  44197. import { Scene } from "babylonjs/scene";
  44198. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44199. import { Mesh } from "babylonjs/Meshes/mesh";
  44200. import { Texture } from "babylonjs/Materials/Textures/texture";
  44201. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44202. import "babylonjs/Meshes/Builders/sphereBuilder";
  44203. /**
  44204. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44205. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44206. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44207. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44208. */
  44209. export class PhotoDome extends TransformNode {
  44210. private _useDirectMapping;
  44211. /**
  44212. * The texture being displayed on the sphere
  44213. */
  44214. protected _photoTexture: Texture;
  44215. /**
  44216. * Gets or sets the texture being displayed on the sphere
  44217. */
  44218. photoTexture: Texture;
  44219. /**
  44220. * Observable raised when an error occured while loading the 360 image
  44221. */
  44222. onLoadErrorObservable: Observable<string>;
  44223. /**
  44224. * The skybox material
  44225. */
  44226. protected _material: BackgroundMaterial;
  44227. /**
  44228. * The surface used for the skybox
  44229. */
  44230. protected _mesh: Mesh;
  44231. /**
  44232. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44233. * Also see the options.resolution property.
  44234. */
  44235. fovMultiplier: number;
  44236. /**
  44237. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44238. * @param name Element's name, child elements will append suffixes for their own names.
  44239. * @param urlsOfPhoto defines the url of the photo to display
  44240. * @param options defines an object containing optional or exposed sub element properties
  44241. * @param onError defines a callback called when an error occured while loading the texture
  44242. */
  44243. constructor(name: string, urlOfPhoto: string, options: {
  44244. resolution?: number;
  44245. size?: number;
  44246. useDirectMapping?: boolean;
  44247. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44248. /**
  44249. * Releases resources associated with this node.
  44250. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44251. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44252. */
  44253. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44254. }
  44255. }
  44256. declare module "babylonjs/Misc/textureTools" {
  44257. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44258. import { Texture } from "babylonjs/Materials/Textures/texture";
  44259. import { Scene } from "babylonjs/scene";
  44260. /**
  44261. * Class used to host texture specific utilities
  44262. */
  44263. export class TextureTools {
  44264. /**
  44265. * Uses the GPU to create a copy texture rescaled at a given size
  44266. * @param texture Texture to copy from
  44267. * @param width defines the desired width
  44268. * @param height defines the desired height
  44269. * @param useBilinearMode defines if bilinear mode has to be used
  44270. * @return the generated texture
  44271. */
  44272. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44273. /**
  44274. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44275. * @param scene defines the hosting scene
  44276. * @returns the environment BRDF texture
  44277. */
  44278. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44279. private static _environmentBRDFBase64Texture;
  44280. }
  44281. }
  44282. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  44283. import { Nullable } from "babylonjs/types";
  44284. import { IAnimatable } from "babylonjs/Misc/tools";
  44285. import { Color3 } from "babylonjs/Maths/math";
  44286. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44287. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44288. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44289. import { Engine } from "babylonjs/Engines/engine";
  44290. import { Scene } from "babylonjs/scene";
  44291. /**
  44292. * @hidden
  44293. */
  44294. export interface IMaterialClearCoatDefines {
  44295. CLEARCOAT: boolean;
  44296. CLEARCOAT_DEFAULTIOR: boolean;
  44297. CLEARCOAT_TEXTURE: boolean;
  44298. CLEARCOAT_TEXTUREDIRECTUV: number;
  44299. CLEARCOAT_BUMP: boolean;
  44300. CLEARCOAT_BUMPDIRECTUV: number;
  44301. CLEARCOAT_TINT: boolean;
  44302. CLEARCOAT_TINT_TEXTURE: boolean;
  44303. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44304. /** @hidden */
  44305. _areTexturesDirty: boolean;
  44306. }
  44307. /**
  44308. * Define the code related to the clear coat parameters of the pbr material.
  44309. */
  44310. export class PBRClearCoatConfiguration {
  44311. /**
  44312. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44313. * The default fits with a polyurethane material.
  44314. */
  44315. private static readonly _DefaultIndiceOfRefraction;
  44316. private _isEnabled;
  44317. /**
  44318. * Defines if the clear coat is enabled in the material.
  44319. */
  44320. isEnabled: boolean;
  44321. /**
  44322. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44323. */
  44324. intensity: number;
  44325. /**
  44326. * Defines the clear coat layer roughness.
  44327. */
  44328. roughness: number;
  44329. private _indiceOfRefraction;
  44330. /**
  44331. * Defines the indice of refraction of the clear coat.
  44332. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44333. * The default fits with a polyurethane material.
  44334. * Changing the default value is more performance intensive.
  44335. */
  44336. indiceOfRefraction: number;
  44337. private _texture;
  44338. /**
  44339. * Stores the clear coat values in a texture.
  44340. */
  44341. texture: Nullable<BaseTexture>;
  44342. private _bumpTexture;
  44343. /**
  44344. * Define the clear coat specific bump texture.
  44345. */
  44346. bumpTexture: Nullable<BaseTexture>;
  44347. private _isTintEnabled;
  44348. /**
  44349. * Defines if the clear coat tint is enabled in the material.
  44350. */
  44351. isTintEnabled: boolean;
  44352. /**
  44353. * Defines if the clear coat tint is enabled in the material.
  44354. * This is only use if tint is enabled
  44355. */
  44356. tintColor: Color3;
  44357. /**
  44358. * Defines if the distance at which the tint color should be found in the
  44359. * clear coat media.
  44360. * This is only use if tint is enabled
  44361. */
  44362. tintColorAtDistance: number;
  44363. /**
  44364. * Defines the clear coat layer thickness.
  44365. * This is only use if tint is enabled
  44366. */
  44367. tintThickness: number;
  44368. private _tintTexture;
  44369. /**
  44370. * Stores the clear tint values in a texture.
  44371. * rgb is tint
  44372. * a is a thickness factor
  44373. */
  44374. tintTexture: Nullable<BaseTexture>;
  44375. /** @hidden */
  44376. private _internalMarkAllSubMeshesAsTexturesDirty;
  44377. /** @hidden */
  44378. _markAllSubMeshesAsTexturesDirty(): void;
  44379. /**
  44380. * Instantiate a new istance of clear coat configuration.
  44381. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44382. */
  44383. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44384. /**
  44385. * Specifies that the submesh is ready to be used.
  44386. * @param defines the list of "defines" to update.
  44387. * @param scene defines the scene the material belongs to.
  44388. * @param engine defines the engine the material belongs to.
  44389. * @param disableBumpMap defines wether the material disables bump or not.
  44390. * @returns - boolean indicating that the submesh is ready or not.
  44391. */
  44392. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44393. /**
  44394. * Checks to see if a texture is used in the material.
  44395. * @param defines the list of "defines" to update.
  44396. * @param scene defines the scene to the material belongs to.
  44397. */
  44398. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44399. /**
  44400. * Binds the material data.
  44401. * @param uniformBuffer defines the Uniform buffer to fill in.
  44402. * @param scene defines the scene the material belongs to.
  44403. * @param engine defines the engine the material belongs to.
  44404. * @param disableBumpMap defines wether the material disables bump or not.
  44405. * @param isFrozen defines wether the material is frozen or not.
  44406. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44407. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44408. */
  44409. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44410. /**
  44411. * Checks to see if a texture is used in the material.
  44412. * @param texture - Base texture to use.
  44413. * @returns - Boolean specifying if a texture is used in the material.
  44414. */
  44415. hasTexture(texture: BaseTexture): boolean;
  44416. /**
  44417. * Returns an array of the actively used textures.
  44418. * @param activeTextures Array of BaseTextures
  44419. */
  44420. getActiveTextures(activeTextures: BaseTexture[]): void;
  44421. /**
  44422. * Returns the animatable textures.
  44423. * @param animatables Array of animatable textures.
  44424. */
  44425. getAnimatables(animatables: IAnimatable[]): void;
  44426. /**
  44427. * Disposes the resources of the material.
  44428. * @param forceDisposeTextures - Forces the disposal of all textures.
  44429. */
  44430. dispose(forceDisposeTextures?: boolean): void;
  44431. /**
  44432. * Get the current class name of the texture useful for serialization or dynamic coding.
  44433. * @returns "PBRClearCoatConfiguration"
  44434. */
  44435. getClassName(): string;
  44436. /**
  44437. * Add fallbacks to the effect fallbacks list.
  44438. * @param defines defines the Base texture to use.
  44439. * @param fallbacks defines the current fallback list.
  44440. * @param currentRank defines the current fallback rank.
  44441. * @returns the new fallback rank.
  44442. */
  44443. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44444. /**
  44445. * Add the required uniforms to the current list.
  44446. * @param uniforms defines the current uniform list.
  44447. */
  44448. static AddUniforms(uniforms: string[]): void;
  44449. /**
  44450. * Add the required samplers to the current list.
  44451. * @param samplers defines the current sampler list.
  44452. */
  44453. static AddSamplers(samplers: string[]): void;
  44454. /**
  44455. * Add the required uniforms to the current buffer.
  44456. * @param uniformBuffer defines the current uniform buffer.
  44457. */
  44458. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44459. /**
  44460. * Makes a duplicate of the current configuration into another one.
  44461. * @param clearCoatConfiguration define the config where to copy the info
  44462. */
  44463. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44464. /**
  44465. * Serializes this clear coat configuration.
  44466. * @returns - An object with the serialized config.
  44467. */
  44468. serialize(): any;
  44469. /**
  44470. * Parses a Clear Coat Configuration from a serialized object.
  44471. * @param source - Serialized object.
  44472. */
  44473. parse(source: any): void;
  44474. }
  44475. }
  44476. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  44477. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44478. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44479. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44480. import { Vector2 } from "babylonjs/Maths/math";
  44481. import { Scene } from "babylonjs/scene";
  44482. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44483. import { IAnimatable } from "babylonjs/Misc/tools";
  44484. import { Nullable } from "babylonjs/types";
  44485. /**
  44486. * @hidden
  44487. */
  44488. export interface IMaterialAnisotropicDefines {
  44489. ANISOTROPIC: boolean;
  44490. ANISOTROPIC_TEXTURE: boolean;
  44491. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44492. MAINUV1: boolean;
  44493. _areTexturesDirty: boolean;
  44494. _needUVs: boolean;
  44495. }
  44496. /**
  44497. * Define the code related to the anisotropic parameters of the pbr material.
  44498. */
  44499. export class PBRAnisotropicConfiguration {
  44500. private _isEnabled;
  44501. /**
  44502. * Defines if the anisotropy is enabled in the material.
  44503. */
  44504. isEnabled: boolean;
  44505. /**
  44506. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44507. */
  44508. intensity: number;
  44509. /**
  44510. * Defines if the effect is along the tangents, bitangents or in between.
  44511. * By default, the effect is "strectching" the highlights along the tangents.
  44512. */
  44513. direction: Vector2;
  44514. private _texture;
  44515. /**
  44516. * Stores the anisotropy values in a texture.
  44517. * rg is direction (like normal from -1 to 1)
  44518. * b is a intensity
  44519. */
  44520. texture: Nullable<BaseTexture>;
  44521. /** @hidden */
  44522. private _internalMarkAllSubMeshesAsTexturesDirty;
  44523. /** @hidden */
  44524. _markAllSubMeshesAsTexturesDirty(): void;
  44525. /**
  44526. * Instantiate a new istance of anisotropy configuration.
  44527. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44528. */
  44529. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44530. /**
  44531. * Specifies that the submesh is ready to be used.
  44532. * @param defines the list of "defines" to update.
  44533. * @param scene defines the scene the material belongs to.
  44534. * @returns - boolean indicating that the submesh is ready or not.
  44535. */
  44536. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44537. /**
  44538. * Checks to see if a texture is used in the material.
  44539. * @param defines the list of "defines" to update.
  44540. * @param mesh the mesh we are preparing the defines for.
  44541. * @param scene defines the scene the material belongs to.
  44542. */
  44543. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44544. /**
  44545. * Binds the material data.
  44546. * @param uniformBuffer defines the Uniform buffer to fill in.
  44547. * @param scene defines the scene the material belongs to.
  44548. * @param isFrozen defines wether the material is frozen or not.
  44549. */
  44550. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44551. /**
  44552. * Checks to see if a texture is used in the material.
  44553. * @param texture - Base texture to use.
  44554. * @returns - Boolean specifying if a texture is used in the material.
  44555. */
  44556. hasTexture(texture: BaseTexture): boolean;
  44557. /**
  44558. * Returns an array of the actively used textures.
  44559. * @param activeTextures Array of BaseTextures
  44560. */
  44561. getActiveTextures(activeTextures: BaseTexture[]): void;
  44562. /**
  44563. * Returns the animatable textures.
  44564. * @param animatables Array of animatable textures.
  44565. */
  44566. getAnimatables(animatables: IAnimatable[]): void;
  44567. /**
  44568. * Disposes the resources of the material.
  44569. * @param forceDisposeTextures - Forces the disposal of all textures.
  44570. */
  44571. dispose(forceDisposeTextures?: boolean): void;
  44572. /**
  44573. * Get the current class name of the texture useful for serialization or dynamic coding.
  44574. * @returns "PBRAnisotropicConfiguration"
  44575. */
  44576. getClassName(): string;
  44577. /**
  44578. * Add fallbacks to the effect fallbacks list.
  44579. * @param defines defines the Base texture to use.
  44580. * @param fallbacks defines the current fallback list.
  44581. * @param currentRank defines the current fallback rank.
  44582. * @returns the new fallback rank.
  44583. */
  44584. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44585. /**
  44586. * Add the required uniforms to the current list.
  44587. * @param uniforms defines the current uniform list.
  44588. */
  44589. static AddUniforms(uniforms: string[]): void;
  44590. /**
  44591. * Add the required uniforms to the current buffer.
  44592. * @param uniformBuffer defines the current uniform buffer.
  44593. */
  44594. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44595. /**
  44596. * Add the required samplers to the current list.
  44597. * @param samplers defines the current sampler list.
  44598. */
  44599. static AddSamplers(samplers: string[]): void;
  44600. /**
  44601. * Makes a duplicate of the current configuration into another one.
  44602. * @param anisotropicConfiguration define the config where to copy the info
  44603. */
  44604. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44605. /**
  44606. * Serializes this anisotropy configuration.
  44607. * @returns - An object with the serialized config.
  44608. */
  44609. serialize(): any;
  44610. /**
  44611. * Parses a anisotropy Configuration from a serialized object.
  44612. * @param source - Serialized object.
  44613. */
  44614. parse(source: any): void;
  44615. }
  44616. }
  44617. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  44618. /**
  44619. * @hidden
  44620. */
  44621. export interface IMaterialBRDFDefines {
  44622. BRDF_V_HEIGHT_CORRELATED: boolean;
  44623. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44624. /** @hidden */
  44625. _areMiscDirty: boolean;
  44626. }
  44627. /**
  44628. * Define the code related to the BRDF parameters of the pbr material.
  44629. */
  44630. export class PBRBRDFConfiguration {
  44631. private _useEnergyConservation;
  44632. /**
  44633. * Defines if the material uses energy conservation.
  44634. */
  44635. useEnergyConservation: boolean;
  44636. private _useSmithVisibilityHeightCorrelated;
  44637. /**
  44638. * LEGACY Mode set to false
  44639. * Defines if the material uses height smith correlated visibility term.
  44640. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44641. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44642. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44643. * Not relying on height correlated will also disable energy conservation.
  44644. */
  44645. useSmithVisibilityHeightCorrelated: boolean;
  44646. /** @hidden */
  44647. private _internalMarkAllSubMeshesAsMiscDirty;
  44648. /** @hidden */
  44649. _markAllSubMeshesAsMiscDirty(): void;
  44650. /**
  44651. * Instantiate a new istance of clear coat configuration.
  44652. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44653. */
  44654. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44655. /**
  44656. * Checks to see if a texture is used in the material.
  44657. * @param defines the list of "defines" to update.
  44658. */
  44659. prepareDefines(defines: IMaterialBRDFDefines): void;
  44660. /**
  44661. * Get the current class name of the texture useful for serialization or dynamic coding.
  44662. * @returns "PBRClearCoatConfiguration"
  44663. */
  44664. getClassName(): string;
  44665. /**
  44666. * Makes a duplicate of the current configuration into another one.
  44667. * @param brdfConfiguration define the config where to copy the info
  44668. */
  44669. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44670. /**
  44671. * Serializes this BRDF configuration.
  44672. * @returns - An object with the serialized config.
  44673. */
  44674. serialize(): any;
  44675. /**
  44676. * Parses a BRDF Configuration from a serialized object.
  44677. * @param source - Serialized object.
  44678. */
  44679. parse(source: any): void;
  44680. }
  44681. }
  44682. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  44683. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44684. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44685. import { Color3 } from "babylonjs/Maths/math";
  44686. import { Scene } from "babylonjs/scene";
  44687. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44688. import { IAnimatable } from "babylonjs/Misc/tools";
  44689. import { Nullable } from "babylonjs/types";
  44690. /**
  44691. * @hidden
  44692. */
  44693. export interface IMaterialSheenDefines {
  44694. SHEEN: boolean;
  44695. SHEEN_TEXTURE: boolean;
  44696. SHEEN_TEXTUREDIRECTUV: number;
  44697. SHEEN_LINKWITHALBEDO: boolean;
  44698. /** @hidden */
  44699. _areTexturesDirty: boolean;
  44700. }
  44701. /**
  44702. * Define the code related to the Sheen parameters of the pbr material.
  44703. */
  44704. export class PBRSheenConfiguration {
  44705. private _isEnabled;
  44706. /**
  44707. * Defines if the material uses sheen.
  44708. */
  44709. isEnabled: boolean;
  44710. private _linkSheenWithAlbedo;
  44711. /**
  44712. * Defines if the sheen is linked to the sheen color.
  44713. */
  44714. linkSheenWithAlbedo: boolean;
  44715. /**
  44716. * Defines the sheen intensity.
  44717. */
  44718. intensity: number;
  44719. /**
  44720. * Defines the sheen color.
  44721. */
  44722. color: Color3;
  44723. private _texture;
  44724. /**
  44725. * Stores the sheen tint values in a texture.
  44726. * rgb is tint
  44727. * a is a intensity
  44728. */
  44729. texture: Nullable<BaseTexture>;
  44730. /** @hidden */
  44731. private _internalMarkAllSubMeshesAsTexturesDirty;
  44732. /** @hidden */
  44733. _markAllSubMeshesAsTexturesDirty(): void;
  44734. /**
  44735. * Instantiate a new istance of clear coat configuration.
  44736. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44737. */
  44738. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44739. /**
  44740. * Specifies that the submesh is ready to be used.
  44741. * @param defines the list of "defines" to update.
  44742. * @param scene defines the scene the material belongs to.
  44743. * @returns - boolean indicating that the submesh is ready or not.
  44744. */
  44745. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44746. /**
  44747. * Checks to see if a texture is used in the material.
  44748. * @param defines the list of "defines" to update.
  44749. * @param scene defines the scene the material belongs to.
  44750. */
  44751. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44752. /**
  44753. * Binds the material data.
  44754. * @param uniformBuffer defines the Uniform buffer to fill in.
  44755. * @param scene defines the scene the material belongs to.
  44756. * @param isFrozen defines wether the material is frozen or not.
  44757. */
  44758. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44759. /**
  44760. * Checks to see if a texture is used in the material.
  44761. * @param texture - Base texture to use.
  44762. * @returns - Boolean specifying if a texture is used in the material.
  44763. */
  44764. hasTexture(texture: BaseTexture): boolean;
  44765. /**
  44766. * Returns an array of the actively used textures.
  44767. * @param activeTextures Array of BaseTextures
  44768. */
  44769. getActiveTextures(activeTextures: BaseTexture[]): void;
  44770. /**
  44771. * Returns the animatable textures.
  44772. * @param animatables Array of animatable textures.
  44773. */
  44774. getAnimatables(animatables: IAnimatable[]): void;
  44775. /**
  44776. * Disposes the resources of the material.
  44777. * @param forceDisposeTextures - Forces the disposal of all textures.
  44778. */
  44779. dispose(forceDisposeTextures?: boolean): void;
  44780. /**
  44781. * Get the current class name of the texture useful for serialization or dynamic coding.
  44782. * @returns "PBRSheenConfiguration"
  44783. */
  44784. getClassName(): string;
  44785. /**
  44786. * Add fallbacks to the effect fallbacks list.
  44787. * @param defines defines the Base texture to use.
  44788. * @param fallbacks defines the current fallback list.
  44789. * @param currentRank defines the current fallback rank.
  44790. * @returns the new fallback rank.
  44791. */
  44792. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44793. /**
  44794. * Add the required uniforms to the current list.
  44795. * @param uniforms defines the current uniform list.
  44796. */
  44797. static AddUniforms(uniforms: string[]): void;
  44798. /**
  44799. * Add the required uniforms to the current buffer.
  44800. * @param uniformBuffer defines the current uniform buffer.
  44801. */
  44802. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44803. /**
  44804. * Add the required samplers to the current list.
  44805. * @param samplers defines the current sampler list.
  44806. */
  44807. static AddSamplers(samplers: string[]): void;
  44808. /**
  44809. * Makes a duplicate of the current configuration into another one.
  44810. * @param sheenConfiguration define the config where to copy the info
  44811. */
  44812. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44813. /**
  44814. * Serializes this BRDF configuration.
  44815. * @returns - An object with the serialized config.
  44816. */
  44817. serialize(): any;
  44818. /**
  44819. * Parses a Sheen Configuration from a serialized object.
  44820. * @param source - Serialized object.
  44821. */
  44822. parse(source: any): void;
  44823. }
  44824. }
  44825. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  44826. /** @hidden */
  44827. export var pbrFragmentDeclaration: {
  44828. name: string;
  44829. shader: string;
  44830. };
  44831. }
  44832. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  44833. /** @hidden */
  44834. export var pbrUboDeclaration: {
  44835. name: string;
  44836. shader: string;
  44837. };
  44838. }
  44839. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  44840. /** @hidden */
  44841. export var pbrFunctions: {
  44842. name: string;
  44843. shader: string;
  44844. };
  44845. }
  44846. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  44847. /** @hidden */
  44848. export var harmonicsFunctions: {
  44849. name: string;
  44850. shader: string;
  44851. };
  44852. }
  44853. declare module "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions" {
  44854. /** @hidden */
  44855. export var pbrPreLightingFunctions: {
  44856. name: string;
  44857. shader: string;
  44858. };
  44859. }
  44860. declare module "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions" {
  44861. /** @hidden */
  44862. export var pbrFalloffLightingFunctions: {
  44863. name: string;
  44864. shader: string;
  44865. };
  44866. }
  44867. declare module "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions" {
  44868. /** @hidden */
  44869. export var pbrLightingFunctions: {
  44870. name: string;
  44871. shader: string;
  44872. };
  44873. }
  44874. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  44875. /** @hidden */
  44876. export var pbrDebug: {
  44877. name: string;
  44878. shader: string;
  44879. };
  44880. }
  44881. declare module "babylonjs/Shaders/pbr.fragment" {
  44882. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  44883. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44884. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44885. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44886. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44887. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44888. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44889. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44890. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44891. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  44892. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44893. import "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions";
  44894. import "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions";
  44895. import "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions";
  44896. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  44897. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44898. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44899. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44900. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44901. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  44902. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  44903. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44904. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  44905. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44906. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  44907. /** @hidden */
  44908. export var pbrPixelShader: {
  44909. name: string;
  44910. shader: string;
  44911. };
  44912. }
  44913. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  44914. /** @hidden */
  44915. export var pbrVertexDeclaration: {
  44916. name: string;
  44917. shader: string;
  44918. };
  44919. }
  44920. declare module "babylonjs/Shaders/pbr.vertex" {
  44921. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  44922. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44923. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44924. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44925. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44926. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44927. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  44928. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44929. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44930. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44931. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44932. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  44933. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  44934. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44935. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  44936. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44937. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44938. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  44939. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44940. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44941. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44942. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  44943. /** @hidden */
  44944. export var pbrVertexShader: {
  44945. name: string;
  44946. shader: string;
  44947. };
  44948. }
  44949. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  44950. import { IAnimatable } from "babylonjs/Misc/tools";
  44951. import { Nullable } from "babylonjs/types";
  44952. import { Scene } from "babylonjs/scene";
  44953. import { Matrix, Color3 } from "babylonjs/Maths/math";
  44954. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44956. import { Mesh } from "babylonjs/Meshes/mesh";
  44957. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  44958. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  44959. import { PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  44960. import { PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  44961. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44962. import { Material } from "babylonjs/Materials/material";
  44963. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44964. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44965. import "babylonjs/Shaders/pbr.fragment";
  44966. import "babylonjs/Shaders/pbr.vertex";
  44967. /**
  44968. * The Physically based material base class of BJS.
  44969. *
  44970. * This offers the main features of a standard PBR material.
  44971. * For more information, please refer to the documentation :
  44972. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44973. */
  44974. export abstract class PBRBaseMaterial extends PushMaterial {
  44975. /**
  44976. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44977. */
  44978. static readonly PBRMATERIAL_OPAQUE: number;
  44979. /**
  44980. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44981. */
  44982. static readonly PBRMATERIAL_ALPHATEST: number;
  44983. /**
  44984. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44985. */
  44986. static readonly PBRMATERIAL_ALPHABLEND: number;
  44987. /**
  44988. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44989. * They are also discarded below the alpha cutoff threshold to improve performances.
  44990. */
  44991. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44992. /**
  44993. * Defines the default value of how much AO map is occluding the analytical lights
  44994. * (point spot...).
  44995. */
  44996. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44997. /**
  44998. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44999. */
  45000. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45001. /**
  45002. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45003. * to enhance interoperability with other engines.
  45004. */
  45005. static readonly LIGHTFALLOFF_GLTF: number;
  45006. /**
  45007. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45008. * to enhance interoperability with other materials.
  45009. */
  45010. static readonly LIGHTFALLOFF_STANDARD: number;
  45011. /**
  45012. * Intensity of the direct lights e.g. the four lights available in your scene.
  45013. * This impacts both the direct diffuse and specular highlights.
  45014. */
  45015. protected _directIntensity: number;
  45016. /**
  45017. * Intensity of the emissive part of the material.
  45018. * This helps controlling the emissive effect without modifying the emissive color.
  45019. */
  45020. protected _emissiveIntensity: number;
  45021. /**
  45022. * Intensity of the environment e.g. how much the environment will light the object
  45023. * either through harmonics for rough material or through the refelction for shiny ones.
  45024. */
  45025. protected _environmentIntensity: number;
  45026. /**
  45027. * This is a special control allowing the reduction of the specular highlights coming from the
  45028. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45029. */
  45030. protected _specularIntensity: number;
  45031. /**
  45032. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45033. */
  45034. private _lightingInfos;
  45035. /**
  45036. * Debug Control allowing disabling the bump map on this material.
  45037. */
  45038. protected _disableBumpMap: boolean;
  45039. /**
  45040. * AKA Diffuse Texture in standard nomenclature.
  45041. */
  45042. protected _albedoTexture: BaseTexture;
  45043. /**
  45044. * AKA Occlusion Texture in other nomenclature.
  45045. */
  45046. protected _ambientTexture: BaseTexture;
  45047. /**
  45048. * AKA Occlusion Texture Intensity in other nomenclature.
  45049. */
  45050. protected _ambientTextureStrength: number;
  45051. /**
  45052. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45053. * 1 means it completely occludes it
  45054. * 0 mean it has no impact
  45055. */
  45056. protected _ambientTextureImpactOnAnalyticalLights: number;
  45057. /**
  45058. * Stores the alpha values in a texture.
  45059. */
  45060. protected _opacityTexture: BaseTexture;
  45061. /**
  45062. * Stores the reflection values in a texture.
  45063. */
  45064. protected _reflectionTexture: BaseTexture;
  45065. /**
  45066. * Stores the refraction values in a texture.
  45067. */
  45068. protected _refractionTexture: BaseTexture;
  45069. /**
  45070. * Stores the emissive values in a texture.
  45071. */
  45072. protected _emissiveTexture: BaseTexture;
  45073. /**
  45074. * AKA Specular texture in other nomenclature.
  45075. */
  45076. protected _reflectivityTexture: BaseTexture;
  45077. /**
  45078. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45079. */
  45080. protected _metallicTexture: BaseTexture;
  45081. /**
  45082. * Specifies the metallic scalar of the metallic/roughness workflow.
  45083. * Can also be used to scale the metalness values of the metallic texture.
  45084. */
  45085. protected _metallic: Nullable<number>;
  45086. /**
  45087. * Specifies the roughness scalar of the metallic/roughness workflow.
  45088. * Can also be used to scale the roughness values of the metallic texture.
  45089. */
  45090. protected _roughness: Nullable<number>;
  45091. /**
  45092. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45093. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45094. */
  45095. protected _microSurfaceTexture: BaseTexture;
  45096. /**
  45097. * Stores surface normal data used to displace a mesh in a texture.
  45098. */
  45099. protected _bumpTexture: BaseTexture;
  45100. /**
  45101. * Stores the pre-calculated light information of a mesh in a texture.
  45102. */
  45103. protected _lightmapTexture: BaseTexture;
  45104. /**
  45105. * The color of a material in ambient lighting.
  45106. */
  45107. protected _ambientColor: Color3;
  45108. /**
  45109. * AKA Diffuse Color in other nomenclature.
  45110. */
  45111. protected _albedoColor: Color3;
  45112. /**
  45113. * AKA Specular Color in other nomenclature.
  45114. */
  45115. protected _reflectivityColor: Color3;
  45116. /**
  45117. * The color applied when light is reflected from a material.
  45118. */
  45119. protected _reflectionColor: Color3;
  45120. /**
  45121. * The color applied when light is emitted from a material.
  45122. */
  45123. protected _emissiveColor: Color3;
  45124. /**
  45125. * AKA Glossiness in other nomenclature.
  45126. */
  45127. protected _microSurface: number;
  45128. /**
  45129. * source material index of refraction (IOR)' / 'destination material IOR.
  45130. */
  45131. protected _indexOfRefraction: number;
  45132. /**
  45133. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45134. */
  45135. protected _invertRefractionY: boolean;
  45136. /**
  45137. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45138. * Materials half opaque for instance using refraction could benefit from this control.
  45139. */
  45140. protected _linkRefractionWithTransparency: boolean;
  45141. /**
  45142. * Specifies that the material will use the light map as a show map.
  45143. */
  45144. protected _useLightmapAsShadowmap: boolean;
  45145. /**
  45146. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45147. * makes the reflect vector face the model (under horizon).
  45148. */
  45149. protected _useHorizonOcclusion: boolean;
  45150. /**
  45151. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45152. * too much the area relying on ambient texture to define their ambient occlusion.
  45153. */
  45154. protected _useRadianceOcclusion: boolean;
  45155. /**
  45156. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45157. */
  45158. protected _useAlphaFromAlbedoTexture: boolean;
  45159. /**
  45160. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45161. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45162. */
  45163. protected _useSpecularOverAlpha: boolean;
  45164. /**
  45165. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45166. */
  45167. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45168. /**
  45169. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45170. */
  45171. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45172. /**
  45173. * Specifies if the metallic texture contains the roughness information in its green channel.
  45174. */
  45175. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45176. /**
  45177. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45178. */
  45179. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45180. /**
  45181. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45182. */
  45183. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45184. /**
  45185. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45186. */
  45187. protected _useAmbientInGrayScale: boolean;
  45188. /**
  45189. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45190. * The material will try to infer what glossiness each pixel should be.
  45191. */
  45192. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45193. /**
  45194. * Defines the falloff type used in this material.
  45195. * It by default is Physical.
  45196. */
  45197. protected _lightFalloff: number;
  45198. /**
  45199. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45200. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45201. */
  45202. protected _useRadianceOverAlpha: boolean;
  45203. /**
  45204. * Allows using an object space normal map (instead of tangent space).
  45205. */
  45206. protected _useObjectSpaceNormalMap: boolean;
  45207. /**
  45208. * Allows using the bump map in parallax mode.
  45209. */
  45210. protected _useParallax: boolean;
  45211. /**
  45212. * Allows using the bump map in parallax occlusion mode.
  45213. */
  45214. protected _useParallaxOcclusion: boolean;
  45215. /**
  45216. * Controls the scale bias of the parallax mode.
  45217. */
  45218. protected _parallaxScaleBias: number;
  45219. /**
  45220. * If sets to true, disables all the lights affecting the material.
  45221. */
  45222. protected _disableLighting: boolean;
  45223. /**
  45224. * Number of Simultaneous lights allowed on the material.
  45225. */
  45226. protected _maxSimultaneousLights: number;
  45227. /**
  45228. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45229. */
  45230. protected _invertNormalMapX: boolean;
  45231. /**
  45232. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45233. */
  45234. protected _invertNormalMapY: boolean;
  45235. /**
  45236. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45237. */
  45238. protected _twoSidedLighting: boolean;
  45239. /**
  45240. * Defines the alpha limits in alpha test mode.
  45241. */
  45242. protected _alphaCutOff: number;
  45243. /**
  45244. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45245. */
  45246. protected _forceAlphaTest: boolean;
  45247. /**
  45248. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45249. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45250. */
  45251. protected _useAlphaFresnel: boolean;
  45252. /**
  45253. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45254. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45255. */
  45256. protected _useLinearAlphaFresnel: boolean;
  45257. /**
  45258. * The transparency mode of the material.
  45259. */
  45260. protected _transparencyMode: Nullable<number>;
  45261. /**
  45262. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45263. * from cos thetav and roughness:
  45264. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45265. */
  45266. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45267. /**
  45268. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45269. */
  45270. protected _forceIrradianceInFragment: boolean;
  45271. /**
  45272. * Force normal to face away from face.
  45273. */
  45274. protected _forceNormalForward: boolean;
  45275. /**
  45276. * Enables specular anti aliasing in the PBR shader.
  45277. * It will both interacts on the Geometry for analytical and IBL lighting.
  45278. * It also prefilter the roughness map based on the bump values.
  45279. */
  45280. protected _enableSpecularAntiAliasing: boolean;
  45281. /**
  45282. * Default configuration related to image processing available in the PBR Material.
  45283. */
  45284. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45285. /**
  45286. * Keep track of the image processing observer to allow dispose and replace.
  45287. */
  45288. private _imageProcessingObserver;
  45289. /**
  45290. * Attaches a new image processing configuration to the PBR Material.
  45291. * @param configuration
  45292. */
  45293. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45294. /**
  45295. * Stores the available render targets.
  45296. */
  45297. private _renderTargets;
  45298. /**
  45299. * Sets the global ambient color for the material used in lighting calculations.
  45300. */
  45301. private _globalAmbientColor;
  45302. /**
  45303. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45304. */
  45305. private _useLogarithmicDepth;
  45306. /**
  45307. * If set to true, no lighting calculations will be applied.
  45308. */
  45309. private _unlit;
  45310. private _debugMode;
  45311. /**
  45312. * @hidden
  45313. * This is reserved for the inspector.
  45314. * Defines the material debug mode.
  45315. * It helps seeing only some components of the material while troubleshooting.
  45316. */
  45317. debugMode: number;
  45318. /**
  45319. * @hidden
  45320. * This is reserved for the inspector.
  45321. * Specify from where on screen the debug mode should start.
  45322. * The value goes from -1 (full screen) to 1 (not visible)
  45323. * It helps with side by side comparison against the final render
  45324. * This defaults to -1
  45325. */
  45326. private debugLimit;
  45327. /**
  45328. * @hidden
  45329. * This is reserved for the inspector.
  45330. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45331. * You can use the factor to better multiply the final value.
  45332. */
  45333. private debugFactor;
  45334. /**
  45335. * Defines the clear coat layer parameters for the material.
  45336. */
  45337. readonly clearCoat: PBRClearCoatConfiguration;
  45338. /**
  45339. * Defines the anisotropic parameters for the material.
  45340. */
  45341. readonly anisotropy: PBRAnisotropicConfiguration;
  45342. /**
  45343. * Defines the BRDF parameters for the material.
  45344. */
  45345. readonly brdf: PBRBRDFConfiguration;
  45346. /**
  45347. * Defines the Sheen parameters for the material.
  45348. */
  45349. readonly sheen: PBRSheenConfiguration;
  45350. /**
  45351. * Instantiates a new PBRMaterial instance.
  45352. *
  45353. * @param name The material name
  45354. * @param scene The scene the material will be use in.
  45355. */
  45356. constructor(name: string, scene: Scene);
  45357. /**
  45358. * Gets a boolean indicating that current material needs to register RTT
  45359. */
  45360. readonly hasRenderTargetTextures: boolean;
  45361. /**
  45362. * Gets the name of the material class.
  45363. */
  45364. getClassName(): string;
  45365. /**
  45366. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45367. */
  45368. /**
  45369. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45370. */
  45371. useLogarithmicDepth: boolean;
  45372. /**
  45373. * Gets the current transparency mode.
  45374. */
  45375. /**
  45376. * Sets the transparency mode of the material.
  45377. *
  45378. * | Value | Type | Description |
  45379. * | ----- | ----------------------------------- | ----------- |
  45380. * | 0 | OPAQUE | |
  45381. * | 1 | ALPHATEST | |
  45382. * | 2 | ALPHABLEND | |
  45383. * | 3 | ALPHATESTANDBLEND | |
  45384. *
  45385. */
  45386. transparencyMode: Nullable<number>;
  45387. /**
  45388. * Returns true if alpha blending should be disabled.
  45389. */
  45390. private readonly _disableAlphaBlending;
  45391. /**
  45392. * Specifies whether or not this material should be rendered in alpha blend mode.
  45393. */
  45394. needAlphaBlending(): boolean;
  45395. /**
  45396. * Specifies if the mesh will require alpha blending.
  45397. * @param mesh - BJS mesh.
  45398. */
  45399. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45400. /**
  45401. * Specifies whether or not this material should be rendered in alpha test mode.
  45402. */
  45403. needAlphaTesting(): boolean;
  45404. /**
  45405. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45406. */
  45407. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45408. /**
  45409. * Gets the texture used for the alpha test.
  45410. */
  45411. getAlphaTestTexture(): BaseTexture;
  45412. /**
  45413. * Specifies that the submesh is ready to be used.
  45414. * @param mesh - BJS mesh.
  45415. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45416. * @param useInstances - Specifies that instances should be used.
  45417. * @returns - boolean indicating that the submesh is ready or not.
  45418. */
  45419. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45420. /**
  45421. * Specifies if the material uses metallic roughness workflow.
  45422. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45423. */
  45424. isMetallicWorkflow(): boolean;
  45425. private _prepareEffect;
  45426. private _prepareDefines;
  45427. /**
  45428. * Force shader compilation
  45429. */
  45430. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45431. clipPlane: boolean;
  45432. }>): void;
  45433. /**
  45434. * Initializes the uniform buffer layout for the shader.
  45435. */
  45436. buildUniformLayout(): void;
  45437. /**
  45438. * Unbinds the textures.
  45439. */
  45440. unbind(): void;
  45441. /**
  45442. * Binds the submesh data.
  45443. * @param world - The world matrix.
  45444. * @param mesh - The BJS mesh.
  45445. * @param subMesh - A submesh of the BJS mesh.
  45446. */
  45447. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45448. /**
  45449. * Returns the animatable textures.
  45450. * @returns - Array of animatable textures.
  45451. */
  45452. getAnimatables(): IAnimatable[];
  45453. /**
  45454. * Returns the texture used for reflections.
  45455. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45456. */
  45457. private _getReflectionTexture;
  45458. /**
  45459. * Returns the texture used for refraction or null if none is used.
  45460. * @returns - Refection texture if present. If no refraction texture and refraction
  45461. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45462. */
  45463. private _getRefractionTexture;
  45464. /**
  45465. * Returns an array of the actively used textures.
  45466. * @returns - Array of BaseTextures
  45467. */
  45468. getActiveTextures(): BaseTexture[];
  45469. /**
  45470. * Checks to see if a texture is used in the material.
  45471. * @param texture - Base texture to use.
  45472. * @returns - Boolean specifying if a texture is used in the material.
  45473. */
  45474. hasTexture(texture: BaseTexture): boolean;
  45475. /**
  45476. * Disposes the resources of the material.
  45477. * @param forceDisposeEffect - Forces the disposal of effects.
  45478. * @param forceDisposeTextures - Forces the disposal of all textures.
  45479. */
  45480. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45481. }
  45482. }
  45483. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  45484. import { Nullable } from "babylonjs/types";
  45485. import { Scene } from "babylonjs/scene";
  45486. import { Color3 } from "babylonjs/Maths/math";
  45487. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45488. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45489. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45490. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  45491. /**
  45492. * The Physically based material of BJS.
  45493. *
  45494. * This offers the main features of a standard PBR material.
  45495. * For more information, please refer to the documentation :
  45496. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45497. */
  45498. export class PBRMaterial extends PBRBaseMaterial {
  45499. /**
  45500. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45501. */
  45502. static readonly PBRMATERIAL_OPAQUE: number;
  45503. /**
  45504. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45505. */
  45506. static readonly PBRMATERIAL_ALPHATEST: number;
  45507. /**
  45508. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45509. */
  45510. static readonly PBRMATERIAL_ALPHABLEND: number;
  45511. /**
  45512. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45513. * They are also discarded below the alpha cutoff threshold to improve performances.
  45514. */
  45515. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45516. /**
  45517. * Defines the default value of how much AO map is occluding the analytical lights
  45518. * (point spot...).
  45519. */
  45520. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45521. /**
  45522. * Intensity of the direct lights e.g. the four lights available in your scene.
  45523. * This impacts both the direct diffuse and specular highlights.
  45524. */
  45525. directIntensity: number;
  45526. /**
  45527. * Intensity of the emissive part of the material.
  45528. * This helps controlling the emissive effect without modifying the emissive color.
  45529. */
  45530. emissiveIntensity: number;
  45531. /**
  45532. * Intensity of the environment e.g. how much the environment will light the object
  45533. * either through harmonics for rough material or through the refelction for shiny ones.
  45534. */
  45535. environmentIntensity: number;
  45536. /**
  45537. * This is a special control allowing the reduction of the specular highlights coming from the
  45538. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45539. */
  45540. specularIntensity: number;
  45541. /**
  45542. * Debug Control allowing disabling the bump map on this material.
  45543. */
  45544. disableBumpMap: boolean;
  45545. /**
  45546. * AKA Diffuse Texture in standard nomenclature.
  45547. */
  45548. albedoTexture: BaseTexture;
  45549. /**
  45550. * AKA Occlusion Texture in other nomenclature.
  45551. */
  45552. ambientTexture: BaseTexture;
  45553. /**
  45554. * AKA Occlusion Texture Intensity in other nomenclature.
  45555. */
  45556. ambientTextureStrength: number;
  45557. /**
  45558. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45559. * 1 means it completely occludes it
  45560. * 0 mean it has no impact
  45561. */
  45562. ambientTextureImpactOnAnalyticalLights: number;
  45563. /**
  45564. * Stores the alpha values in a texture.
  45565. */
  45566. opacityTexture: BaseTexture;
  45567. /**
  45568. * Stores the reflection values in a texture.
  45569. */
  45570. reflectionTexture: Nullable<BaseTexture>;
  45571. /**
  45572. * Stores the emissive values in a texture.
  45573. */
  45574. emissiveTexture: BaseTexture;
  45575. /**
  45576. * AKA Specular texture in other nomenclature.
  45577. */
  45578. reflectivityTexture: BaseTexture;
  45579. /**
  45580. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45581. */
  45582. metallicTexture: BaseTexture;
  45583. /**
  45584. * Specifies the metallic scalar of the metallic/roughness workflow.
  45585. * Can also be used to scale the metalness values of the metallic texture.
  45586. */
  45587. metallic: Nullable<number>;
  45588. /**
  45589. * Specifies the roughness scalar of the metallic/roughness workflow.
  45590. * Can also be used to scale the roughness values of the metallic texture.
  45591. */
  45592. roughness: Nullable<number>;
  45593. /**
  45594. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45595. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45596. */
  45597. microSurfaceTexture: BaseTexture;
  45598. /**
  45599. * Stores surface normal data used to displace a mesh in a texture.
  45600. */
  45601. bumpTexture: BaseTexture;
  45602. /**
  45603. * Stores the pre-calculated light information of a mesh in a texture.
  45604. */
  45605. lightmapTexture: BaseTexture;
  45606. /**
  45607. * Stores the refracted light information in a texture.
  45608. */
  45609. refractionTexture: BaseTexture;
  45610. /**
  45611. * The color of a material in ambient lighting.
  45612. */
  45613. ambientColor: Color3;
  45614. /**
  45615. * AKA Diffuse Color in other nomenclature.
  45616. */
  45617. albedoColor: Color3;
  45618. /**
  45619. * AKA Specular Color in other nomenclature.
  45620. */
  45621. reflectivityColor: Color3;
  45622. /**
  45623. * The color reflected from the material.
  45624. */
  45625. reflectionColor: Color3;
  45626. /**
  45627. * The color emitted from the material.
  45628. */
  45629. emissiveColor: Color3;
  45630. /**
  45631. * AKA Glossiness in other nomenclature.
  45632. */
  45633. microSurface: number;
  45634. /**
  45635. * source material index of refraction (IOR)' / 'destination material IOR.
  45636. */
  45637. indexOfRefraction: number;
  45638. /**
  45639. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45640. */
  45641. invertRefractionY: boolean;
  45642. /**
  45643. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45644. * Materials half opaque for instance using refraction could benefit from this control.
  45645. */
  45646. linkRefractionWithTransparency: boolean;
  45647. /**
  45648. * If true, the light map contains occlusion information instead of lighting info.
  45649. */
  45650. useLightmapAsShadowmap: boolean;
  45651. /**
  45652. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45653. */
  45654. useAlphaFromAlbedoTexture: boolean;
  45655. /**
  45656. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45657. */
  45658. forceAlphaTest: boolean;
  45659. /**
  45660. * Defines the alpha limits in alpha test mode.
  45661. */
  45662. alphaCutOff: number;
  45663. /**
  45664. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45665. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45666. */
  45667. useSpecularOverAlpha: boolean;
  45668. /**
  45669. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45670. */
  45671. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45672. /**
  45673. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45674. */
  45675. useRoughnessFromMetallicTextureAlpha: boolean;
  45676. /**
  45677. * Specifies if the metallic texture contains the roughness information in its green channel.
  45678. */
  45679. useRoughnessFromMetallicTextureGreen: boolean;
  45680. /**
  45681. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45682. */
  45683. useMetallnessFromMetallicTextureBlue: boolean;
  45684. /**
  45685. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45686. */
  45687. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45688. /**
  45689. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45690. */
  45691. useAmbientInGrayScale: boolean;
  45692. /**
  45693. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45694. * The material will try to infer what glossiness each pixel should be.
  45695. */
  45696. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45697. /**
  45698. * BJS is using an harcoded light falloff based on a manually sets up range.
  45699. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45700. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45701. */
  45702. /**
  45703. * BJS is using an harcoded light falloff based on a manually sets up range.
  45704. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45705. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45706. */
  45707. usePhysicalLightFalloff: boolean;
  45708. /**
  45709. * In order to support the falloff compatibility with gltf, a special mode has been added
  45710. * to reproduce the gltf light falloff.
  45711. */
  45712. /**
  45713. * In order to support the falloff compatibility with gltf, a special mode has been added
  45714. * to reproduce the gltf light falloff.
  45715. */
  45716. useGLTFLightFalloff: boolean;
  45717. /**
  45718. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45719. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45720. */
  45721. useRadianceOverAlpha: boolean;
  45722. /**
  45723. * Allows using an object space normal map (instead of tangent space).
  45724. */
  45725. useObjectSpaceNormalMap: boolean;
  45726. /**
  45727. * Allows using the bump map in parallax mode.
  45728. */
  45729. useParallax: boolean;
  45730. /**
  45731. * Allows using the bump map in parallax occlusion mode.
  45732. */
  45733. useParallaxOcclusion: boolean;
  45734. /**
  45735. * Controls the scale bias of the parallax mode.
  45736. */
  45737. parallaxScaleBias: number;
  45738. /**
  45739. * If sets to true, disables all the lights affecting the material.
  45740. */
  45741. disableLighting: boolean;
  45742. /**
  45743. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45744. */
  45745. forceIrradianceInFragment: boolean;
  45746. /**
  45747. * Number of Simultaneous lights allowed on the material.
  45748. */
  45749. maxSimultaneousLights: number;
  45750. /**
  45751. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45752. */
  45753. invertNormalMapX: boolean;
  45754. /**
  45755. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45756. */
  45757. invertNormalMapY: boolean;
  45758. /**
  45759. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45760. */
  45761. twoSidedLighting: boolean;
  45762. /**
  45763. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45764. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45765. */
  45766. useAlphaFresnel: boolean;
  45767. /**
  45768. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45769. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45770. */
  45771. useLinearAlphaFresnel: boolean;
  45772. /**
  45773. * Let user defines the brdf lookup texture used for IBL.
  45774. * A default 8bit version is embedded but you could point at :
  45775. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45776. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45777. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45778. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45779. */
  45780. environmentBRDFTexture: Nullable<BaseTexture>;
  45781. /**
  45782. * Force normal to face away from face.
  45783. */
  45784. forceNormalForward: boolean;
  45785. /**
  45786. * Enables specular anti aliasing in the PBR shader.
  45787. * It will both interacts on the Geometry for analytical and IBL lighting.
  45788. * It also prefilter the roughness map based on the bump values.
  45789. */
  45790. enableSpecularAntiAliasing: boolean;
  45791. /**
  45792. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45793. * makes the reflect vector face the model (under horizon).
  45794. */
  45795. useHorizonOcclusion: boolean;
  45796. /**
  45797. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45798. * too much the area relying on ambient texture to define their ambient occlusion.
  45799. */
  45800. useRadianceOcclusion: boolean;
  45801. /**
  45802. * If set to true, no lighting calculations will be applied.
  45803. */
  45804. unlit: boolean;
  45805. /**
  45806. * Gets the image processing configuration used either in this material.
  45807. */
  45808. /**
  45809. * Sets the Default image processing configuration used either in the this material.
  45810. *
  45811. * If sets to null, the scene one is in use.
  45812. */
  45813. imageProcessingConfiguration: ImageProcessingConfiguration;
  45814. /**
  45815. * Gets wether the color curves effect is enabled.
  45816. */
  45817. /**
  45818. * Sets wether the color curves effect is enabled.
  45819. */
  45820. cameraColorCurvesEnabled: boolean;
  45821. /**
  45822. * Gets wether the color grading effect is enabled.
  45823. */
  45824. /**
  45825. * Gets wether the color grading effect is enabled.
  45826. */
  45827. cameraColorGradingEnabled: boolean;
  45828. /**
  45829. * Gets wether tonemapping is enabled or not.
  45830. */
  45831. /**
  45832. * Sets wether tonemapping is enabled or not
  45833. */
  45834. cameraToneMappingEnabled: boolean;
  45835. /**
  45836. * The camera exposure used on this material.
  45837. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45838. * This corresponds to a photographic exposure.
  45839. */
  45840. /**
  45841. * The camera exposure used on this material.
  45842. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45843. * This corresponds to a photographic exposure.
  45844. */
  45845. cameraExposure: number;
  45846. /**
  45847. * Gets The camera contrast used on this material.
  45848. */
  45849. /**
  45850. * Sets The camera contrast used on this material.
  45851. */
  45852. cameraContrast: number;
  45853. /**
  45854. * Gets the Color Grading 2D Lookup Texture.
  45855. */
  45856. /**
  45857. * Sets the Color Grading 2D Lookup Texture.
  45858. */
  45859. cameraColorGradingTexture: Nullable<BaseTexture>;
  45860. /**
  45861. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45862. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45863. * 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;
  45864. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45865. */
  45866. /**
  45867. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45868. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45869. * 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;
  45870. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45871. */
  45872. cameraColorCurves: Nullable<ColorCurves>;
  45873. /**
  45874. * Instantiates a new PBRMaterial instance.
  45875. *
  45876. * @param name The material name
  45877. * @param scene The scene the material will be use in.
  45878. */
  45879. constructor(name: string, scene: Scene);
  45880. /**
  45881. * Returns the name of this material class.
  45882. */
  45883. getClassName(): string;
  45884. /**
  45885. * Makes a duplicate of the current material.
  45886. * @param name - name to use for the new material.
  45887. */
  45888. clone(name: string): PBRMaterial;
  45889. /**
  45890. * Serializes this PBR Material.
  45891. * @returns - An object with the serialized material.
  45892. */
  45893. serialize(): any;
  45894. /**
  45895. * Parses a PBR Material from a serialized object.
  45896. * @param source - Serialized object.
  45897. * @param scene - BJS scene instance.
  45898. * @param rootUrl - url for the scene object
  45899. * @returns - PBRMaterial
  45900. */
  45901. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45902. }
  45903. }
  45904. declare module "babylonjs/Misc/dds" {
  45905. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  45906. import { Engine } from "babylonjs/Engines/engine";
  45907. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45908. import { Nullable } from "babylonjs/types";
  45909. import { Scene } from "babylonjs/scene";
  45910. /**
  45911. * Direct draw surface info
  45912. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45913. */
  45914. export interface DDSInfo {
  45915. /**
  45916. * Width of the texture
  45917. */
  45918. width: number;
  45919. /**
  45920. * Width of the texture
  45921. */
  45922. height: number;
  45923. /**
  45924. * Number of Mipmaps for the texture
  45925. * @see https://en.wikipedia.org/wiki/Mipmap
  45926. */
  45927. mipmapCount: number;
  45928. /**
  45929. * If the textures format is a known fourCC format
  45930. * @see https://www.fourcc.org/
  45931. */
  45932. isFourCC: boolean;
  45933. /**
  45934. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45935. */
  45936. isRGB: boolean;
  45937. /**
  45938. * If the texture is a lumincance format
  45939. */
  45940. isLuminance: boolean;
  45941. /**
  45942. * If this is a cube texture
  45943. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45944. */
  45945. isCube: boolean;
  45946. /**
  45947. * If the texture is a compressed format eg. FOURCC_DXT1
  45948. */
  45949. isCompressed: boolean;
  45950. /**
  45951. * The dxgiFormat of the texture
  45952. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45953. */
  45954. dxgiFormat: number;
  45955. /**
  45956. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45957. */
  45958. textureType: number;
  45959. /**
  45960. * Sphericle polynomial created for the dds texture
  45961. */
  45962. sphericalPolynomial?: SphericalPolynomial;
  45963. }
  45964. /**
  45965. * Class used to provide DDS decompression tools
  45966. */
  45967. export class DDSTools {
  45968. /**
  45969. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45970. */
  45971. static StoreLODInAlphaChannel: boolean;
  45972. /**
  45973. * Gets DDS information from an array buffer
  45974. * @param arrayBuffer defines the array buffer to read data from
  45975. * @returns the DDS information
  45976. */
  45977. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45978. private static _FloatView;
  45979. private static _Int32View;
  45980. private static _ToHalfFloat;
  45981. private static _FromHalfFloat;
  45982. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45983. private static _GetHalfFloatRGBAArrayBuffer;
  45984. private static _GetFloatRGBAArrayBuffer;
  45985. private static _GetFloatAsUIntRGBAArrayBuffer;
  45986. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45987. private static _GetRGBAArrayBuffer;
  45988. private static _ExtractLongWordOrder;
  45989. private static _GetRGBArrayBuffer;
  45990. private static _GetLuminanceArrayBuffer;
  45991. /**
  45992. * Uploads DDS Levels to a Babylon Texture
  45993. * @hidden
  45994. */
  45995. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45996. }
  45997. module "babylonjs/Engines/engine" {
  45998. interface Engine {
  45999. /**
  46000. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46001. * @param rootUrl defines the url where the file to load is located
  46002. * @param scene defines the current scene
  46003. * @param lodScale defines scale to apply to the mip map selection
  46004. * @param lodOffset defines offset to apply to the mip map selection
  46005. * @param onLoad defines an optional callback raised when the texture is loaded
  46006. * @param onError defines an optional callback raised if there is an issue to load the texture
  46007. * @param format defines the format of the data
  46008. * @param forcedExtension defines the extension to use to pick the right loader
  46009. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46010. * @returns the cube texture as an InternalTexture
  46011. */
  46012. 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;
  46013. }
  46014. }
  46015. }
  46016. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  46017. import { Nullable } from "babylonjs/types";
  46018. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46019. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46020. /**
  46021. * Implementation of the DDS Texture Loader.
  46022. * @hidden
  46023. */
  46024. export class _DDSTextureLoader implements IInternalTextureLoader {
  46025. /**
  46026. * Defines wether the loader supports cascade loading the different faces.
  46027. */
  46028. readonly supportCascades: boolean;
  46029. /**
  46030. * This returns if the loader support the current file information.
  46031. * @param extension defines the file extension of the file being loaded
  46032. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46033. * @param fallback defines the fallback internal texture if any
  46034. * @param isBase64 defines whether the texture is encoded as a base64
  46035. * @param isBuffer defines whether the texture data are stored as a buffer
  46036. * @returns true if the loader can load the specified file
  46037. */
  46038. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46039. /**
  46040. * Transform the url before loading if required.
  46041. * @param rootUrl the url of the texture
  46042. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46043. * @returns the transformed texture
  46044. */
  46045. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46046. /**
  46047. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46048. * @param rootUrl the url of the texture
  46049. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46050. * @returns the fallback texture
  46051. */
  46052. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46053. /**
  46054. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46055. * @param data contains the texture data
  46056. * @param texture defines the BabylonJS internal texture
  46057. * @param createPolynomials will be true if polynomials have been requested
  46058. * @param onLoad defines the callback to trigger once the texture is ready
  46059. * @param onError defines the callback to trigger in case of error
  46060. */
  46061. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46062. /**
  46063. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46064. * @param data contains the texture data
  46065. * @param texture defines the BabylonJS internal texture
  46066. * @param callback defines the method to call once ready to upload
  46067. */
  46068. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46069. }
  46070. }
  46071. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46072. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46073. /** @hidden */
  46074. export var rgbdEncodePixelShader: {
  46075. name: string;
  46076. shader: string;
  46077. };
  46078. }
  46079. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46080. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46081. /** @hidden */
  46082. export var rgbdDecodePixelShader: {
  46083. name: string;
  46084. shader: string;
  46085. };
  46086. }
  46087. declare module "babylonjs/Misc/environmentTextureTools" {
  46088. import { Nullable } from "babylonjs/types";
  46089. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46090. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46091. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46092. import "babylonjs/Shaders/rgbdEncode.fragment";
  46093. import "babylonjs/Shaders/rgbdDecode.fragment";
  46094. /**
  46095. * Raw texture data and descriptor sufficient for WebGL texture upload
  46096. */
  46097. export interface EnvironmentTextureInfo {
  46098. /**
  46099. * Version of the environment map
  46100. */
  46101. version: number;
  46102. /**
  46103. * Width of image
  46104. */
  46105. width: number;
  46106. /**
  46107. * Irradiance information stored in the file.
  46108. */
  46109. irradiance: any;
  46110. /**
  46111. * Specular information stored in the file.
  46112. */
  46113. specular: any;
  46114. }
  46115. /**
  46116. * Sets of helpers addressing the serialization and deserialization of environment texture
  46117. * stored in a BabylonJS env file.
  46118. * Those files are usually stored as .env files.
  46119. */
  46120. export class EnvironmentTextureTools {
  46121. /**
  46122. * Magic number identifying the env file.
  46123. */
  46124. private static _MagicBytes;
  46125. /**
  46126. * Gets the environment info from an env file.
  46127. * @param data The array buffer containing the .env bytes.
  46128. * @returns the environment file info (the json header) if successfully parsed.
  46129. */
  46130. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46131. /**
  46132. * Creates an environment texture from a loaded cube texture.
  46133. * @param texture defines the cube texture to convert in env file
  46134. * @return a promise containing the environment data if succesfull.
  46135. */
  46136. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46137. /**
  46138. * Creates a JSON representation of the spherical data.
  46139. * @param texture defines the texture containing the polynomials
  46140. * @return the JSON representation of the spherical info
  46141. */
  46142. private static _CreateEnvTextureIrradiance;
  46143. /**
  46144. * Uploads the texture info contained in the env file to the GPU.
  46145. * @param texture defines the internal texture to upload to
  46146. * @param arrayBuffer defines the buffer cotaining the data to load
  46147. * @param info defines the texture info retrieved through the GetEnvInfo method
  46148. * @returns a promise
  46149. */
  46150. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46151. /**
  46152. * Uploads the levels of image data to the GPU.
  46153. * @param texture defines the internal texture to upload to
  46154. * @param imageData defines the array buffer views of image data [mipmap][face]
  46155. * @returns a promise
  46156. */
  46157. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46158. /**
  46159. * Uploads spherical polynomials information to the texture.
  46160. * @param texture defines the texture we are trying to upload the information to
  46161. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46162. */
  46163. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46164. /** @hidden */
  46165. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46166. }
  46167. }
  46168. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  46169. import { Nullable } from "babylonjs/types";
  46170. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46171. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46172. /**
  46173. * Implementation of the ENV Texture Loader.
  46174. * @hidden
  46175. */
  46176. export class _ENVTextureLoader implements IInternalTextureLoader {
  46177. /**
  46178. * Defines wether the loader supports cascade loading the different faces.
  46179. */
  46180. readonly supportCascades: boolean;
  46181. /**
  46182. * This returns if the loader support the current file information.
  46183. * @param extension defines the file extension of the file being loaded
  46184. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46185. * @param fallback defines the fallback internal texture if any
  46186. * @param isBase64 defines whether the texture is encoded as a base64
  46187. * @param isBuffer defines whether the texture data are stored as a buffer
  46188. * @returns true if the loader can load the specified file
  46189. */
  46190. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46191. /**
  46192. * Transform the url before loading if required.
  46193. * @param rootUrl the url of the texture
  46194. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46195. * @returns the transformed texture
  46196. */
  46197. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46198. /**
  46199. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46200. * @param rootUrl the url of the texture
  46201. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46202. * @returns the fallback texture
  46203. */
  46204. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46205. /**
  46206. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46207. * @param data contains the texture data
  46208. * @param texture defines the BabylonJS internal texture
  46209. * @param createPolynomials will be true if polynomials have been requested
  46210. * @param onLoad defines the callback to trigger once the texture is ready
  46211. * @param onError defines the callback to trigger in case of error
  46212. */
  46213. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46214. /**
  46215. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46216. * @param data contains the texture data
  46217. * @param texture defines the BabylonJS internal texture
  46218. * @param callback defines the method to call once ready to upload
  46219. */
  46220. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46221. }
  46222. }
  46223. declare module "babylonjs/Misc/khronosTextureContainer" {
  46224. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46225. /**
  46226. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46227. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46228. */
  46229. export class KhronosTextureContainer {
  46230. /** contents of the KTX container file */
  46231. arrayBuffer: any;
  46232. private static HEADER_LEN;
  46233. private static COMPRESSED_2D;
  46234. private static COMPRESSED_3D;
  46235. private static TEX_2D;
  46236. private static TEX_3D;
  46237. /**
  46238. * Gets the openGL type
  46239. */
  46240. glType: number;
  46241. /**
  46242. * Gets the openGL type size
  46243. */
  46244. glTypeSize: number;
  46245. /**
  46246. * Gets the openGL format
  46247. */
  46248. glFormat: number;
  46249. /**
  46250. * Gets the openGL internal format
  46251. */
  46252. glInternalFormat: number;
  46253. /**
  46254. * Gets the base internal format
  46255. */
  46256. glBaseInternalFormat: number;
  46257. /**
  46258. * Gets image width in pixel
  46259. */
  46260. pixelWidth: number;
  46261. /**
  46262. * Gets image height in pixel
  46263. */
  46264. pixelHeight: number;
  46265. /**
  46266. * Gets image depth in pixels
  46267. */
  46268. pixelDepth: number;
  46269. /**
  46270. * Gets the number of array elements
  46271. */
  46272. numberOfArrayElements: number;
  46273. /**
  46274. * Gets the number of faces
  46275. */
  46276. numberOfFaces: number;
  46277. /**
  46278. * Gets the number of mipmap levels
  46279. */
  46280. numberOfMipmapLevels: number;
  46281. /**
  46282. * Gets the bytes of key value data
  46283. */
  46284. bytesOfKeyValueData: number;
  46285. /**
  46286. * Gets the load type
  46287. */
  46288. loadType: number;
  46289. /**
  46290. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46291. */
  46292. isInvalid: boolean;
  46293. /**
  46294. * Creates a new KhronosTextureContainer
  46295. * @param arrayBuffer contents of the KTX container file
  46296. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46297. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46298. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46299. */
  46300. constructor(
  46301. /** contents of the KTX container file */
  46302. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46303. /**
  46304. * Uploads KTX content to a Babylon Texture.
  46305. * It is assumed that the texture has already been created & is currently bound
  46306. * @hidden
  46307. */
  46308. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46309. private _upload2DCompressedLevels;
  46310. }
  46311. }
  46312. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  46313. import { Nullable } from "babylonjs/types";
  46314. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46315. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46316. /**
  46317. * Implementation of the KTX Texture Loader.
  46318. * @hidden
  46319. */
  46320. export class _KTXTextureLoader implements IInternalTextureLoader {
  46321. /**
  46322. * Defines wether the loader supports cascade loading the different faces.
  46323. */
  46324. readonly supportCascades: boolean;
  46325. /**
  46326. * This returns if the loader support the current file information.
  46327. * @param extension defines the file extension of the file being loaded
  46328. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46329. * @param fallback defines the fallback internal texture if any
  46330. * @param isBase64 defines whether the texture is encoded as a base64
  46331. * @param isBuffer defines whether the texture data are stored as a buffer
  46332. * @returns true if the loader can load the specified file
  46333. */
  46334. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46335. /**
  46336. * Transform the url before loading if required.
  46337. * @param rootUrl the url of the texture
  46338. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46339. * @returns the transformed texture
  46340. */
  46341. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46342. /**
  46343. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46344. * @param rootUrl the url of the texture
  46345. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46346. * @returns the fallback texture
  46347. */
  46348. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46349. /**
  46350. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46351. * @param data contains the texture data
  46352. * @param texture defines the BabylonJS internal texture
  46353. * @param createPolynomials will be true if polynomials have been requested
  46354. * @param onLoad defines the callback to trigger once the texture is ready
  46355. * @param onError defines the callback to trigger in case of error
  46356. */
  46357. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46358. /**
  46359. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46360. * @param data contains the texture data
  46361. * @param texture defines the BabylonJS internal texture
  46362. * @param callback defines the method to call once ready to upload
  46363. */
  46364. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46365. }
  46366. }
  46367. declare module "babylonjs/Helpers/sceneHelpers" {
  46368. import { Nullable } from "babylonjs/types";
  46369. import { Mesh } from "babylonjs/Meshes/mesh";
  46370. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46371. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  46372. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46373. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  46374. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  46375. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  46376. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  46377. import "babylonjs/Meshes/Builders/boxBuilder";
  46378. /** @hidden */
  46379. export var _forceSceneHelpersToBundle: boolean;
  46380. module "babylonjs/scene" {
  46381. interface Scene {
  46382. /**
  46383. * Creates a default light for the scene.
  46384. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46385. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46386. */
  46387. createDefaultLight(replace?: boolean): void;
  46388. /**
  46389. * Creates a default camera for the scene.
  46390. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46391. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46392. * @param replace has default false, when true replaces the active camera in the scene
  46393. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46394. */
  46395. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46396. /**
  46397. * Creates a default camera and a default light.
  46398. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46399. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46400. * @param replace has the default false, when true replaces the active camera/light in the scene
  46401. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46402. */
  46403. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46404. /**
  46405. * Creates a new sky box
  46406. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46407. * @param environmentTexture defines the texture to use as environment texture
  46408. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46409. * @param scale defines the overall scale of the skybox
  46410. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46411. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46412. * @returns a new mesh holding the sky box
  46413. */
  46414. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46415. /**
  46416. * Creates a new environment
  46417. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46418. * @param options defines the options you can use to configure the environment
  46419. * @returns the new EnvironmentHelper
  46420. */
  46421. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46422. /**
  46423. * Creates a new VREXperienceHelper
  46424. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46425. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46426. * @returns a new VREXperienceHelper
  46427. */
  46428. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46429. /**
  46430. * Creates a new XREXperienceHelper
  46431. * @see http://doc.babylonjs.com/how_to/webxr
  46432. * @returns a promise for a new XREXperienceHelper
  46433. */
  46434. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46435. }
  46436. }
  46437. }
  46438. declare module "babylonjs/Helpers/videoDome" {
  46439. import { Scene } from "babylonjs/scene";
  46440. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46441. import { Mesh } from "babylonjs/Meshes/mesh";
  46442. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  46443. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46444. import "babylonjs/Meshes/Builders/sphereBuilder";
  46445. /**
  46446. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46447. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46448. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46449. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46450. */
  46451. export class VideoDome extends TransformNode {
  46452. /**
  46453. * Define the video source as a Monoscopic panoramic 360 video.
  46454. */
  46455. static readonly MODE_MONOSCOPIC: number;
  46456. /**
  46457. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46458. */
  46459. static readonly MODE_TOPBOTTOM: number;
  46460. /**
  46461. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46462. */
  46463. static readonly MODE_SIDEBYSIDE: number;
  46464. private _useDirectMapping;
  46465. /**
  46466. * The video texture being displayed on the sphere
  46467. */
  46468. protected _videoTexture: VideoTexture;
  46469. /**
  46470. * Gets the video texture being displayed on the sphere
  46471. */
  46472. readonly videoTexture: VideoTexture;
  46473. /**
  46474. * The skybox material
  46475. */
  46476. protected _material: BackgroundMaterial;
  46477. /**
  46478. * The surface used for the skybox
  46479. */
  46480. protected _mesh: Mesh;
  46481. /**
  46482. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46483. * Also see the options.resolution property.
  46484. */
  46485. fovMultiplier: number;
  46486. private _videoMode;
  46487. /**
  46488. * Gets or set the current video mode for the video. It can be:
  46489. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46490. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46491. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46492. */
  46493. videoMode: number;
  46494. /**
  46495. * Oberserver used in Stereoscopic VR Mode.
  46496. */
  46497. private _onBeforeCameraRenderObserver;
  46498. /**
  46499. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46500. * @param name Element's name, child elements will append suffixes for their own names.
  46501. * @param urlsOrVideo defines the url(s) or the video element to use
  46502. * @param options An object containing optional or exposed sub element properties
  46503. */
  46504. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46505. resolution?: number;
  46506. clickToPlay?: boolean;
  46507. autoPlay?: boolean;
  46508. loop?: boolean;
  46509. size?: number;
  46510. poster?: string;
  46511. useDirectMapping?: boolean;
  46512. }, scene: Scene);
  46513. private _changeVideoMode;
  46514. /**
  46515. * Releases resources associated with this node.
  46516. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46517. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46518. */
  46519. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46520. }
  46521. }
  46522. declare module "babylonjs/Helpers/index" {
  46523. export * from "babylonjs/Helpers/environmentHelper";
  46524. export * from "babylonjs/Helpers/photoDome";
  46525. export * from "babylonjs/Helpers/sceneHelpers";
  46526. export * from "babylonjs/Helpers/videoDome";
  46527. }
  46528. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  46529. import { PerfCounter } from "babylonjs/Misc/tools";
  46530. import { IDisposable } from "babylonjs/scene";
  46531. import { Engine } from "babylonjs/Engines/engine";
  46532. /**
  46533. * This class can be used to get instrumentation data from a Babylon engine
  46534. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46535. */
  46536. export class EngineInstrumentation implements IDisposable {
  46537. /**
  46538. * Define the instrumented engine.
  46539. */
  46540. engine: Engine;
  46541. private _captureGPUFrameTime;
  46542. private _gpuFrameTimeToken;
  46543. private _gpuFrameTime;
  46544. private _captureShaderCompilationTime;
  46545. private _shaderCompilationTime;
  46546. private _onBeginFrameObserver;
  46547. private _onEndFrameObserver;
  46548. private _onBeforeShaderCompilationObserver;
  46549. private _onAfterShaderCompilationObserver;
  46550. /**
  46551. * Gets the perf counter used for GPU frame time
  46552. */
  46553. readonly gpuFrameTimeCounter: PerfCounter;
  46554. /**
  46555. * Gets the GPU frame time capture status
  46556. */
  46557. /**
  46558. * Enable or disable the GPU frame time capture
  46559. */
  46560. captureGPUFrameTime: boolean;
  46561. /**
  46562. * Gets the perf counter used for shader compilation time
  46563. */
  46564. readonly shaderCompilationTimeCounter: PerfCounter;
  46565. /**
  46566. * Gets the shader compilation time capture status
  46567. */
  46568. /**
  46569. * Enable or disable the shader compilation time capture
  46570. */
  46571. captureShaderCompilationTime: boolean;
  46572. /**
  46573. * Instantiates a new engine instrumentation.
  46574. * This class can be used to get instrumentation data from a Babylon engine
  46575. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46576. * @param engine Defines the engine to instrument
  46577. */
  46578. constructor(
  46579. /**
  46580. * Define the instrumented engine.
  46581. */
  46582. engine: Engine);
  46583. /**
  46584. * Dispose and release associated resources.
  46585. */
  46586. dispose(): void;
  46587. }
  46588. }
  46589. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  46590. import { PerfCounter } from "babylonjs/Misc/tools";
  46591. import { Scene, IDisposable } from "babylonjs/scene";
  46592. /**
  46593. * This class can be used to get instrumentation data from a Babylon engine
  46594. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46595. */
  46596. export class SceneInstrumentation implements IDisposable {
  46597. /**
  46598. * Defines the scene to instrument
  46599. */
  46600. scene: Scene;
  46601. private _captureActiveMeshesEvaluationTime;
  46602. private _activeMeshesEvaluationTime;
  46603. private _captureRenderTargetsRenderTime;
  46604. private _renderTargetsRenderTime;
  46605. private _captureFrameTime;
  46606. private _frameTime;
  46607. private _captureRenderTime;
  46608. private _renderTime;
  46609. private _captureInterFrameTime;
  46610. private _interFrameTime;
  46611. private _captureParticlesRenderTime;
  46612. private _particlesRenderTime;
  46613. private _captureSpritesRenderTime;
  46614. private _spritesRenderTime;
  46615. private _capturePhysicsTime;
  46616. private _physicsTime;
  46617. private _captureAnimationsTime;
  46618. private _animationsTime;
  46619. private _captureCameraRenderTime;
  46620. private _cameraRenderTime;
  46621. private _onBeforeActiveMeshesEvaluationObserver;
  46622. private _onAfterActiveMeshesEvaluationObserver;
  46623. private _onBeforeRenderTargetsRenderObserver;
  46624. private _onAfterRenderTargetsRenderObserver;
  46625. private _onAfterRenderObserver;
  46626. private _onBeforeDrawPhaseObserver;
  46627. private _onAfterDrawPhaseObserver;
  46628. private _onBeforeAnimationsObserver;
  46629. private _onBeforeParticlesRenderingObserver;
  46630. private _onAfterParticlesRenderingObserver;
  46631. private _onBeforeSpritesRenderingObserver;
  46632. private _onAfterSpritesRenderingObserver;
  46633. private _onBeforePhysicsObserver;
  46634. private _onAfterPhysicsObserver;
  46635. private _onAfterAnimationsObserver;
  46636. private _onBeforeCameraRenderObserver;
  46637. private _onAfterCameraRenderObserver;
  46638. /**
  46639. * Gets the perf counter used for active meshes evaluation time
  46640. */
  46641. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46642. /**
  46643. * Gets the active meshes evaluation time capture status
  46644. */
  46645. /**
  46646. * Enable or disable the active meshes evaluation time capture
  46647. */
  46648. captureActiveMeshesEvaluationTime: boolean;
  46649. /**
  46650. * Gets the perf counter used for render targets render time
  46651. */
  46652. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46653. /**
  46654. * Gets the render targets render time capture status
  46655. */
  46656. /**
  46657. * Enable or disable the render targets render time capture
  46658. */
  46659. captureRenderTargetsRenderTime: boolean;
  46660. /**
  46661. * Gets the perf counter used for particles render time
  46662. */
  46663. readonly particlesRenderTimeCounter: PerfCounter;
  46664. /**
  46665. * Gets the particles render time capture status
  46666. */
  46667. /**
  46668. * Enable or disable the particles render time capture
  46669. */
  46670. captureParticlesRenderTime: boolean;
  46671. /**
  46672. * Gets the perf counter used for sprites render time
  46673. */
  46674. readonly spritesRenderTimeCounter: PerfCounter;
  46675. /**
  46676. * Gets the sprites render time capture status
  46677. */
  46678. /**
  46679. * Enable or disable the sprites render time capture
  46680. */
  46681. captureSpritesRenderTime: boolean;
  46682. /**
  46683. * Gets the perf counter used for physics time
  46684. */
  46685. readonly physicsTimeCounter: PerfCounter;
  46686. /**
  46687. * Gets the physics time capture status
  46688. */
  46689. /**
  46690. * Enable or disable the physics time capture
  46691. */
  46692. capturePhysicsTime: boolean;
  46693. /**
  46694. * Gets the perf counter used for animations time
  46695. */
  46696. readonly animationsTimeCounter: PerfCounter;
  46697. /**
  46698. * Gets the animations time capture status
  46699. */
  46700. /**
  46701. * Enable or disable the animations time capture
  46702. */
  46703. captureAnimationsTime: boolean;
  46704. /**
  46705. * Gets the perf counter used for frame time capture
  46706. */
  46707. readonly frameTimeCounter: PerfCounter;
  46708. /**
  46709. * Gets the frame time capture status
  46710. */
  46711. /**
  46712. * Enable or disable the frame time capture
  46713. */
  46714. captureFrameTime: boolean;
  46715. /**
  46716. * Gets the perf counter used for inter-frames time capture
  46717. */
  46718. readonly interFrameTimeCounter: PerfCounter;
  46719. /**
  46720. * Gets the inter-frames time capture status
  46721. */
  46722. /**
  46723. * Enable or disable the inter-frames time capture
  46724. */
  46725. captureInterFrameTime: boolean;
  46726. /**
  46727. * Gets the perf counter used for render time capture
  46728. */
  46729. readonly renderTimeCounter: PerfCounter;
  46730. /**
  46731. * Gets the render time capture status
  46732. */
  46733. /**
  46734. * Enable or disable the render time capture
  46735. */
  46736. captureRenderTime: boolean;
  46737. /**
  46738. * Gets the perf counter used for camera render time capture
  46739. */
  46740. readonly cameraRenderTimeCounter: PerfCounter;
  46741. /**
  46742. * Gets the camera render time capture status
  46743. */
  46744. /**
  46745. * Enable or disable the camera render time capture
  46746. */
  46747. captureCameraRenderTime: boolean;
  46748. /**
  46749. * Gets the perf counter used for draw calls
  46750. */
  46751. readonly drawCallsCounter: PerfCounter;
  46752. /**
  46753. * Gets the perf counter used for texture collisions
  46754. */
  46755. readonly textureCollisionsCounter: PerfCounter;
  46756. /**
  46757. * Instantiates a new scene instrumentation.
  46758. * This class can be used to get instrumentation data from a Babylon engine
  46759. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46760. * @param scene Defines the scene to instrument
  46761. */
  46762. constructor(
  46763. /**
  46764. * Defines the scene to instrument
  46765. */
  46766. scene: Scene);
  46767. /**
  46768. * Dispose and release associated resources.
  46769. */
  46770. dispose(): void;
  46771. }
  46772. }
  46773. declare module "babylonjs/Instrumentation/index" {
  46774. export * from "babylonjs/Instrumentation/engineInstrumentation";
  46775. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  46776. export * from "babylonjs/Instrumentation/timeToken";
  46777. }
  46778. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  46779. /** @hidden */
  46780. export var glowMapGenerationPixelShader: {
  46781. name: string;
  46782. shader: string;
  46783. };
  46784. }
  46785. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  46786. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46787. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46788. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46789. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46790. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46791. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46792. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46793. /** @hidden */
  46794. export var glowMapGenerationVertexShader: {
  46795. name: string;
  46796. shader: string;
  46797. };
  46798. }
  46799. declare module "babylonjs/Layers/effectLayer" {
  46800. import { Observable } from "babylonjs/Misc/observable";
  46801. import { Nullable } from "babylonjs/types";
  46802. import { Camera } from "babylonjs/Cameras/camera";
  46803. import { Scene } from "babylonjs/scene";
  46804. import { Color4, ISize } from "babylonjs/Maths/math";
  46805. import { Engine } from "babylonjs/Engines/engine";
  46806. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46808. import { Mesh } from "babylonjs/Meshes/mesh";
  46809. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  46810. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46811. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46812. import { Effect } from "babylonjs/Materials/effect";
  46813. import { Material } from "babylonjs/Materials/material";
  46814. import "babylonjs/Shaders/glowMapGeneration.fragment";
  46815. import "babylonjs/Shaders/glowMapGeneration.vertex";
  46816. /**
  46817. * Effect layer options. This helps customizing the behaviour
  46818. * of the effect layer.
  46819. */
  46820. export interface IEffectLayerOptions {
  46821. /**
  46822. * Multiplication factor apply to the canvas size to compute the render target size
  46823. * used to generated the objects (the smaller the faster).
  46824. */
  46825. mainTextureRatio: number;
  46826. /**
  46827. * Enforces a fixed size texture to ensure effect stability across devices.
  46828. */
  46829. mainTextureFixedSize?: number;
  46830. /**
  46831. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46832. */
  46833. alphaBlendingMode: number;
  46834. /**
  46835. * The camera attached to the layer.
  46836. */
  46837. camera: Nullable<Camera>;
  46838. /**
  46839. * The rendering group to draw the layer in.
  46840. */
  46841. renderingGroupId: number;
  46842. }
  46843. /**
  46844. * The effect layer Helps adding post process effect blended with the main pass.
  46845. *
  46846. * This can be for instance use to generate glow or higlight effects on the scene.
  46847. *
  46848. * The effect layer class can not be used directly and is intented to inherited from to be
  46849. * customized per effects.
  46850. */
  46851. export abstract class EffectLayer {
  46852. private _vertexBuffers;
  46853. private _indexBuffer;
  46854. private _cachedDefines;
  46855. private _effectLayerMapGenerationEffect;
  46856. private _effectLayerOptions;
  46857. private _mergeEffect;
  46858. protected _scene: Scene;
  46859. protected _engine: Engine;
  46860. protected _maxSize: number;
  46861. protected _mainTextureDesiredSize: ISize;
  46862. protected _mainTexture: RenderTargetTexture;
  46863. protected _shouldRender: boolean;
  46864. protected _postProcesses: PostProcess[];
  46865. protected _textures: BaseTexture[];
  46866. protected _emissiveTextureAndColor: {
  46867. texture: Nullable<BaseTexture>;
  46868. color: Color4;
  46869. };
  46870. /**
  46871. * The name of the layer
  46872. */
  46873. name: string;
  46874. /**
  46875. * The clear color of the texture used to generate the glow map.
  46876. */
  46877. neutralColor: Color4;
  46878. /**
  46879. * Specifies wether the highlight layer is enabled or not.
  46880. */
  46881. isEnabled: boolean;
  46882. /**
  46883. * Gets the camera attached to the layer.
  46884. */
  46885. readonly camera: Nullable<Camera>;
  46886. /**
  46887. * Gets the rendering group id the layer should render in.
  46888. */
  46889. readonly renderingGroupId: number;
  46890. /**
  46891. * An event triggered when the effect layer has been disposed.
  46892. */
  46893. onDisposeObservable: Observable<EffectLayer>;
  46894. /**
  46895. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46896. */
  46897. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46898. /**
  46899. * An event triggered when the generated texture is being merged in the scene.
  46900. */
  46901. onBeforeComposeObservable: Observable<EffectLayer>;
  46902. /**
  46903. * An event triggered when the generated texture has been merged in the scene.
  46904. */
  46905. onAfterComposeObservable: Observable<EffectLayer>;
  46906. /**
  46907. * An event triggered when the efffect layer changes its size.
  46908. */
  46909. onSizeChangedObservable: Observable<EffectLayer>;
  46910. /** @hidden */
  46911. static _SceneComponentInitialization: (scene: Scene) => void;
  46912. /**
  46913. * Instantiates a new effect Layer and references it in the scene.
  46914. * @param name The name of the layer
  46915. * @param scene The scene to use the layer in
  46916. */
  46917. constructor(
  46918. /** The Friendly of the effect in the scene */
  46919. name: string, scene: Scene);
  46920. /**
  46921. * Get the effect name of the layer.
  46922. * @return The effect name
  46923. */
  46924. abstract getEffectName(): string;
  46925. /**
  46926. * Checks for the readiness of the element composing the layer.
  46927. * @param subMesh the mesh to check for
  46928. * @param useInstances specify wether or not to use instances to render the mesh
  46929. * @return true if ready otherwise, false
  46930. */
  46931. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46932. /**
  46933. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46934. * @returns true if the effect requires stencil during the main canvas render pass.
  46935. */
  46936. abstract needStencil(): boolean;
  46937. /**
  46938. * Create the merge effect. This is the shader use to blit the information back
  46939. * to the main canvas at the end of the scene rendering.
  46940. * @returns The effect containing the shader used to merge the effect on the main canvas
  46941. */
  46942. protected abstract _createMergeEffect(): Effect;
  46943. /**
  46944. * Creates the render target textures and post processes used in the effect layer.
  46945. */
  46946. protected abstract _createTextureAndPostProcesses(): void;
  46947. /**
  46948. * Implementation specific of rendering the generating effect on the main canvas.
  46949. * @param effect The effect used to render through
  46950. */
  46951. protected abstract _internalRender(effect: Effect): void;
  46952. /**
  46953. * Sets the required values for both the emissive texture and and the main color.
  46954. */
  46955. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46956. /**
  46957. * Free any resources and references associated to a mesh.
  46958. * Internal use
  46959. * @param mesh The mesh to free.
  46960. */
  46961. abstract _disposeMesh(mesh: Mesh): void;
  46962. /**
  46963. * Serializes this layer (Glow or Highlight for example)
  46964. * @returns a serialized layer object
  46965. */
  46966. abstract serialize?(): any;
  46967. /**
  46968. * Initializes the effect layer with the required options.
  46969. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46970. */
  46971. protected _init(options: Partial<IEffectLayerOptions>): void;
  46972. /**
  46973. * Generates the index buffer of the full screen quad blending to the main canvas.
  46974. */
  46975. private _generateIndexBuffer;
  46976. /**
  46977. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46978. */
  46979. private _genrateVertexBuffer;
  46980. /**
  46981. * Sets the main texture desired size which is the closest power of two
  46982. * of the engine canvas size.
  46983. */
  46984. private _setMainTextureSize;
  46985. /**
  46986. * Creates the main texture for the effect layer.
  46987. */
  46988. protected _createMainTexture(): void;
  46989. /**
  46990. * Adds specific effects defines.
  46991. * @param defines The defines to add specifics to.
  46992. */
  46993. protected _addCustomEffectDefines(defines: string[]): void;
  46994. /**
  46995. * Checks for the readiness of the element composing the layer.
  46996. * @param subMesh the mesh to check for
  46997. * @param useInstances specify wether or not to use instances to render the mesh
  46998. * @param emissiveTexture the associated emissive texture used to generate the glow
  46999. * @return true if ready otherwise, false
  47000. */
  47001. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47002. /**
  47003. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47004. */
  47005. render(): void;
  47006. /**
  47007. * Determine if a given mesh will be used in the current effect.
  47008. * @param mesh mesh to test
  47009. * @returns true if the mesh will be used
  47010. */
  47011. hasMesh(mesh: AbstractMesh): boolean;
  47012. /**
  47013. * Returns true if the layer contains information to display, otherwise false.
  47014. * @returns true if the glow layer should be rendered
  47015. */
  47016. shouldRender(): boolean;
  47017. /**
  47018. * Returns true if the mesh should render, otherwise false.
  47019. * @param mesh The mesh to render
  47020. * @returns true if it should render otherwise false
  47021. */
  47022. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47023. /**
  47024. * Returns true if the mesh can be rendered, otherwise false.
  47025. * @param mesh The mesh to render
  47026. * @param material The material used on the mesh
  47027. * @returns true if it can be rendered otherwise false
  47028. */
  47029. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47030. /**
  47031. * Returns true if the mesh should render, otherwise false.
  47032. * @param mesh The mesh to render
  47033. * @returns true if it should render otherwise false
  47034. */
  47035. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47036. /**
  47037. * Renders the submesh passed in parameter to the generation map.
  47038. */
  47039. protected _renderSubMesh(subMesh: SubMesh): void;
  47040. /**
  47041. * Rebuild the required buffers.
  47042. * @hidden Internal use only.
  47043. */
  47044. _rebuild(): void;
  47045. /**
  47046. * Dispose only the render target textures and post process.
  47047. */
  47048. private _disposeTextureAndPostProcesses;
  47049. /**
  47050. * Dispose the highlight layer and free resources.
  47051. */
  47052. dispose(): void;
  47053. /**
  47054. * Gets the class name of the effect layer
  47055. * @returns the string with the class name of the effect layer
  47056. */
  47057. getClassName(): string;
  47058. /**
  47059. * Creates an effect layer from parsed effect layer data
  47060. * @param parsedEffectLayer defines effect layer data
  47061. * @param scene defines the current scene
  47062. * @param rootUrl defines the root URL containing the effect layer information
  47063. * @returns a parsed effect Layer
  47064. */
  47065. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47066. }
  47067. }
  47068. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  47069. import { Scene } from "babylonjs/scene";
  47070. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47071. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47072. import { AbstractScene } from "babylonjs/abstractScene";
  47073. module "babylonjs/abstractScene" {
  47074. interface AbstractScene {
  47075. /**
  47076. * The list of effect layers (highlights/glow) added to the scene
  47077. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47078. * @see http://doc.babylonjs.com/how_to/glow_layer
  47079. */
  47080. effectLayers: Array<EffectLayer>;
  47081. /**
  47082. * Removes the given effect layer from this scene.
  47083. * @param toRemove defines the effect layer to remove
  47084. * @returns the index of the removed effect layer
  47085. */
  47086. removeEffectLayer(toRemove: EffectLayer): number;
  47087. /**
  47088. * Adds the given effect layer to this scene
  47089. * @param newEffectLayer defines the effect layer to add
  47090. */
  47091. addEffectLayer(newEffectLayer: EffectLayer): void;
  47092. }
  47093. }
  47094. /**
  47095. * Defines the layer scene component responsible to manage any effect layers
  47096. * in a given scene.
  47097. */
  47098. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47099. /**
  47100. * The component name helpfull to identify the component in the list of scene components.
  47101. */
  47102. readonly name: string;
  47103. /**
  47104. * The scene the component belongs to.
  47105. */
  47106. scene: Scene;
  47107. private _engine;
  47108. private _renderEffects;
  47109. private _needStencil;
  47110. private _previousStencilState;
  47111. /**
  47112. * Creates a new instance of the component for the given scene
  47113. * @param scene Defines the scene to register the component in
  47114. */
  47115. constructor(scene: Scene);
  47116. /**
  47117. * Registers the component in a given scene
  47118. */
  47119. register(): void;
  47120. /**
  47121. * Rebuilds the elements related to this component in case of
  47122. * context lost for instance.
  47123. */
  47124. rebuild(): void;
  47125. /**
  47126. * Serializes the component data to the specified json object
  47127. * @param serializationObject The object to serialize to
  47128. */
  47129. serialize(serializationObject: any): void;
  47130. /**
  47131. * Adds all the element from the container to the scene
  47132. * @param container the container holding the elements
  47133. */
  47134. addFromContainer(container: AbstractScene): void;
  47135. /**
  47136. * Removes all the elements in the container from the scene
  47137. * @param container contains the elements to remove
  47138. */
  47139. removeFromContainer(container: AbstractScene): void;
  47140. /**
  47141. * Disposes the component and the associated ressources.
  47142. */
  47143. dispose(): void;
  47144. private _isReadyForMesh;
  47145. private _renderMainTexture;
  47146. private _setStencil;
  47147. private _setStencilBack;
  47148. private _draw;
  47149. private _drawCamera;
  47150. private _drawRenderingGroup;
  47151. }
  47152. }
  47153. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  47154. /** @hidden */
  47155. export var glowMapMergePixelShader: {
  47156. name: string;
  47157. shader: string;
  47158. };
  47159. }
  47160. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  47161. /** @hidden */
  47162. export var glowMapMergeVertexShader: {
  47163. name: string;
  47164. shader: string;
  47165. };
  47166. }
  47167. declare module "babylonjs/Layers/glowLayer" {
  47168. import { Nullable } from "babylonjs/types";
  47169. import { Camera } from "babylonjs/Cameras/camera";
  47170. import { Scene } from "babylonjs/scene";
  47171. import { Color4 } from "babylonjs/Maths/math";
  47172. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47174. import { Mesh } from "babylonjs/Meshes/mesh";
  47175. import { Texture } from "babylonjs/Materials/Textures/texture";
  47176. import { Effect } from "babylonjs/Materials/effect";
  47177. import { Material } from "babylonjs/Materials/material";
  47178. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47179. import "babylonjs/Shaders/glowMapMerge.fragment";
  47180. import "babylonjs/Shaders/glowMapMerge.vertex";
  47181. import "babylonjs/Layers/effectLayerSceneComponent";
  47182. module "babylonjs/abstractScene" {
  47183. interface AbstractScene {
  47184. /**
  47185. * Return a the first highlight layer of the scene with a given name.
  47186. * @param name The name of the highlight layer to look for.
  47187. * @return The highlight layer if found otherwise null.
  47188. */
  47189. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47190. }
  47191. }
  47192. /**
  47193. * Glow layer options. This helps customizing the behaviour
  47194. * of the glow layer.
  47195. */
  47196. export interface IGlowLayerOptions {
  47197. /**
  47198. * Multiplication factor apply to the canvas size to compute the render target size
  47199. * used to generated the glowing objects (the smaller the faster).
  47200. */
  47201. mainTextureRatio: number;
  47202. /**
  47203. * Enforces a fixed size texture to ensure resize independant blur.
  47204. */
  47205. mainTextureFixedSize?: number;
  47206. /**
  47207. * How big is the kernel of the blur texture.
  47208. */
  47209. blurKernelSize: number;
  47210. /**
  47211. * The camera attached to the layer.
  47212. */
  47213. camera: Nullable<Camera>;
  47214. /**
  47215. * Enable MSAA by chosing the number of samples.
  47216. */
  47217. mainTextureSamples?: number;
  47218. /**
  47219. * The rendering group to draw the layer in.
  47220. */
  47221. renderingGroupId: number;
  47222. }
  47223. /**
  47224. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47225. *
  47226. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47227. * glowy meshes to your scene.
  47228. *
  47229. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47230. */
  47231. export class GlowLayer extends EffectLayer {
  47232. /**
  47233. * Effect Name of the layer.
  47234. */
  47235. static readonly EffectName: string;
  47236. /**
  47237. * The default blur kernel size used for the glow.
  47238. */
  47239. static DefaultBlurKernelSize: number;
  47240. /**
  47241. * The default texture size ratio used for the glow.
  47242. */
  47243. static DefaultTextureRatio: number;
  47244. /**
  47245. * Sets the kernel size of the blur.
  47246. */
  47247. /**
  47248. * Gets the kernel size of the blur.
  47249. */
  47250. blurKernelSize: number;
  47251. /**
  47252. * Sets the glow intensity.
  47253. */
  47254. /**
  47255. * Gets the glow intensity.
  47256. */
  47257. intensity: number;
  47258. private _options;
  47259. private _intensity;
  47260. private _horizontalBlurPostprocess1;
  47261. private _verticalBlurPostprocess1;
  47262. private _horizontalBlurPostprocess2;
  47263. private _verticalBlurPostprocess2;
  47264. private _blurTexture1;
  47265. private _blurTexture2;
  47266. private _postProcesses1;
  47267. private _postProcesses2;
  47268. private _includedOnlyMeshes;
  47269. private _excludedMeshes;
  47270. /**
  47271. * Callback used to let the user override the color selection on a per mesh basis
  47272. */
  47273. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47274. /**
  47275. * Callback used to let the user override the texture selection on a per mesh basis
  47276. */
  47277. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47278. /**
  47279. * Instantiates a new glow Layer and references it to the scene.
  47280. * @param name The name of the layer
  47281. * @param scene The scene to use the layer in
  47282. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47283. */
  47284. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47285. /**
  47286. * Get the effect name of the layer.
  47287. * @return The effect name
  47288. */
  47289. getEffectName(): string;
  47290. /**
  47291. * Create the merge effect. This is the shader use to blit the information back
  47292. * to the main canvas at the end of the scene rendering.
  47293. */
  47294. protected _createMergeEffect(): Effect;
  47295. /**
  47296. * Creates the render target textures and post processes used in the glow layer.
  47297. */
  47298. protected _createTextureAndPostProcesses(): void;
  47299. /**
  47300. * Checks for the readiness of the element composing the layer.
  47301. * @param subMesh the mesh to check for
  47302. * @param useInstances specify wether or not to use instances to render the mesh
  47303. * @param emissiveTexture the associated emissive texture used to generate the glow
  47304. * @return true if ready otherwise, false
  47305. */
  47306. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47307. /**
  47308. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47309. */
  47310. needStencil(): boolean;
  47311. /**
  47312. * Returns true if the mesh can be rendered, otherwise false.
  47313. * @param mesh The mesh to render
  47314. * @param material The material used on the mesh
  47315. * @returns true if it can be rendered otherwise false
  47316. */
  47317. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47318. /**
  47319. * Implementation specific of rendering the generating effect on the main canvas.
  47320. * @param effect The effect used to render through
  47321. */
  47322. protected _internalRender(effect: Effect): void;
  47323. /**
  47324. * Sets the required values for both the emissive texture and and the main color.
  47325. */
  47326. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47327. /**
  47328. * Returns true if the mesh should render, otherwise false.
  47329. * @param mesh The mesh to render
  47330. * @returns true if it should render otherwise false
  47331. */
  47332. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47333. /**
  47334. * Adds specific effects defines.
  47335. * @param defines The defines to add specifics to.
  47336. */
  47337. protected _addCustomEffectDefines(defines: string[]): void;
  47338. /**
  47339. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47340. * @param mesh The mesh to exclude from the glow layer
  47341. */
  47342. addExcludedMesh(mesh: Mesh): void;
  47343. /**
  47344. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47345. * @param mesh The mesh to remove
  47346. */
  47347. removeExcludedMesh(mesh: Mesh): void;
  47348. /**
  47349. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47350. * @param mesh The mesh to include in the glow layer
  47351. */
  47352. addIncludedOnlyMesh(mesh: Mesh): void;
  47353. /**
  47354. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47355. * @param mesh The mesh to remove
  47356. */
  47357. removeIncludedOnlyMesh(mesh: Mesh): void;
  47358. /**
  47359. * Determine if a given mesh will be used in the glow layer
  47360. * @param mesh The mesh to test
  47361. * @returns true if the mesh will be highlighted by the current glow layer
  47362. */
  47363. hasMesh(mesh: AbstractMesh): boolean;
  47364. /**
  47365. * Free any resources and references associated to a mesh.
  47366. * Internal use
  47367. * @param mesh The mesh to free.
  47368. * @hidden
  47369. */
  47370. _disposeMesh(mesh: Mesh): void;
  47371. /**
  47372. * Gets the class name of the effect layer
  47373. * @returns the string with the class name of the effect layer
  47374. */
  47375. getClassName(): string;
  47376. /**
  47377. * Serializes this glow layer
  47378. * @returns a serialized glow layer object
  47379. */
  47380. serialize(): any;
  47381. /**
  47382. * Creates a Glow Layer from parsed glow layer data
  47383. * @param parsedGlowLayer defines glow layer data
  47384. * @param scene defines the current scene
  47385. * @param rootUrl defines the root URL containing the glow layer information
  47386. * @returns a parsed Glow Layer
  47387. */
  47388. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47389. }
  47390. }
  47391. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  47392. /** @hidden */
  47393. export var glowBlurPostProcessPixelShader: {
  47394. name: string;
  47395. shader: string;
  47396. };
  47397. }
  47398. declare module "babylonjs/Layers/highlightLayer" {
  47399. import { Observable } from "babylonjs/Misc/observable";
  47400. import { Nullable } from "babylonjs/types";
  47401. import { Camera } from "babylonjs/Cameras/camera";
  47402. import { Scene } from "babylonjs/scene";
  47403. import { Color3, Color4 } from "babylonjs/Maths/math";
  47404. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47406. import { Mesh } from "babylonjs/Meshes/mesh";
  47407. import { Effect } from "babylonjs/Materials/effect";
  47408. import { Material } from "babylonjs/Materials/material";
  47409. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47410. import "babylonjs/Shaders/glowMapMerge.fragment";
  47411. import "babylonjs/Shaders/glowMapMerge.vertex";
  47412. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  47413. module "babylonjs/abstractScene" {
  47414. interface AbstractScene {
  47415. /**
  47416. * Return a the first highlight layer of the scene with a given name.
  47417. * @param name The name of the highlight layer to look for.
  47418. * @return The highlight layer if found otherwise null.
  47419. */
  47420. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47421. }
  47422. }
  47423. /**
  47424. * Highlight layer options. This helps customizing the behaviour
  47425. * of the highlight layer.
  47426. */
  47427. export interface IHighlightLayerOptions {
  47428. /**
  47429. * Multiplication factor apply to the canvas size to compute the render target size
  47430. * used to generated the glowing objects (the smaller the faster).
  47431. */
  47432. mainTextureRatio: number;
  47433. /**
  47434. * Enforces a fixed size texture to ensure resize independant blur.
  47435. */
  47436. mainTextureFixedSize?: number;
  47437. /**
  47438. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47439. * of the picture to blur (the smaller the faster).
  47440. */
  47441. blurTextureSizeRatio: number;
  47442. /**
  47443. * How big in texel of the blur texture is the vertical blur.
  47444. */
  47445. blurVerticalSize: number;
  47446. /**
  47447. * How big in texel of the blur texture is the horizontal blur.
  47448. */
  47449. blurHorizontalSize: number;
  47450. /**
  47451. * Alpha blending mode used to apply the blur. Default is combine.
  47452. */
  47453. alphaBlendingMode: number;
  47454. /**
  47455. * The camera attached to the layer.
  47456. */
  47457. camera: Nullable<Camera>;
  47458. /**
  47459. * Should we display highlight as a solid stroke?
  47460. */
  47461. isStroke?: boolean;
  47462. /**
  47463. * The rendering group to draw the layer in.
  47464. */
  47465. renderingGroupId: number;
  47466. }
  47467. /**
  47468. * The highlight layer Helps adding a glow effect around a mesh.
  47469. *
  47470. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47471. * glowy meshes to your scene.
  47472. *
  47473. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47474. */
  47475. export class HighlightLayer extends EffectLayer {
  47476. name: string;
  47477. /**
  47478. * Effect Name of the highlight layer.
  47479. */
  47480. static readonly EffectName: string;
  47481. /**
  47482. * The neutral color used during the preparation of the glow effect.
  47483. * This is black by default as the blend operation is a blend operation.
  47484. */
  47485. static NeutralColor: Color4;
  47486. /**
  47487. * Stencil value used for glowing meshes.
  47488. */
  47489. static GlowingMeshStencilReference: number;
  47490. /**
  47491. * Stencil value used for the other meshes in the scene.
  47492. */
  47493. static NormalMeshStencilReference: number;
  47494. /**
  47495. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47496. */
  47497. innerGlow: boolean;
  47498. /**
  47499. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47500. */
  47501. outerGlow: boolean;
  47502. /**
  47503. * Specifies the horizontal size of the blur.
  47504. */
  47505. /**
  47506. * Gets the horizontal size of the blur.
  47507. */
  47508. blurHorizontalSize: number;
  47509. /**
  47510. * Specifies the vertical size of the blur.
  47511. */
  47512. /**
  47513. * Gets the vertical size of the blur.
  47514. */
  47515. blurVerticalSize: number;
  47516. /**
  47517. * An event triggered when the highlight layer is being blurred.
  47518. */
  47519. onBeforeBlurObservable: Observable<HighlightLayer>;
  47520. /**
  47521. * An event triggered when the highlight layer has been blurred.
  47522. */
  47523. onAfterBlurObservable: Observable<HighlightLayer>;
  47524. private _instanceGlowingMeshStencilReference;
  47525. private _options;
  47526. private _downSamplePostprocess;
  47527. private _horizontalBlurPostprocess;
  47528. private _verticalBlurPostprocess;
  47529. private _blurTexture;
  47530. private _meshes;
  47531. private _excludedMeshes;
  47532. /**
  47533. * Instantiates a new highlight Layer and references it to the scene..
  47534. * @param name The name of the layer
  47535. * @param scene The scene to use the layer in
  47536. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47537. */
  47538. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47539. /**
  47540. * Get the effect name of the layer.
  47541. * @return The effect name
  47542. */
  47543. getEffectName(): string;
  47544. /**
  47545. * Create the merge effect. This is the shader use to blit the information back
  47546. * to the main canvas at the end of the scene rendering.
  47547. */
  47548. protected _createMergeEffect(): Effect;
  47549. /**
  47550. * Creates the render target textures and post processes used in the highlight layer.
  47551. */
  47552. protected _createTextureAndPostProcesses(): void;
  47553. /**
  47554. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47555. */
  47556. needStencil(): boolean;
  47557. /**
  47558. * Checks for the readiness of the element composing the layer.
  47559. * @param subMesh the mesh to check for
  47560. * @param useInstances specify wether or not to use instances to render the mesh
  47561. * @param emissiveTexture the associated emissive texture used to generate the glow
  47562. * @return true if ready otherwise, false
  47563. */
  47564. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47565. /**
  47566. * Implementation specific of rendering the generating effect on the main canvas.
  47567. * @param effect The effect used to render through
  47568. */
  47569. protected _internalRender(effect: Effect): void;
  47570. /**
  47571. * Returns true if the layer contains information to display, otherwise false.
  47572. */
  47573. shouldRender(): boolean;
  47574. /**
  47575. * Returns true if the mesh should render, otherwise false.
  47576. * @param mesh The mesh to render
  47577. * @returns true if it should render otherwise false
  47578. */
  47579. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47580. /**
  47581. * Sets the required values for both the emissive texture and and the main color.
  47582. */
  47583. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47584. /**
  47585. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47586. * @param mesh The mesh to exclude from the highlight layer
  47587. */
  47588. addExcludedMesh(mesh: Mesh): void;
  47589. /**
  47590. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47591. * @param mesh The mesh to highlight
  47592. */
  47593. removeExcludedMesh(mesh: Mesh): void;
  47594. /**
  47595. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47596. * @param mesh mesh to test
  47597. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47598. */
  47599. hasMesh(mesh: AbstractMesh): boolean;
  47600. /**
  47601. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47602. * @param mesh The mesh to highlight
  47603. * @param color The color of the highlight
  47604. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47605. */
  47606. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47607. /**
  47608. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47609. * @param mesh The mesh to highlight
  47610. */
  47611. removeMesh(mesh: Mesh): void;
  47612. /**
  47613. * Force the stencil to the normal expected value for none glowing parts
  47614. */
  47615. private _defaultStencilReference;
  47616. /**
  47617. * Free any resources and references associated to a mesh.
  47618. * Internal use
  47619. * @param mesh The mesh to free.
  47620. * @hidden
  47621. */
  47622. _disposeMesh(mesh: Mesh): void;
  47623. /**
  47624. * Dispose the highlight layer and free resources.
  47625. */
  47626. dispose(): void;
  47627. /**
  47628. * Gets the class name of the effect layer
  47629. * @returns the string with the class name of the effect layer
  47630. */
  47631. getClassName(): string;
  47632. /**
  47633. * Serializes this Highlight layer
  47634. * @returns a serialized Highlight layer object
  47635. */
  47636. serialize(): any;
  47637. /**
  47638. * Creates a Highlight layer from parsed Highlight layer data
  47639. * @param parsedHightlightLayer defines the Highlight layer data
  47640. * @param scene defines the current scene
  47641. * @param rootUrl defines the root URL containing the Highlight layer information
  47642. * @returns a parsed Highlight layer
  47643. */
  47644. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47645. }
  47646. }
  47647. declare module "babylonjs/Layers/index" {
  47648. export * from "babylonjs/Layers/effectLayer";
  47649. export * from "babylonjs/Layers/effectLayerSceneComponent";
  47650. export * from "babylonjs/Layers/glowLayer";
  47651. export * from "babylonjs/Layers/highlightLayer";
  47652. export * from "babylonjs/Layers/layer";
  47653. export * from "babylonjs/Layers/layerSceneComponent";
  47654. }
  47655. declare module "babylonjs/Shaders/lensFlare.fragment" {
  47656. /** @hidden */
  47657. export var lensFlarePixelShader: {
  47658. name: string;
  47659. shader: string;
  47660. };
  47661. }
  47662. declare module "babylonjs/Shaders/lensFlare.vertex" {
  47663. /** @hidden */
  47664. export var lensFlareVertexShader: {
  47665. name: string;
  47666. shader: string;
  47667. };
  47668. }
  47669. declare module "babylonjs/LensFlares/lensFlareSystem" {
  47670. import { Scene } from "babylonjs/scene";
  47671. import { Vector3, Viewport } from "babylonjs/Maths/math";
  47672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47673. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  47674. import "babylonjs/Shaders/lensFlare.fragment";
  47675. import "babylonjs/Shaders/lensFlare.vertex";
  47676. /**
  47677. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47678. * It is usually composed of several `lensFlare`.
  47679. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47680. */
  47681. export class LensFlareSystem {
  47682. /**
  47683. * Define the name of the lens flare system
  47684. */
  47685. name: string;
  47686. /**
  47687. * List of lens flares used in this system.
  47688. */
  47689. lensFlares: LensFlare[];
  47690. /**
  47691. * Define a limit from the border the lens flare can be visible.
  47692. */
  47693. borderLimit: number;
  47694. /**
  47695. * Define a viewport border we do not want to see the lens flare in.
  47696. */
  47697. viewportBorder: number;
  47698. /**
  47699. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47700. */
  47701. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47702. /**
  47703. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47704. */
  47705. layerMask: number;
  47706. /**
  47707. * Define the id of the lens flare system in the scene.
  47708. * (equal to name by default)
  47709. */
  47710. id: string;
  47711. private _scene;
  47712. private _emitter;
  47713. private _vertexBuffers;
  47714. private _indexBuffer;
  47715. private _effect;
  47716. private _positionX;
  47717. private _positionY;
  47718. private _isEnabled;
  47719. /** @hidden */
  47720. static _SceneComponentInitialization: (scene: Scene) => void;
  47721. /**
  47722. * Instantiates a lens flare system.
  47723. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47724. * It is usually composed of several `lensFlare`.
  47725. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47726. * @param name Define the name of the lens flare system in the scene
  47727. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47728. * @param scene Define the scene the lens flare system belongs to
  47729. */
  47730. constructor(
  47731. /**
  47732. * Define the name of the lens flare system
  47733. */
  47734. name: string, emitter: any, scene: Scene);
  47735. /**
  47736. * Define if the lens flare system is enabled.
  47737. */
  47738. isEnabled: boolean;
  47739. /**
  47740. * Get the scene the effects belongs to.
  47741. * @returns the scene holding the lens flare system
  47742. */
  47743. getScene(): Scene;
  47744. /**
  47745. * Get the emitter of the lens flare system.
  47746. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47747. * @returns the emitter of the lens flare system
  47748. */
  47749. getEmitter(): any;
  47750. /**
  47751. * Set the emitter of the lens flare system.
  47752. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47753. * @param newEmitter Define the new emitter of the system
  47754. */
  47755. setEmitter(newEmitter: any): void;
  47756. /**
  47757. * Get the lens flare system emitter position.
  47758. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47759. * @returns the position
  47760. */
  47761. getEmitterPosition(): Vector3;
  47762. /**
  47763. * @hidden
  47764. */
  47765. computeEffectivePosition(globalViewport: Viewport): boolean;
  47766. /** @hidden */
  47767. _isVisible(): boolean;
  47768. /**
  47769. * @hidden
  47770. */
  47771. render(): boolean;
  47772. /**
  47773. * Dispose and release the lens flare with its associated resources.
  47774. */
  47775. dispose(): void;
  47776. /**
  47777. * Parse a lens flare system from a JSON repressentation
  47778. * @param parsedLensFlareSystem Define the JSON to parse
  47779. * @param scene Define the scene the parsed system should be instantiated in
  47780. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47781. * @returns the parsed system
  47782. */
  47783. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47784. /**
  47785. * Serialize the current Lens Flare System into a JSON representation.
  47786. * @returns the serialized JSON
  47787. */
  47788. serialize(): any;
  47789. }
  47790. }
  47791. declare module "babylonjs/LensFlares/lensFlare" {
  47792. import { Nullable } from "babylonjs/types";
  47793. import { Color3 } from "babylonjs/Maths/math";
  47794. import { Texture } from "babylonjs/Materials/Textures/texture";
  47795. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47796. /**
  47797. * This represents one of the lens effect in a `lensFlareSystem`.
  47798. * It controls one of the indiviual texture used in the effect.
  47799. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47800. */
  47801. export class LensFlare {
  47802. /**
  47803. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47804. */
  47805. size: number;
  47806. /**
  47807. * 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.
  47808. */
  47809. position: number;
  47810. /**
  47811. * Define the lens color.
  47812. */
  47813. color: Color3;
  47814. /**
  47815. * Define the lens texture.
  47816. */
  47817. texture: Nullable<Texture>;
  47818. /**
  47819. * Define the alpha mode to render this particular lens.
  47820. */
  47821. alphaMode: number;
  47822. private _system;
  47823. /**
  47824. * Creates a new Lens Flare.
  47825. * This represents one of the lens effect in a `lensFlareSystem`.
  47826. * It controls one of the indiviual texture used in the effect.
  47827. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47828. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47829. * @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.
  47830. * @param color Define the lens color
  47831. * @param imgUrl Define the lens texture url
  47832. * @param system Define the `lensFlareSystem` this flare is part of
  47833. * @returns The newly created Lens Flare
  47834. */
  47835. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47836. /**
  47837. * Instantiates a new Lens Flare.
  47838. * This represents one of the lens effect in a `lensFlareSystem`.
  47839. * It controls one of the indiviual texture used in the effect.
  47840. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47841. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47842. * @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.
  47843. * @param color Define the lens color
  47844. * @param imgUrl Define the lens texture url
  47845. * @param system Define the `lensFlareSystem` this flare is part of
  47846. */
  47847. constructor(
  47848. /**
  47849. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47850. */
  47851. size: number,
  47852. /**
  47853. * 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.
  47854. */
  47855. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47856. /**
  47857. * Dispose and release the lens flare with its associated resources.
  47858. */
  47859. dispose(): void;
  47860. }
  47861. }
  47862. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  47863. import { Nullable } from "babylonjs/types";
  47864. import { Scene } from "babylonjs/scene";
  47865. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47866. import { AbstractScene } from "babylonjs/abstractScene";
  47867. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47868. module "babylonjs/abstractScene" {
  47869. interface AbstractScene {
  47870. /**
  47871. * The list of lens flare system added to the scene
  47872. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47873. */
  47874. lensFlareSystems: Array<LensFlareSystem>;
  47875. /**
  47876. * Removes the given lens flare system from this scene.
  47877. * @param toRemove The lens flare system to remove
  47878. * @returns The index of the removed lens flare system
  47879. */
  47880. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47881. /**
  47882. * Adds the given lens flare system to this scene
  47883. * @param newLensFlareSystem The lens flare system to add
  47884. */
  47885. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47886. /**
  47887. * Gets a lens flare system using its name
  47888. * @param name defines the name to look for
  47889. * @returns the lens flare system or null if not found
  47890. */
  47891. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47892. /**
  47893. * Gets a lens flare system using its id
  47894. * @param id defines the id to look for
  47895. * @returns the lens flare system or null if not found
  47896. */
  47897. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47898. }
  47899. }
  47900. /**
  47901. * Defines the lens flare scene component responsible to manage any lens flares
  47902. * in a given scene.
  47903. */
  47904. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47905. /**
  47906. * The component name helpfull to identify the component in the list of scene components.
  47907. */
  47908. readonly name: string;
  47909. /**
  47910. * The scene the component belongs to.
  47911. */
  47912. scene: Scene;
  47913. /**
  47914. * Creates a new instance of the component for the given scene
  47915. * @param scene Defines the scene to register the component in
  47916. */
  47917. constructor(scene: Scene);
  47918. /**
  47919. * Registers the component in a given scene
  47920. */
  47921. register(): void;
  47922. /**
  47923. * Rebuilds the elements related to this component in case of
  47924. * context lost for instance.
  47925. */
  47926. rebuild(): void;
  47927. /**
  47928. * Adds all the element from the container to the scene
  47929. * @param container the container holding the elements
  47930. */
  47931. addFromContainer(container: AbstractScene): void;
  47932. /**
  47933. * Removes all the elements in the container from the scene
  47934. * @param container contains the elements to remove
  47935. */
  47936. removeFromContainer(container: AbstractScene): void;
  47937. /**
  47938. * Serializes the component data to the specified json object
  47939. * @param serializationObject The object to serialize to
  47940. */
  47941. serialize(serializationObject: any): void;
  47942. /**
  47943. * Disposes the component and the associated ressources.
  47944. */
  47945. dispose(): void;
  47946. private _draw;
  47947. }
  47948. }
  47949. declare module "babylonjs/LensFlares/index" {
  47950. export * from "babylonjs/LensFlares/lensFlare";
  47951. export * from "babylonjs/LensFlares/lensFlareSystem";
  47952. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  47953. }
  47954. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  47955. import { Scene } from "babylonjs/scene";
  47956. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47957. import { AbstractScene } from "babylonjs/abstractScene";
  47958. /**
  47959. * Defines the shadow generator component responsible to manage any shadow generators
  47960. * in a given scene.
  47961. */
  47962. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47963. /**
  47964. * The component name helpfull to identify the component in the list of scene components.
  47965. */
  47966. readonly name: string;
  47967. /**
  47968. * The scene the component belongs to.
  47969. */
  47970. scene: Scene;
  47971. /**
  47972. * Creates a new instance of the component for the given scene
  47973. * @param scene Defines the scene to register the component in
  47974. */
  47975. constructor(scene: Scene);
  47976. /**
  47977. * Registers the component in a given scene
  47978. */
  47979. register(): void;
  47980. /**
  47981. * Rebuilds the elements related to this component in case of
  47982. * context lost for instance.
  47983. */
  47984. rebuild(): void;
  47985. /**
  47986. * Serializes the component data to the specified json object
  47987. * @param serializationObject The object to serialize to
  47988. */
  47989. serialize(serializationObject: any): void;
  47990. /**
  47991. * Adds all the element from the container to the scene
  47992. * @param container the container holding the elements
  47993. */
  47994. addFromContainer(container: AbstractScene): void;
  47995. /**
  47996. * Removes all the elements in the container from the scene
  47997. * @param container contains the elements to remove
  47998. */
  47999. removeFromContainer(container: AbstractScene): void;
  48000. /**
  48001. * Rebuilds the elements related to this component in case of
  48002. * context lost for instance.
  48003. */
  48004. dispose(): void;
  48005. private _gatherRenderTargets;
  48006. }
  48007. }
  48008. declare module "babylonjs/Lights/Shadows/index" {
  48009. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  48010. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  48011. }
  48012. declare module "babylonjs/Lights/directionalLight" {
  48013. import { Camera } from "babylonjs/Cameras/camera";
  48014. import { Scene } from "babylonjs/scene";
  48015. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48016. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48017. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48018. import { Effect } from "babylonjs/Materials/effect";
  48019. /**
  48020. * A directional light is defined by a direction (what a surprise!).
  48021. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48022. * 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.
  48023. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48024. */
  48025. export class DirectionalLight extends ShadowLight {
  48026. private _shadowFrustumSize;
  48027. /**
  48028. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48029. */
  48030. /**
  48031. * Specifies a fix frustum size for the shadow generation.
  48032. */
  48033. shadowFrustumSize: number;
  48034. private _shadowOrthoScale;
  48035. /**
  48036. * Gets the shadow projection scale against the optimal computed one.
  48037. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48038. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48039. */
  48040. /**
  48041. * Sets the shadow projection scale against the optimal computed one.
  48042. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48043. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48044. */
  48045. shadowOrthoScale: number;
  48046. /**
  48047. * Automatically compute the projection matrix to best fit (including all the casters)
  48048. * on each frame.
  48049. */
  48050. autoUpdateExtends: boolean;
  48051. private _orthoLeft;
  48052. private _orthoRight;
  48053. private _orthoTop;
  48054. private _orthoBottom;
  48055. /**
  48056. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48057. * The directional light is emitted from everywhere in the given direction.
  48058. * It can cast shadows.
  48059. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48060. * @param name The friendly name of the light
  48061. * @param direction The direction of the light
  48062. * @param scene The scene the light belongs to
  48063. */
  48064. constructor(name: string, direction: Vector3, scene: Scene);
  48065. /**
  48066. * Returns the string "DirectionalLight".
  48067. * @return The class name
  48068. */
  48069. getClassName(): string;
  48070. /**
  48071. * Returns the integer 1.
  48072. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48073. */
  48074. getTypeID(): number;
  48075. /**
  48076. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48077. * Returns the DirectionalLight Shadow projection matrix.
  48078. */
  48079. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48080. /**
  48081. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48082. * Returns the DirectionalLight Shadow projection matrix.
  48083. */
  48084. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48085. /**
  48086. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48087. * Returns the DirectionalLight Shadow projection matrix.
  48088. */
  48089. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48090. protected _buildUniformLayout(): void;
  48091. /**
  48092. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48093. * @param effect The effect to update
  48094. * @param lightIndex The index of the light in the effect to update
  48095. * @returns The directional light
  48096. */
  48097. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48098. /**
  48099. * Gets the minZ used for shadow according to both the scene and the light.
  48100. *
  48101. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48102. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48103. * @param activeCamera The camera we are returning the min for
  48104. * @returns the depth min z
  48105. */
  48106. getDepthMinZ(activeCamera: Camera): number;
  48107. /**
  48108. * Gets the maxZ used for shadow according to both the scene and the light.
  48109. *
  48110. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48111. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48112. * @param activeCamera The camera we are returning the max for
  48113. * @returns the depth max z
  48114. */
  48115. getDepthMaxZ(activeCamera: Camera): number;
  48116. /**
  48117. * Prepares the list of defines specific to the light type.
  48118. * @param defines the list of defines
  48119. * @param lightIndex defines the index of the light for the effect
  48120. */
  48121. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48122. }
  48123. }
  48124. declare module "babylonjs/Lights/pointLight" {
  48125. import { Scene } from "babylonjs/scene";
  48126. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48128. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48129. import { Effect } from "babylonjs/Materials/effect";
  48130. /**
  48131. * A point light is a light defined by an unique point in world space.
  48132. * The light is emitted in every direction from this point.
  48133. * A good example of a point light is a standard light bulb.
  48134. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48135. */
  48136. export class PointLight extends ShadowLight {
  48137. private _shadowAngle;
  48138. /**
  48139. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48140. * This specifies what angle the shadow will use to be created.
  48141. *
  48142. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48143. */
  48144. /**
  48145. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48146. * This specifies what angle the shadow will use to be created.
  48147. *
  48148. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48149. */
  48150. shadowAngle: number;
  48151. /**
  48152. * Gets the direction if it has been set.
  48153. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48154. */
  48155. /**
  48156. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48157. */
  48158. direction: Vector3;
  48159. /**
  48160. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48161. * A PointLight emits the light in every direction.
  48162. * It can cast shadows.
  48163. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48164. * ```javascript
  48165. * var pointLight = new PointLight("pl", camera.position, scene);
  48166. * ```
  48167. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48168. * @param name The light friendly name
  48169. * @param position The position of the point light in the scene
  48170. * @param scene The scene the lights belongs to
  48171. */
  48172. constructor(name: string, position: Vector3, scene: Scene);
  48173. /**
  48174. * Returns the string "PointLight"
  48175. * @returns the class name
  48176. */
  48177. getClassName(): string;
  48178. /**
  48179. * Returns the integer 0.
  48180. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48181. */
  48182. getTypeID(): number;
  48183. /**
  48184. * Specifies wether or not the shadowmap should be a cube texture.
  48185. * @returns true if the shadowmap needs to be a cube texture.
  48186. */
  48187. needCube(): boolean;
  48188. /**
  48189. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48190. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48191. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48192. */
  48193. getShadowDirection(faceIndex?: number): Vector3;
  48194. /**
  48195. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48196. * - fov = PI / 2
  48197. * - aspect ratio : 1.0
  48198. * - z-near and far equal to the active camera minZ and maxZ.
  48199. * Returns the PointLight.
  48200. */
  48201. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48202. protected _buildUniformLayout(): void;
  48203. /**
  48204. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48205. * @param effect The effect to update
  48206. * @param lightIndex The index of the light in the effect to update
  48207. * @returns The point light
  48208. */
  48209. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48210. /**
  48211. * Prepares the list of defines specific to the light type.
  48212. * @param defines the list of defines
  48213. * @param lightIndex defines the index of the light for the effect
  48214. */
  48215. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48216. }
  48217. }
  48218. declare module "babylonjs/Lights/spotLight" {
  48219. import { Nullable } from "babylonjs/types";
  48220. import { Scene } from "babylonjs/scene";
  48221. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48223. import { Effect } from "babylonjs/Materials/effect";
  48224. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48225. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48226. /**
  48227. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48228. * These values define a cone of light starting from the position, emitting toward the direction.
  48229. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48230. * and the exponent defines the speed of the decay of the light with distance (reach).
  48231. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48232. */
  48233. export class SpotLight extends ShadowLight {
  48234. private _angle;
  48235. private _innerAngle;
  48236. private _cosHalfAngle;
  48237. private _lightAngleScale;
  48238. private _lightAngleOffset;
  48239. /**
  48240. * Gets the cone angle of the spot light in Radians.
  48241. */
  48242. /**
  48243. * Sets the cone angle of the spot light in Radians.
  48244. */
  48245. angle: number;
  48246. /**
  48247. * Only used in gltf falloff mode, this defines the angle where
  48248. * the directional falloff will start before cutting at angle which could be seen
  48249. * as outer angle.
  48250. */
  48251. /**
  48252. * Only used in gltf falloff mode, this defines the angle where
  48253. * the directional falloff will start before cutting at angle which could be seen
  48254. * as outer angle.
  48255. */
  48256. innerAngle: number;
  48257. private _shadowAngleScale;
  48258. /**
  48259. * Allows scaling the angle of the light for shadow generation only.
  48260. */
  48261. /**
  48262. * Allows scaling the angle of the light for shadow generation only.
  48263. */
  48264. shadowAngleScale: number;
  48265. /**
  48266. * The light decay speed with the distance from the emission spot.
  48267. */
  48268. exponent: number;
  48269. private _projectionTextureMatrix;
  48270. /**
  48271. * Allows reading the projecton texture
  48272. */
  48273. readonly projectionTextureMatrix: Matrix;
  48274. protected _projectionTextureLightNear: number;
  48275. /**
  48276. * Gets the near clip of the Spotlight for texture projection.
  48277. */
  48278. /**
  48279. * Sets the near clip of the Spotlight for texture projection.
  48280. */
  48281. projectionTextureLightNear: number;
  48282. protected _projectionTextureLightFar: number;
  48283. /**
  48284. * Gets the far clip of the Spotlight for texture projection.
  48285. */
  48286. /**
  48287. * Sets the far clip of the Spotlight for texture projection.
  48288. */
  48289. projectionTextureLightFar: number;
  48290. protected _projectionTextureUpDirection: Vector3;
  48291. /**
  48292. * Gets the Up vector of the Spotlight for texture projection.
  48293. */
  48294. /**
  48295. * Sets the Up vector of the Spotlight for texture projection.
  48296. */
  48297. projectionTextureUpDirection: Vector3;
  48298. private _projectionTexture;
  48299. /**
  48300. * Gets the projection texture of the light.
  48301. */
  48302. /**
  48303. * Sets the projection texture of the light.
  48304. */
  48305. projectionTexture: Nullable<BaseTexture>;
  48306. private _projectionTextureViewLightDirty;
  48307. private _projectionTextureProjectionLightDirty;
  48308. private _projectionTextureDirty;
  48309. private _projectionTextureViewTargetVector;
  48310. private _projectionTextureViewLightMatrix;
  48311. private _projectionTextureProjectionLightMatrix;
  48312. private _projectionTextureScalingMatrix;
  48313. /**
  48314. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48315. * It can cast shadows.
  48316. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48317. * @param name The light friendly name
  48318. * @param position The position of the spot light in the scene
  48319. * @param direction The direction of the light in the scene
  48320. * @param angle The cone angle of the light in Radians
  48321. * @param exponent The light decay speed with the distance from the emission spot
  48322. * @param scene The scene the lights belongs to
  48323. */
  48324. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48325. /**
  48326. * Returns the string "SpotLight".
  48327. * @returns the class name
  48328. */
  48329. getClassName(): string;
  48330. /**
  48331. * Returns the integer 2.
  48332. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48333. */
  48334. getTypeID(): number;
  48335. /**
  48336. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48337. */
  48338. protected _setDirection(value: Vector3): void;
  48339. /**
  48340. * Overrides the position setter to recompute the projection texture view light Matrix.
  48341. */
  48342. protected _setPosition(value: Vector3): void;
  48343. /**
  48344. * 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.
  48345. * Returns the SpotLight.
  48346. */
  48347. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48348. protected _computeProjectionTextureViewLightMatrix(): void;
  48349. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48350. /**
  48351. * Main function for light texture projection matrix computing.
  48352. */
  48353. protected _computeProjectionTextureMatrix(): void;
  48354. protected _buildUniformLayout(): void;
  48355. private _computeAngleValues;
  48356. /**
  48357. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48358. * @param effect The effect to update
  48359. * @param lightIndex The index of the light in the effect to update
  48360. * @returns The spot light
  48361. */
  48362. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48363. /**
  48364. * Disposes the light and the associated resources.
  48365. */
  48366. dispose(): void;
  48367. /**
  48368. * Prepares the list of defines specific to the light type.
  48369. * @param defines the list of defines
  48370. * @param lightIndex defines the index of the light for the effect
  48371. */
  48372. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48373. }
  48374. }
  48375. declare module "babylonjs/Lights/index" {
  48376. export * from "babylonjs/Lights/light";
  48377. export * from "babylonjs/Lights/shadowLight";
  48378. export * from "babylonjs/Lights/Shadows/index";
  48379. export * from "babylonjs/Lights/directionalLight";
  48380. export * from "babylonjs/Lights/hemisphericLight";
  48381. export * from "babylonjs/Lights/pointLight";
  48382. export * from "babylonjs/Lights/spotLight";
  48383. }
  48384. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  48385. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48386. /**
  48387. * Header information of HDR texture files.
  48388. */
  48389. export interface HDRInfo {
  48390. /**
  48391. * The height of the texture in pixels.
  48392. */
  48393. height: number;
  48394. /**
  48395. * The width of the texture in pixels.
  48396. */
  48397. width: number;
  48398. /**
  48399. * The index of the beginning of the data in the binary file.
  48400. */
  48401. dataPosition: number;
  48402. }
  48403. /**
  48404. * This groups tools to convert HDR texture to native colors array.
  48405. */
  48406. export class HDRTools {
  48407. private static Ldexp;
  48408. private static Rgbe2float;
  48409. private static readStringLine;
  48410. /**
  48411. * Reads header information from an RGBE texture stored in a native array.
  48412. * More information on this format are available here:
  48413. * https://en.wikipedia.org/wiki/RGBE_image_format
  48414. *
  48415. * @param uint8array The binary file stored in native array.
  48416. * @return The header information.
  48417. */
  48418. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48419. /**
  48420. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48421. * This RGBE texture needs to store the information as a panorama.
  48422. *
  48423. * More information on this format are available here:
  48424. * https://en.wikipedia.org/wiki/RGBE_image_format
  48425. *
  48426. * @param buffer The binary file stored in an array buffer.
  48427. * @param size The expected size of the extracted cubemap.
  48428. * @return The Cube Map information.
  48429. */
  48430. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48431. /**
  48432. * Returns the pixels data extracted from an RGBE texture.
  48433. * This pixels will be stored left to right up to down in the R G B order in one array.
  48434. *
  48435. * More information on this format are available here:
  48436. * https://en.wikipedia.org/wiki/RGBE_image_format
  48437. *
  48438. * @param uint8array The binary file stored in an array buffer.
  48439. * @param hdrInfo The header information of the file.
  48440. * @return The pixels data in RGB right to left up to down order.
  48441. */
  48442. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48443. private static RGBE_ReadPixels_RLE;
  48444. }
  48445. }
  48446. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  48447. import { Nullable } from "babylonjs/types";
  48448. import { Scene } from "babylonjs/scene";
  48449. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48450. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48451. /**
  48452. * This represents a texture coming from an HDR input.
  48453. *
  48454. * The only supported format is currently panorama picture stored in RGBE format.
  48455. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48456. */
  48457. export class HDRCubeTexture extends BaseTexture {
  48458. private static _facesMapping;
  48459. private _generateHarmonics;
  48460. private _noMipmap;
  48461. private _textureMatrix;
  48462. private _size;
  48463. private _onLoad;
  48464. private _onError;
  48465. /**
  48466. * The texture URL.
  48467. */
  48468. url: string;
  48469. /**
  48470. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48471. */
  48472. coordinatesMode: number;
  48473. protected _isBlocking: boolean;
  48474. /**
  48475. * Sets wether or not the texture is blocking during loading.
  48476. */
  48477. /**
  48478. * Gets wether or not the texture is blocking during loading.
  48479. */
  48480. isBlocking: boolean;
  48481. protected _rotationY: number;
  48482. /**
  48483. * Sets texture matrix rotation angle around Y axis in radians.
  48484. */
  48485. /**
  48486. * Gets texture matrix rotation angle around Y axis radians.
  48487. */
  48488. rotationY: number;
  48489. /**
  48490. * Gets or sets the center of the bounding box associated with the cube texture
  48491. * It must define where the camera used to render the texture was set
  48492. */
  48493. boundingBoxPosition: Vector3;
  48494. private _boundingBoxSize;
  48495. /**
  48496. * Gets or sets the size of the bounding box associated with the cube texture
  48497. * When defined, the cubemap will switch to local mode
  48498. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48499. * @example https://www.babylonjs-playground.com/#RNASML
  48500. */
  48501. boundingBoxSize: Vector3;
  48502. /**
  48503. * Instantiates an HDRTexture from the following parameters.
  48504. *
  48505. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48506. * @param scene The scene the texture will be used in
  48507. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48508. * @param noMipmap Forces to not generate the mipmap if true
  48509. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48510. * @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)
  48511. * @param reserved Reserved flag for internal use.
  48512. */
  48513. 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>);
  48514. /**
  48515. * Get the current class name of the texture useful for serialization or dynamic coding.
  48516. * @returns "HDRCubeTexture"
  48517. */
  48518. getClassName(): string;
  48519. /**
  48520. * Occurs when the file is raw .hdr file.
  48521. */
  48522. private loadTexture;
  48523. clone(): HDRCubeTexture;
  48524. delayLoad(): void;
  48525. /**
  48526. * Get the texture reflection matrix used to rotate/transform the reflection.
  48527. * @returns the reflection matrix
  48528. */
  48529. getReflectionTextureMatrix(): Matrix;
  48530. /**
  48531. * Set the texture reflection matrix used to rotate/transform the reflection.
  48532. * @param value Define the reflection matrix to set
  48533. */
  48534. setReflectionTextureMatrix(value: Matrix): void;
  48535. /**
  48536. * Parses a JSON representation of an HDR Texture in order to create the texture
  48537. * @param parsedTexture Define the JSON representation
  48538. * @param scene Define the scene the texture should be created in
  48539. * @param rootUrl Define the root url in case we need to load relative dependencies
  48540. * @returns the newly created texture after parsing
  48541. */
  48542. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48543. serialize(): any;
  48544. }
  48545. }
  48546. declare module "babylonjs/Physics/physicsEngine" {
  48547. import { Nullable } from "babylonjs/types";
  48548. import { Vector3 } from "babylonjs/Maths/math";
  48549. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48550. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  48551. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  48552. /**
  48553. * Class used to control physics engine
  48554. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48555. */
  48556. export class PhysicsEngine implements IPhysicsEngine {
  48557. private _physicsPlugin;
  48558. /**
  48559. * Global value used to control the smallest number supported by the simulation
  48560. */
  48561. static Epsilon: number;
  48562. private _impostors;
  48563. private _joints;
  48564. /**
  48565. * Gets the gravity vector used by the simulation
  48566. */
  48567. gravity: Vector3;
  48568. /**
  48569. * Factory used to create the default physics plugin.
  48570. * @returns The default physics plugin
  48571. */
  48572. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48573. /**
  48574. * Creates a new Physics Engine
  48575. * @param gravity defines the gravity vector used by the simulation
  48576. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48577. */
  48578. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48579. /**
  48580. * Sets the gravity vector used by the simulation
  48581. * @param gravity defines the gravity vector to use
  48582. */
  48583. setGravity(gravity: Vector3): void;
  48584. /**
  48585. * Set the time step of the physics engine.
  48586. * Default is 1/60.
  48587. * To slow it down, enter 1/600 for example.
  48588. * To speed it up, 1/30
  48589. * @param newTimeStep defines the new timestep to apply to this world.
  48590. */
  48591. setTimeStep(newTimeStep?: number): void;
  48592. /**
  48593. * Get the time step of the physics engine.
  48594. * @returns the current time step
  48595. */
  48596. getTimeStep(): number;
  48597. /**
  48598. * Release all resources
  48599. */
  48600. dispose(): void;
  48601. /**
  48602. * Gets the name of the current physics plugin
  48603. * @returns the name of the plugin
  48604. */
  48605. getPhysicsPluginName(): string;
  48606. /**
  48607. * Adding a new impostor for the impostor tracking.
  48608. * This will be done by the impostor itself.
  48609. * @param impostor the impostor to add
  48610. */
  48611. addImpostor(impostor: PhysicsImpostor): void;
  48612. /**
  48613. * Remove an impostor from the engine.
  48614. * This impostor and its mesh will not longer be updated by the physics engine.
  48615. * @param impostor the impostor to remove
  48616. */
  48617. removeImpostor(impostor: PhysicsImpostor): void;
  48618. /**
  48619. * Add a joint to the physics engine
  48620. * @param mainImpostor defines the main impostor to which the joint is added.
  48621. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48622. * @param joint defines the joint that will connect both impostors.
  48623. */
  48624. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48625. /**
  48626. * Removes a joint from the simulation
  48627. * @param mainImpostor defines the impostor used with the joint
  48628. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48629. * @param joint defines the joint to remove
  48630. */
  48631. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48632. /**
  48633. * Called by the scene. No need to call it.
  48634. * @param delta defines the timespam between frames
  48635. */
  48636. _step(delta: number): void;
  48637. /**
  48638. * Gets the current plugin used to run the simulation
  48639. * @returns current plugin
  48640. */
  48641. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48642. /**
  48643. * Gets the list of physic impostors
  48644. * @returns an array of PhysicsImpostor
  48645. */
  48646. getImpostors(): Array<PhysicsImpostor>;
  48647. /**
  48648. * Gets the impostor for a physics enabled object
  48649. * @param object defines the object impersonated by the impostor
  48650. * @returns the PhysicsImpostor or null if not found
  48651. */
  48652. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48653. /**
  48654. * Gets the impostor for a physics body object
  48655. * @param body defines physics body used by the impostor
  48656. * @returns the PhysicsImpostor or null if not found
  48657. */
  48658. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48659. }
  48660. }
  48661. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  48662. import { Nullable } from "babylonjs/types";
  48663. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  48664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48665. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  48666. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48667. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  48668. /** @hidden */
  48669. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48670. private _useDeltaForWorldStep;
  48671. world: any;
  48672. name: string;
  48673. private _physicsMaterials;
  48674. private _fixedTimeStep;
  48675. BJSCANNON: any;
  48676. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48677. setGravity(gravity: Vector3): void;
  48678. setTimeStep(timeStep: number): void;
  48679. getTimeStep(): number;
  48680. executeStep(delta: number): void;
  48681. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48682. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48683. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48684. private _processChildMeshes;
  48685. removePhysicsBody(impostor: PhysicsImpostor): void;
  48686. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48687. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48688. private _addMaterial;
  48689. private _checkWithEpsilon;
  48690. private _createShape;
  48691. private _createHeightmap;
  48692. private _minus90X;
  48693. private _plus90X;
  48694. private _tmpPosition;
  48695. private _tmpDeltaPosition;
  48696. private _tmpUnityRotation;
  48697. private _updatePhysicsBodyTransformation;
  48698. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48699. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48700. isSupported(): boolean;
  48701. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48702. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48703. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48704. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48705. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48706. getBodyMass(impostor: PhysicsImpostor): number;
  48707. getBodyFriction(impostor: PhysicsImpostor): number;
  48708. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48709. getBodyRestitution(impostor: PhysicsImpostor): number;
  48710. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48711. sleepBody(impostor: PhysicsImpostor): void;
  48712. wakeUpBody(impostor: PhysicsImpostor): void;
  48713. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48714. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48715. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48716. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48717. getRadius(impostor: PhysicsImpostor): number;
  48718. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48719. dispose(): void;
  48720. private _extendNamespace;
  48721. }
  48722. }
  48723. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  48724. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  48725. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48726. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  48727. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48728. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  48729. import { Nullable } from "babylonjs/types";
  48730. /** @hidden */
  48731. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48732. world: any;
  48733. name: string;
  48734. BJSOIMO: any;
  48735. constructor(iterations?: number, oimoInjection?: any);
  48736. setGravity(gravity: Vector3): void;
  48737. setTimeStep(timeStep: number): void;
  48738. getTimeStep(): number;
  48739. private _tmpImpostorsArray;
  48740. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48741. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48742. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48743. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48744. private _tmpPositionVector;
  48745. removePhysicsBody(impostor: PhysicsImpostor): void;
  48746. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48747. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48748. isSupported(): boolean;
  48749. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48750. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48751. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48752. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48753. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48754. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48755. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48756. getBodyMass(impostor: PhysicsImpostor): number;
  48757. getBodyFriction(impostor: PhysicsImpostor): number;
  48758. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48759. getBodyRestitution(impostor: PhysicsImpostor): number;
  48760. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48761. sleepBody(impostor: PhysicsImpostor): void;
  48762. wakeUpBody(impostor: PhysicsImpostor): void;
  48763. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48764. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48765. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48766. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48767. getRadius(impostor: PhysicsImpostor): number;
  48768. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48769. dispose(): void;
  48770. }
  48771. }
  48772. declare module "babylonjs/Probes/reflectionProbe" {
  48773. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48774. import { Vector3 } from "babylonjs/Maths/math";
  48775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48776. import { Nullable } from "babylonjs/types";
  48777. import { Scene } from "babylonjs/scene";
  48778. module "babylonjs/abstractScene" {
  48779. interface AbstractScene {
  48780. /**
  48781. * The list of reflection probes added to the scene
  48782. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48783. */
  48784. reflectionProbes: Array<ReflectionProbe>;
  48785. /**
  48786. * Removes the given reflection probe from this scene.
  48787. * @param toRemove The reflection probe to remove
  48788. * @returns The index of the removed reflection probe
  48789. */
  48790. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48791. /**
  48792. * Adds the given reflection probe to this scene.
  48793. * @param newReflectionProbe The reflection probe to add
  48794. */
  48795. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48796. }
  48797. }
  48798. /**
  48799. * Class used to generate realtime reflection / refraction cube textures
  48800. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48801. */
  48802. export class ReflectionProbe {
  48803. /** defines the name of the probe */
  48804. name: string;
  48805. private _scene;
  48806. private _renderTargetTexture;
  48807. private _projectionMatrix;
  48808. private _viewMatrix;
  48809. private _target;
  48810. private _add;
  48811. private _attachedMesh;
  48812. private _invertYAxis;
  48813. /** Gets or sets probe position (center of the cube map) */
  48814. position: Vector3;
  48815. /**
  48816. * Creates a new reflection probe
  48817. * @param name defines the name of the probe
  48818. * @param size defines the texture resolution (for each face)
  48819. * @param scene defines the hosting scene
  48820. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48821. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48822. */
  48823. constructor(
  48824. /** defines the name of the probe */
  48825. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48826. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48827. samples: number;
  48828. /** Gets or sets the refresh rate to use (on every frame by default) */
  48829. refreshRate: number;
  48830. /**
  48831. * Gets the hosting scene
  48832. * @returns a Scene
  48833. */
  48834. getScene(): Scene;
  48835. /** Gets the internal CubeTexture used to render to */
  48836. readonly cubeTexture: RenderTargetTexture;
  48837. /** Gets the list of meshes to render */
  48838. readonly renderList: Nullable<AbstractMesh[]>;
  48839. /**
  48840. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48841. * @param mesh defines the mesh to attach to
  48842. */
  48843. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48844. /**
  48845. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48846. * @param renderingGroupId The rendering group id corresponding to its index
  48847. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48848. */
  48849. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48850. /**
  48851. * Clean all associated resources
  48852. */
  48853. dispose(): void;
  48854. /**
  48855. * Converts the reflection probe information to a readable string for debug purpose.
  48856. * @param fullDetails Supports for multiple levels of logging within scene loading
  48857. * @returns the human readable reflection probe info
  48858. */
  48859. toString(fullDetails?: boolean): string;
  48860. /**
  48861. * Get the class name of the relfection probe.
  48862. * @returns "ReflectionProbe"
  48863. */
  48864. getClassName(): string;
  48865. /**
  48866. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48867. * @returns The JSON representation of the texture
  48868. */
  48869. serialize(): any;
  48870. /**
  48871. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48872. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48873. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48874. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48875. * @returns The parsed reflection probe if successful
  48876. */
  48877. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48878. }
  48879. }
  48880. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  48881. /** @hidden */
  48882. export var _BabylonLoaderRegistered: boolean;
  48883. }
  48884. declare module "babylonjs/Loading/Plugins/index" {
  48885. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  48886. }
  48887. declare module "babylonjs/Loading/index" {
  48888. export * from "babylonjs/Loading/loadingScreen";
  48889. export * from "babylonjs/Loading/Plugins/index";
  48890. export * from "babylonjs/Loading/sceneLoader";
  48891. export * from "babylonjs/Loading/sceneLoaderFlags";
  48892. }
  48893. declare module "babylonjs/Materials/Background/index" {
  48894. export * from "babylonjs/Materials/Background/backgroundMaterial";
  48895. }
  48896. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  48897. import { Scene } from "babylonjs/scene";
  48898. import { Color3 } from "babylonjs/Maths/math";
  48899. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48900. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48901. /**
  48902. * The Physically based simple base material of BJS.
  48903. *
  48904. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48905. * It is used as the base class for both the specGloss and metalRough conventions.
  48906. */
  48907. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48908. /**
  48909. * Number of Simultaneous lights allowed on the material.
  48910. */
  48911. maxSimultaneousLights: number;
  48912. /**
  48913. * If sets to true, disables all the lights affecting the material.
  48914. */
  48915. disableLighting: boolean;
  48916. /**
  48917. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48918. */
  48919. environmentTexture: BaseTexture;
  48920. /**
  48921. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48922. */
  48923. invertNormalMapX: boolean;
  48924. /**
  48925. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48926. */
  48927. invertNormalMapY: boolean;
  48928. /**
  48929. * Normal map used in the model.
  48930. */
  48931. normalTexture: BaseTexture;
  48932. /**
  48933. * Emissivie color used to self-illuminate the model.
  48934. */
  48935. emissiveColor: Color3;
  48936. /**
  48937. * Emissivie texture used to self-illuminate the model.
  48938. */
  48939. emissiveTexture: BaseTexture;
  48940. /**
  48941. * Occlusion Channel Strenght.
  48942. */
  48943. occlusionStrength: number;
  48944. /**
  48945. * Occlusion Texture of the material (adding extra occlusion effects).
  48946. */
  48947. occlusionTexture: BaseTexture;
  48948. /**
  48949. * Defines the alpha limits in alpha test mode.
  48950. */
  48951. alphaCutOff: number;
  48952. /**
  48953. * Gets the current double sided mode.
  48954. */
  48955. /**
  48956. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48957. */
  48958. doubleSided: boolean;
  48959. /**
  48960. * Stores the pre-calculated light information of a mesh in a texture.
  48961. */
  48962. lightmapTexture: BaseTexture;
  48963. /**
  48964. * If true, the light map contains occlusion information instead of lighting info.
  48965. */
  48966. useLightmapAsShadowmap: boolean;
  48967. /**
  48968. * Instantiates a new PBRMaterial instance.
  48969. *
  48970. * @param name The material name
  48971. * @param scene The scene the material will be use in.
  48972. */
  48973. constructor(name: string, scene: Scene);
  48974. getClassName(): string;
  48975. }
  48976. }
  48977. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  48978. import { Scene } from "babylonjs/scene";
  48979. import { Color3 } from "babylonjs/Maths/math";
  48980. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48981. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48982. /**
  48983. * The PBR material of BJS following the metal roughness convention.
  48984. *
  48985. * This fits to the PBR convention in the GLTF definition:
  48986. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48987. */
  48988. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48989. /**
  48990. * The base color has two different interpretations depending on the value of metalness.
  48991. * When the material is a metal, the base color is the specific measured reflectance value
  48992. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48993. * of the material.
  48994. */
  48995. baseColor: Color3;
  48996. /**
  48997. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48998. * well as opacity information in the alpha channel.
  48999. */
  49000. baseTexture: BaseTexture;
  49001. /**
  49002. * Specifies the metallic scalar value of the material.
  49003. * Can also be used to scale the metalness values of the metallic texture.
  49004. */
  49005. metallic: number;
  49006. /**
  49007. * Specifies the roughness scalar value of the material.
  49008. * Can also be used to scale the roughness values of the metallic texture.
  49009. */
  49010. roughness: number;
  49011. /**
  49012. * Texture containing both the metallic value in the B channel and the
  49013. * roughness value in the G channel to keep better precision.
  49014. */
  49015. metallicRoughnessTexture: BaseTexture;
  49016. /**
  49017. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49018. *
  49019. * @param name The material name
  49020. * @param scene The scene the material will be use in.
  49021. */
  49022. constructor(name: string, scene: Scene);
  49023. /**
  49024. * Return the currrent class name of the material.
  49025. */
  49026. getClassName(): string;
  49027. /**
  49028. * Makes a duplicate of the current material.
  49029. * @param name - name to use for the new material.
  49030. */
  49031. clone(name: string): PBRMetallicRoughnessMaterial;
  49032. /**
  49033. * Serialize the material to a parsable JSON object.
  49034. */
  49035. serialize(): any;
  49036. /**
  49037. * Parses a JSON object correponding to the serialize function.
  49038. */
  49039. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49040. }
  49041. }
  49042. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  49043. import { Scene } from "babylonjs/scene";
  49044. import { Color3 } from "babylonjs/Maths/math";
  49045. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49046. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49047. /**
  49048. * The PBR material of BJS following the specular glossiness convention.
  49049. *
  49050. * This fits to the PBR convention in the GLTF definition:
  49051. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49052. */
  49053. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49054. /**
  49055. * Specifies the diffuse color of the material.
  49056. */
  49057. diffuseColor: Color3;
  49058. /**
  49059. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49060. * channel.
  49061. */
  49062. diffuseTexture: BaseTexture;
  49063. /**
  49064. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49065. */
  49066. specularColor: Color3;
  49067. /**
  49068. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49069. */
  49070. glossiness: number;
  49071. /**
  49072. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49073. */
  49074. specularGlossinessTexture: BaseTexture;
  49075. /**
  49076. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49077. *
  49078. * @param name The material name
  49079. * @param scene The scene the material will be use in.
  49080. */
  49081. constructor(name: string, scene: Scene);
  49082. /**
  49083. * Return the currrent class name of the material.
  49084. */
  49085. getClassName(): string;
  49086. /**
  49087. * Makes a duplicate of the current material.
  49088. * @param name - name to use for the new material.
  49089. */
  49090. clone(name: string): PBRSpecularGlossinessMaterial;
  49091. /**
  49092. * Serialize the material to a parsable JSON object.
  49093. */
  49094. serialize(): any;
  49095. /**
  49096. * Parses a JSON object correponding to the serialize function.
  49097. */
  49098. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49099. }
  49100. }
  49101. declare module "babylonjs/Materials/PBR/index" {
  49102. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49103. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49104. export * from "babylonjs/Materials/PBR/pbrMaterial";
  49105. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  49106. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  49107. }
  49108. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  49109. import { Nullable } from "babylonjs/types";
  49110. import { Scene } from "babylonjs/scene";
  49111. import { Matrix } from "babylonjs/Maths/math";
  49112. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49113. /**
  49114. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49115. * It can help converting any input color in a desired output one. This can then be used to create effects
  49116. * from sepia, black and white to sixties or futuristic rendering...
  49117. *
  49118. * The only supported format is currently 3dl.
  49119. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49120. */
  49121. export class ColorGradingTexture extends BaseTexture {
  49122. /**
  49123. * The current texture matrix. (will always be identity in color grading texture)
  49124. */
  49125. private _textureMatrix;
  49126. /**
  49127. * The texture URL.
  49128. */
  49129. url: string;
  49130. /**
  49131. * Empty line regex stored for GC.
  49132. */
  49133. private static _noneEmptyLineRegex;
  49134. private _engine;
  49135. /**
  49136. * Instantiates a ColorGradingTexture from the following parameters.
  49137. *
  49138. * @param url The location of the color gradind data (currently only supporting 3dl)
  49139. * @param scene The scene the texture will be used in
  49140. */
  49141. constructor(url: string, scene: Scene);
  49142. /**
  49143. * Returns the texture matrix used in most of the material.
  49144. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49145. */
  49146. getTextureMatrix(): Matrix;
  49147. /**
  49148. * Occurs when the file being loaded is a .3dl LUT file.
  49149. */
  49150. private load3dlTexture;
  49151. /**
  49152. * Starts the loading process of the texture.
  49153. */
  49154. private loadTexture;
  49155. /**
  49156. * Clones the color gradind texture.
  49157. */
  49158. clone(): ColorGradingTexture;
  49159. /**
  49160. * Called during delayed load for textures.
  49161. */
  49162. delayLoad(): void;
  49163. /**
  49164. * Parses a color grading texture serialized by Babylon.
  49165. * @param parsedTexture The texture information being parsedTexture
  49166. * @param scene The scene to load the texture in
  49167. * @param rootUrl The root url of the data assets to load
  49168. * @return A color gradind texture
  49169. */
  49170. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49171. /**
  49172. * Serializes the LUT texture to json format.
  49173. */
  49174. serialize(): any;
  49175. }
  49176. }
  49177. declare module "babylonjs/Misc/tga" {
  49178. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49179. /**
  49180. * Based on jsTGALoader - Javascript loader for TGA file
  49181. * By Vincent Thibault
  49182. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49183. */
  49184. export class TGATools {
  49185. private static _TYPE_INDEXED;
  49186. private static _TYPE_RGB;
  49187. private static _TYPE_GREY;
  49188. private static _TYPE_RLE_INDEXED;
  49189. private static _TYPE_RLE_RGB;
  49190. private static _TYPE_RLE_GREY;
  49191. private static _ORIGIN_MASK;
  49192. private static _ORIGIN_SHIFT;
  49193. private static _ORIGIN_BL;
  49194. private static _ORIGIN_BR;
  49195. private static _ORIGIN_UL;
  49196. private static _ORIGIN_UR;
  49197. /**
  49198. * Gets the header of a TGA file
  49199. * @param data defines the TGA data
  49200. * @returns the header
  49201. */
  49202. static GetTGAHeader(data: Uint8Array): any;
  49203. /**
  49204. * Uploads TGA content to a Babylon Texture
  49205. * @hidden
  49206. */
  49207. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49208. /** @hidden */
  49209. 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;
  49210. /** @hidden */
  49211. 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;
  49212. /** @hidden */
  49213. 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;
  49214. /** @hidden */
  49215. 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;
  49216. /** @hidden */
  49217. 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;
  49218. /** @hidden */
  49219. 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;
  49220. }
  49221. }
  49222. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  49223. import { Nullable } from "babylonjs/types";
  49224. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49225. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49226. /**
  49227. * Implementation of the TGA Texture Loader.
  49228. * @hidden
  49229. */
  49230. export class _TGATextureLoader implements IInternalTextureLoader {
  49231. /**
  49232. * Defines wether the loader supports cascade loading the different faces.
  49233. */
  49234. readonly supportCascades: boolean;
  49235. /**
  49236. * This returns if the loader support the current file information.
  49237. * @param extension defines the file extension of the file being loaded
  49238. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49239. * @param fallback defines the fallback internal texture if any
  49240. * @param isBase64 defines whether the texture is encoded as a base64
  49241. * @param isBuffer defines whether the texture data are stored as a buffer
  49242. * @returns true if the loader can load the specified file
  49243. */
  49244. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49245. /**
  49246. * Transform the url before loading if required.
  49247. * @param rootUrl the url of the texture
  49248. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49249. * @returns the transformed texture
  49250. */
  49251. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49252. /**
  49253. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49254. * @param rootUrl the url of the texture
  49255. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49256. * @returns the fallback texture
  49257. */
  49258. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49259. /**
  49260. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49261. * @param data contains the texture data
  49262. * @param texture defines the BabylonJS internal texture
  49263. * @param createPolynomials will be true if polynomials have been requested
  49264. * @param onLoad defines the callback to trigger once the texture is ready
  49265. * @param onError defines the callback to trigger in case of error
  49266. */
  49267. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49268. /**
  49269. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49270. * @param data contains the texture data
  49271. * @param texture defines the BabylonJS internal texture
  49272. * @param callback defines the method to call once ready to upload
  49273. */
  49274. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49275. }
  49276. }
  49277. declare module "babylonjs/Materials/Textures/Loaders/index" {
  49278. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49279. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49280. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49281. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  49282. }
  49283. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  49284. import { Scene } from "babylonjs/scene";
  49285. import { Texture } from "babylonjs/Materials/Textures/texture";
  49286. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49287. /**
  49288. * 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.
  49289. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49290. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49291. */
  49292. export class CustomProceduralTexture extends ProceduralTexture {
  49293. private _animate;
  49294. private _time;
  49295. private _config;
  49296. private _texturePath;
  49297. /**
  49298. * Instantiates a new Custom Procedural Texture.
  49299. * 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.
  49300. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49301. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49302. * @param name Define the name of the texture
  49303. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49304. * @param size Define the size of the texture to create
  49305. * @param scene Define the scene the texture belongs to
  49306. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49307. * @param generateMipMaps Define if the texture should creates mip maps or not
  49308. */
  49309. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49310. private _loadJson;
  49311. /**
  49312. * Is the texture ready to be used ? (rendered at least once)
  49313. * @returns true if ready, otherwise, false.
  49314. */
  49315. isReady(): boolean;
  49316. /**
  49317. * Render the texture to its associated render target.
  49318. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49319. */
  49320. render(useCameraPostProcess?: boolean): void;
  49321. /**
  49322. * Update the list of dependant textures samplers in the shader.
  49323. */
  49324. updateTextures(): void;
  49325. /**
  49326. * Update the uniform values of the procedural texture in the shader.
  49327. */
  49328. updateShaderUniforms(): void;
  49329. /**
  49330. * Define if the texture animates or not.
  49331. */
  49332. animate: boolean;
  49333. }
  49334. }
  49335. declare module "babylonjs/Shaders/noise.fragment" {
  49336. /** @hidden */
  49337. export var noisePixelShader: {
  49338. name: string;
  49339. shader: string;
  49340. };
  49341. }
  49342. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  49343. import { Nullable } from "babylonjs/types";
  49344. import { Scene } from "babylonjs/scene";
  49345. import { Texture } from "babylonjs/Materials/Textures/texture";
  49346. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49347. import "babylonjs/Shaders/noise.fragment";
  49348. /**
  49349. * Class used to generate noise procedural textures
  49350. */
  49351. export class NoiseProceduralTexture extends ProceduralTexture {
  49352. private _time;
  49353. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49354. brightness: number;
  49355. /** Defines the number of octaves to process */
  49356. octaves: number;
  49357. /** Defines the level of persistence (0.8 by default) */
  49358. persistence: number;
  49359. /** Gets or sets animation speed factor (default is 1) */
  49360. animationSpeedFactor: number;
  49361. /**
  49362. * Creates a new NoiseProceduralTexture
  49363. * @param name defines the name fo the texture
  49364. * @param size defines the size of the texture (default is 256)
  49365. * @param scene defines the hosting scene
  49366. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49367. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49368. */
  49369. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49370. private _updateShaderUniforms;
  49371. protected _getDefines(): string;
  49372. /** Generate the current state of the procedural texture */
  49373. render(useCameraPostProcess?: boolean): void;
  49374. /**
  49375. * Serializes this noise procedural texture
  49376. * @returns a serialized noise procedural texture object
  49377. */
  49378. serialize(): any;
  49379. /**
  49380. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49381. * @param parsedTexture defines parsed texture data
  49382. * @param scene defines the current scene
  49383. * @param rootUrl defines the root URL containing noise procedural texture information
  49384. * @returns a parsed NoiseProceduralTexture
  49385. */
  49386. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49387. }
  49388. }
  49389. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  49390. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  49391. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  49392. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49393. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  49394. }
  49395. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  49396. import { Nullable } from "babylonjs/types";
  49397. import { Scene } from "babylonjs/scene";
  49398. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49399. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49400. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49401. /**
  49402. * Raw cube texture where the raw buffers are passed in
  49403. */
  49404. export class RawCubeTexture extends CubeTexture {
  49405. /**
  49406. * Creates a cube texture where the raw buffers are passed in.
  49407. * @param scene defines the scene the texture is attached to
  49408. * @param data defines the array of data to use to create each face
  49409. * @param size defines the size of the textures
  49410. * @param format defines the format of the data
  49411. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49412. * @param generateMipMaps defines if the engine should generate the mip levels
  49413. * @param invertY defines if data must be stored with Y axis inverted
  49414. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49415. * @param compression defines the compression used (null by default)
  49416. */
  49417. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49418. /**
  49419. * Updates the raw cube texture.
  49420. * @param data defines the data to store
  49421. * @param format defines the data format
  49422. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49423. * @param invertY defines if data must be stored with Y axis inverted
  49424. * @param compression defines the compression used (null by default)
  49425. * @param level defines which level of the texture to update
  49426. */
  49427. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49428. /**
  49429. * Updates a raw cube texture with RGBD encoded data.
  49430. * @param data defines the array of data [mipmap][face] to use to create each face
  49431. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49432. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49433. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49434. * @returns a promsie that resolves when the operation is complete
  49435. */
  49436. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49437. /**
  49438. * Clones the raw cube texture.
  49439. * @return a new cube texture
  49440. */
  49441. clone(): CubeTexture;
  49442. /** @hidden */
  49443. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49444. }
  49445. }
  49446. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  49447. import { Scene } from "babylonjs/scene";
  49448. import { Texture } from "babylonjs/Materials/Textures/texture";
  49449. /**
  49450. * Class used to store 3D textures containing user data
  49451. */
  49452. export class RawTexture3D extends Texture {
  49453. /** Gets or sets the texture format to use */
  49454. format: number;
  49455. private _engine;
  49456. /**
  49457. * Create a new RawTexture3D
  49458. * @param data defines the data of the texture
  49459. * @param width defines the width of the texture
  49460. * @param height defines the height of the texture
  49461. * @param depth defines the depth of the texture
  49462. * @param format defines the texture format to use
  49463. * @param scene defines the hosting scene
  49464. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49465. * @param invertY defines if texture must be stored with Y axis inverted
  49466. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49467. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49468. */
  49469. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49470. /** Gets or sets the texture format to use */
  49471. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49472. /**
  49473. * Update the texture with new data
  49474. * @param data defines the data to store in the texture
  49475. */
  49476. update(data: ArrayBufferView): void;
  49477. }
  49478. }
  49479. declare module "babylonjs/Materials/Textures/refractionTexture" {
  49480. import { Scene } from "babylonjs/scene";
  49481. import { Plane } from "babylonjs/Maths/math";
  49482. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49483. /**
  49484. * Creates a refraction texture used by refraction channel of the standard material.
  49485. * It is like a mirror but to see through a material.
  49486. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49487. */
  49488. export class RefractionTexture extends RenderTargetTexture {
  49489. /**
  49490. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49491. * 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.
  49492. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49493. */
  49494. refractionPlane: Plane;
  49495. /**
  49496. * Define how deep under the surface we should see.
  49497. */
  49498. depth: number;
  49499. /**
  49500. * Creates a refraction texture used by refraction channel of the standard material.
  49501. * It is like a mirror but to see through a material.
  49502. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49503. * @param name Define the texture name
  49504. * @param size Define the size of the underlying texture
  49505. * @param scene Define the scene the refraction belongs to
  49506. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49507. */
  49508. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49509. /**
  49510. * Clone the refraction texture.
  49511. * @returns the cloned texture
  49512. */
  49513. clone(): RefractionTexture;
  49514. /**
  49515. * Serialize the texture to a JSON representation you could use in Parse later on
  49516. * @returns the serialized JSON representation
  49517. */
  49518. serialize(): any;
  49519. }
  49520. }
  49521. declare module "babylonjs/Materials/Textures/index" {
  49522. export * from "babylonjs/Materials/Textures/baseTexture";
  49523. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  49524. export * from "babylonjs/Materials/Textures/cubeTexture";
  49525. export * from "babylonjs/Materials/Textures/dynamicTexture";
  49526. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  49527. export * from "babylonjs/Materials/Textures/internalTexture";
  49528. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  49529. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  49530. export * from "babylonjs/Materials/Textures/Loaders/index";
  49531. export * from "babylonjs/Materials/Textures/mirrorTexture";
  49532. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  49533. export * from "babylonjs/Materials/Textures/Procedurals/index";
  49534. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  49535. export * from "babylonjs/Materials/Textures/rawTexture";
  49536. export * from "babylonjs/Materials/Textures/rawTexture3D";
  49537. export * from "babylonjs/Materials/Textures/refractionTexture";
  49538. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  49539. export * from "babylonjs/Materials/Textures/texture";
  49540. export * from "babylonjs/Materials/Textures/videoTexture";
  49541. }
  49542. declare module "babylonjs/Materials/index" {
  49543. export * from "babylonjs/Materials/Background/index";
  49544. export * from "babylonjs/Materials/colorCurves";
  49545. export * from "babylonjs/Materials/effect";
  49546. export * from "babylonjs/Materials/fresnelParameters";
  49547. export * from "babylonjs/Materials/imageProcessingConfiguration";
  49548. export * from "babylonjs/Materials/material";
  49549. export * from "babylonjs/Materials/materialDefines";
  49550. export * from "babylonjs/Materials/materialHelper";
  49551. export * from "babylonjs/Materials/multiMaterial";
  49552. export * from "babylonjs/Materials/PBR/index";
  49553. export * from "babylonjs/Materials/pushMaterial";
  49554. export * from "babylonjs/Materials/shaderMaterial";
  49555. export * from "babylonjs/Materials/standardMaterial";
  49556. export * from "babylonjs/Materials/Textures/index";
  49557. export * from "babylonjs/Materials/uniformBuffer";
  49558. export * from "babylonjs/Materials/materialFlags";
  49559. }
  49560. declare module "babylonjs/Maths/index" {
  49561. export * from "babylonjs/Maths/math.scalar";
  49562. export * from "babylonjs/Maths/math";
  49563. export * from "babylonjs/Maths/sphericalPolynomial";
  49564. }
  49565. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  49566. import { IDisposable } from "babylonjs/scene";
  49567. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  49568. /**
  49569. * Configuration for Draco compression
  49570. */
  49571. export interface IDracoCompressionConfiguration {
  49572. /**
  49573. * Configuration for the decoder.
  49574. */
  49575. decoder?: {
  49576. /**
  49577. * The url to the WebAssembly module.
  49578. */
  49579. wasmUrl?: string;
  49580. /**
  49581. * The url to the WebAssembly binary.
  49582. */
  49583. wasmBinaryUrl?: string;
  49584. /**
  49585. * The url to the fallback JavaScript module.
  49586. */
  49587. fallbackUrl?: string;
  49588. };
  49589. }
  49590. /**
  49591. * Draco compression (https://google.github.io/draco/)
  49592. *
  49593. * This class wraps the Draco module.
  49594. *
  49595. * **Encoder**
  49596. *
  49597. * The encoder is not currently implemented.
  49598. *
  49599. * **Decoder**
  49600. *
  49601. * 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.
  49602. *
  49603. * To update the configuration, use the following code:
  49604. * ```javascript
  49605. * DracoCompression.Configuration = {
  49606. * decoder: {
  49607. * wasmUrl: "<url to the WebAssembly library>",
  49608. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49609. * fallbackUrl: "<url to the fallback JavaScript library>",
  49610. * }
  49611. * };
  49612. * ```
  49613. *
  49614. * 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.
  49615. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49616. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49617. *
  49618. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49619. * ```javascript
  49620. * var dracoCompression = new DracoCompression();
  49621. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49622. * [VertexBuffer.PositionKind]: 0
  49623. * });
  49624. * ```
  49625. *
  49626. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49627. */
  49628. export class DracoCompression implements IDisposable {
  49629. private static _DecoderModulePromise;
  49630. /**
  49631. * The configuration. Defaults to the following urls:
  49632. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49633. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49634. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49635. */
  49636. static Configuration: IDracoCompressionConfiguration;
  49637. /**
  49638. * Returns true if the decoder is available.
  49639. */
  49640. static readonly DecoderAvailable: boolean;
  49641. /**
  49642. * Constructor
  49643. */
  49644. constructor();
  49645. /**
  49646. * Stop all async operations and release resources.
  49647. */
  49648. dispose(): void;
  49649. /**
  49650. * Decode Draco compressed mesh data to vertex data.
  49651. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49652. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49653. * @returns A promise that resolves with the decoded vertex data
  49654. */
  49655. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  49656. [kind: string]: number;
  49657. }): Promise<VertexData>;
  49658. private static _GetDecoderModule;
  49659. private static _LoadScriptAsync;
  49660. private static _LoadFileAsync;
  49661. }
  49662. }
  49663. declare module "babylonjs/Meshes/Compression/index" {
  49664. export * from "babylonjs/Meshes/Compression/dracoCompression";
  49665. }
  49666. declare module "babylonjs/Meshes/csg" {
  49667. import { Nullable } from "babylonjs/types";
  49668. import { Scene } from "babylonjs/scene";
  49669. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  49670. import { Mesh } from "babylonjs/Meshes/mesh";
  49671. import { Material } from "babylonjs/Materials/material";
  49672. /**
  49673. * Class for building Constructive Solid Geometry
  49674. */
  49675. export class CSG {
  49676. private polygons;
  49677. /**
  49678. * The world matrix
  49679. */
  49680. matrix: Matrix;
  49681. /**
  49682. * Stores the position
  49683. */
  49684. position: Vector3;
  49685. /**
  49686. * Stores the rotation
  49687. */
  49688. rotation: Vector3;
  49689. /**
  49690. * Stores the rotation quaternion
  49691. */
  49692. rotationQuaternion: Nullable<Quaternion>;
  49693. /**
  49694. * Stores the scaling vector
  49695. */
  49696. scaling: Vector3;
  49697. /**
  49698. * Convert the Mesh to CSG
  49699. * @param mesh The Mesh to convert to CSG
  49700. * @returns A new CSG from the Mesh
  49701. */
  49702. static FromMesh(mesh: Mesh): CSG;
  49703. /**
  49704. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49705. * @param polygons Polygons used to construct a CSG solid
  49706. */
  49707. private static FromPolygons;
  49708. /**
  49709. * Clones, or makes a deep copy, of the CSG
  49710. * @returns A new CSG
  49711. */
  49712. clone(): CSG;
  49713. /**
  49714. * Unions this CSG with another CSG
  49715. * @param csg The CSG to union against this CSG
  49716. * @returns The unioned CSG
  49717. */
  49718. union(csg: CSG): CSG;
  49719. /**
  49720. * Unions this CSG with another CSG in place
  49721. * @param csg The CSG to union against this CSG
  49722. */
  49723. unionInPlace(csg: CSG): void;
  49724. /**
  49725. * Subtracts this CSG with another CSG
  49726. * @param csg The CSG to subtract against this CSG
  49727. * @returns A new CSG
  49728. */
  49729. subtract(csg: CSG): CSG;
  49730. /**
  49731. * Subtracts this CSG with another CSG in place
  49732. * @param csg The CSG to subtact against this CSG
  49733. */
  49734. subtractInPlace(csg: CSG): void;
  49735. /**
  49736. * Intersect this CSG with another CSG
  49737. * @param csg The CSG to intersect against this CSG
  49738. * @returns A new CSG
  49739. */
  49740. intersect(csg: CSG): CSG;
  49741. /**
  49742. * Intersects this CSG with another CSG in place
  49743. * @param csg The CSG to intersect against this CSG
  49744. */
  49745. intersectInPlace(csg: CSG): void;
  49746. /**
  49747. * Return a new CSG solid with solid and empty space switched. This solid is
  49748. * not modified.
  49749. * @returns A new CSG solid with solid and empty space switched
  49750. */
  49751. inverse(): CSG;
  49752. /**
  49753. * Inverses the CSG in place
  49754. */
  49755. inverseInPlace(): void;
  49756. /**
  49757. * This is used to keep meshes transformations so they can be restored
  49758. * when we build back a Babylon Mesh
  49759. * NB : All CSG operations are performed in world coordinates
  49760. * @param csg The CSG to copy the transform attributes from
  49761. * @returns This CSG
  49762. */
  49763. copyTransformAttributes(csg: CSG): CSG;
  49764. /**
  49765. * Build Raw mesh from CSG
  49766. * Coordinates here are in world space
  49767. * @param name The name of the mesh geometry
  49768. * @param scene The Scene
  49769. * @param keepSubMeshes Specifies if the submeshes should be kept
  49770. * @returns A new Mesh
  49771. */
  49772. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49773. /**
  49774. * Build Mesh from CSG taking material and transforms into account
  49775. * @param name The name of the Mesh
  49776. * @param material The material of the Mesh
  49777. * @param scene The Scene
  49778. * @param keepSubMeshes Specifies if submeshes should be kept
  49779. * @returns The new Mesh
  49780. */
  49781. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49782. }
  49783. }
  49784. declare module "babylonjs/Meshes/trailMesh" {
  49785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49786. import { Mesh } from "babylonjs/Meshes/mesh";
  49787. import { Scene } from "babylonjs/scene";
  49788. /**
  49789. * Class used to create a trail following a mesh
  49790. */
  49791. export class TrailMesh extends Mesh {
  49792. private _generator;
  49793. private _autoStart;
  49794. private _running;
  49795. private _diameter;
  49796. private _length;
  49797. private _sectionPolygonPointsCount;
  49798. private _sectionVectors;
  49799. private _sectionNormalVectors;
  49800. private _beforeRenderObserver;
  49801. /**
  49802. * @constructor
  49803. * @param name The value used by scene.getMeshByName() to do a lookup.
  49804. * @param generator The mesh to generate a trail.
  49805. * @param scene The scene to add this mesh to.
  49806. * @param diameter Diameter of trailing mesh. Default is 1.
  49807. * @param length Length of trailing mesh. Default is 60.
  49808. * @param autoStart Automatically start trailing mesh. Default true.
  49809. */
  49810. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49811. /**
  49812. * "TrailMesh"
  49813. * @returns "TrailMesh"
  49814. */
  49815. getClassName(): string;
  49816. private _createMesh;
  49817. /**
  49818. * Start trailing mesh.
  49819. */
  49820. start(): void;
  49821. /**
  49822. * Stop trailing mesh.
  49823. */
  49824. stop(): void;
  49825. /**
  49826. * Update trailing mesh geometry.
  49827. */
  49828. update(): void;
  49829. /**
  49830. * Returns a new TrailMesh object.
  49831. * @param name is a string, the name given to the new mesh
  49832. * @param newGenerator use new generator object for cloned trail mesh
  49833. * @returns a new mesh
  49834. */
  49835. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49836. /**
  49837. * Serializes this trail mesh
  49838. * @param serializationObject object to write serialization to
  49839. */
  49840. serialize(serializationObject: any): void;
  49841. /**
  49842. * Parses a serialized trail mesh
  49843. * @param parsedMesh the serialized mesh
  49844. * @param scene the scene to create the trail mesh in
  49845. * @returns the created trail mesh
  49846. */
  49847. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49848. }
  49849. }
  49850. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  49851. import { Nullable } from "babylonjs/types";
  49852. import { Scene } from "babylonjs/scene";
  49853. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  49854. import { Mesh } from "babylonjs/Meshes/mesh";
  49855. /**
  49856. * Class containing static functions to help procedurally build meshes
  49857. */
  49858. export class RibbonBuilder {
  49859. /**
  49860. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49861. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49862. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49863. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49864. * * 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
  49865. * * 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
  49866. * * 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
  49867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49868. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49869. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49870. * * 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
  49871. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49872. * * 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
  49873. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49875. * @param name defines the name of the mesh
  49876. * @param options defines the options used to create the mesh
  49877. * @param scene defines the hosting scene
  49878. * @returns the ribbon mesh
  49879. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49880. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49881. */
  49882. static CreateRibbon(name: string, options: {
  49883. pathArray: Vector3[][];
  49884. closeArray?: boolean;
  49885. closePath?: boolean;
  49886. offset?: number;
  49887. updatable?: boolean;
  49888. sideOrientation?: number;
  49889. frontUVs?: Vector4;
  49890. backUVs?: Vector4;
  49891. instance?: Mesh;
  49892. invertUV?: boolean;
  49893. uvs?: Vector2[];
  49894. colors?: Color4[];
  49895. }, scene?: Nullable<Scene>): Mesh;
  49896. }
  49897. }
  49898. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  49899. import { Vector4 } from "babylonjs/Maths/math";
  49900. import { Mesh } from "babylonjs/Meshes/mesh";
  49901. /**
  49902. * Class containing static functions to help procedurally build meshes
  49903. */
  49904. export class TorusKnotBuilder {
  49905. /**
  49906. * Creates a torus knot mesh
  49907. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49908. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49909. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49910. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49911. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49912. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49914. * @param name defines the name of the mesh
  49915. * @param options defines the options used to create the mesh
  49916. * @param scene defines the hosting scene
  49917. * @returns the torus knot mesh
  49918. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49919. */
  49920. static CreateTorusKnot(name: string, options: {
  49921. radius?: number;
  49922. tube?: number;
  49923. radialSegments?: number;
  49924. tubularSegments?: number;
  49925. p?: number;
  49926. q?: number;
  49927. updatable?: boolean;
  49928. sideOrientation?: number;
  49929. frontUVs?: Vector4;
  49930. backUVs?: Vector4;
  49931. }, scene: any): Mesh;
  49932. }
  49933. }
  49934. declare module "babylonjs/Meshes/polygonMesh" {
  49935. import { Scene } from "babylonjs/scene";
  49936. import { Vector2, Path2 } from "babylonjs/Maths/math";
  49937. import { Mesh } from "babylonjs/Meshes/mesh";
  49938. /**
  49939. * Polygon
  49940. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49941. */
  49942. export class Polygon {
  49943. /**
  49944. * Creates a rectangle
  49945. * @param xmin bottom X coord
  49946. * @param ymin bottom Y coord
  49947. * @param xmax top X coord
  49948. * @param ymax top Y coord
  49949. * @returns points that make the resulting rectation
  49950. */
  49951. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49952. /**
  49953. * Creates a circle
  49954. * @param radius radius of circle
  49955. * @param cx scale in x
  49956. * @param cy scale in y
  49957. * @param numberOfSides number of sides that make up the circle
  49958. * @returns points that make the resulting circle
  49959. */
  49960. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49961. /**
  49962. * Creates a polygon from input string
  49963. * @param input Input polygon data
  49964. * @returns the parsed points
  49965. */
  49966. static Parse(input: string): Vector2[];
  49967. /**
  49968. * Starts building a polygon from x and y coordinates
  49969. * @param x x coordinate
  49970. * @param y y coordinate
  49971. * @returns the started path2
  49972. */
  49973. static StartingAt(x: number, y: number): Path2;
  49974. }
  49975. /**
  49976. * Builds a polygon
  49977. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49978. */
  49979. export class PolygonMeshBuilder {
  49980. private _points;
  49981. private _outlinepoints;
  49982. private _holes;
  49983. private _name;
  49984. private _scene;
  49985. private _epoints;
  49986. private _eholes;
  49987. private _addToepoint;
  49988. /**
  49989. * Babylon reference to the earcut plugin.
  49990. */
  49991. bjsEarcut: any;
  49992. /**
  49993. * Creates a PolygonMeshBuilder
  49994. * @param name name of the builder
  49995. * @param contours Path of the polygon
  49996. * @param scene scene to add to
  49997. * @param earcutInjection can be used to inject your own earcut reference
  49998. */
  49999. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  50000. /**
  50001. * Adds a whole within the polygon
  50002. * @param hole Array of points defining the hole
  50003. * @returns this
  50004. */
  50005. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50006. /**
  50007. * Creates the polygon
  50008. * @param updatable If the mesh should be updatable
  50009. * @param depth The depth of the mesh created
  50010. * @returns the created mesh
  50011. */
  50012. build(updatable?: boolean, depth?: number): Mesh;
  50013. /**
  50014. * Adds a side to the polygon
  50015. * @param positions points that make the polygon
  50016. * @param normals normals of the polygon
  50017. * @param uvs uvs of the polygon
  50018. * @param indices indices of the polygon
  50019. * @param bounds bounds of the polygon
  50020. * @param points points of the polygon
  50021. * @param depth depth of the polygon
  50022. * @param flip flip of the polygon
  50023. */
  50024. private addSide;
  50025. }
  50026. }
  50027. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  50028. import { Scene } from "babylonjs/scene";
  50029. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  50030. import { Mesh } from "babylonjs/Meshes/mesh";
  50031. /**
  50032. * Class containing static functions to help procedurally build meshes
  50033. */
  50034. export class PolygonBuilder {
  50035. /**
  50036. * Creates a polygon mesh
  50037. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50038. * * 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
  50039. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50041. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50042. * * Remember you can only change the shape positions, not their number when updating a polygon
  50043. * @param name defines the name of the mesh
  50044. * @param options defines the options used to create the mesh
  50045. * @param scene defines the hosting scene
  50046. * @param earcutInjection can be used to inject your own earcut reference
  50047. * @returns the polygon mesh
  50048. */
  50049. static CreatePolygon(name: string, options: {
  50050. shape: Vector3[];
  50051. holes?: Vector3[][];
  50052. depth?: number;
  50053. faceUV?: Vector4[];
  50054. faceColors?: Color4[];
  50055. updatable?: boolean;
  50056. sideOrientation?: number;
  50057. frontUVs?: Vector4;
  50058. backUVs?: Vector4;
  50059. }, scene: Scene, earcutInjection?: any): Mesh;
  50060. /**
  50061. * Creates an extruded polygon mesh, with depth in the Y direction.
  50062. * * 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)
  50063. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50064. * @param name defines the name of the mesh
  50065. * @param options defines the options used to create the mesh
  50066. * @param scene defines the hosting scene
  50067. * @param earcutInjection can be used to inject your own earcut reference
  50068. * @returns the polygon mesh
  50069. */
  50070. static ExtrudePolygon(name: string, options: {
  50071. shape: Vector3[];
  50072. holes?: Vector3[][];
  50073. depth?: number;
  50074. faceUV?: Vector4[];
  50075. faceColors?: Color4[];
  50076. updatable?: boolean;
  50077. sideOrientation?: number;
  50078. frontUVs?: Vector4;
  50079. backUVs?: Vector4;
  50080. }, scene: Scene, earcutInjection?: any): Mesh;
  50081. }
  50082. }
  50083. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50084. import { Nullable } from "babylonjs/types";
  50085. import { Scene } from "babylonjs/scene";
  50086. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50087. import { Mesh } from "babylonjs/Meshes/mesh";
  50088. /**
  50089. * Class containing static functions to help procedurally build meshes
  50090. */
  50091. export class ShapeBuilder {
  50092. /**
  50093. * 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.
  50094. * * 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.
  50095. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50096. * * 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.
  50097. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50098. * * 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
  50099. * * 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
  50100. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50101. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50102. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50103. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50105. * @param name defines the name of the mesh
  50106. * @param options defines the options used to create the mesh
  50107. * @param scene defines the hosting scene
  50108. * @returns the extruded shape mesh
  50109. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50110. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50111. */
  50112. static ExtrudeShape(name: string, options: {
  50113. shape: Vector3[];
  50114. path: Vector3[];
  50115. scale?: number;
  50116. rotation?: number;
  50117. cap?: number;
  50118. updatable?: boolean;
  50119. sideOrientation?: number;
  50120. frontUVs?: Vector4;
  50121. backUVs?: Vector4;
  50122. instance?: Mesh;
  50123. invertUV?: boolean;
  50124. }, scene?: Nullable<Scene>): Mesh;
  50125. /**
  50126. * Creates an custom extruded shape mesh.
  50127. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50128. * * 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.
  50129. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50130. * * 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
  50131. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50132. * * 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
  50133. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50134. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50135. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50136. * * 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
  50137. * * 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
  50138. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50140. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50141. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50143. * @param name defines the name of the mesh
  50144. * @param options defines the options used to create the mesh
  50145. * @param scene defines the hosting scene
  50146. * @returns the custom extruded shape mesh
  50147. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50148. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50149. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50150. */
  50151. static ExtrudeShapeCustom(name: string, options: {
  50152. shape: Vector3[];
  50153. path: Vector3[];
  50154. scaleFunction?: any;
  50155. rotationFunction?: any;
  50156. ribbonCloseArray?: boolean;
  50157. ribbonClosePath?: boolean;
  50158. cap?: number;
  50159. updatable?: boolean;
  50160. sideOrientation?: number;
  50161. frontUVs?: Vector4;
  50162. backUVs?: Vector4;
  50163. instance?: Mesh;
  50164. invertUV?: boolean;
  50165. }, scene: Scene): Mesh;
  50166. private static _ExtrudeShapeGeneric;
  50167. }
  50168. }
  50169. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  50170. import { Scene } from "babylonjs/scene";
  50171. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50172. import { Mesh } from "babylonjs/Meshes/mesh";
  50173. /**
  50174. * Class containing static functions to help procedurally build meshes
  50175. */
  50176. export class LatheBuilder {
  50177. /**
  50178. * Creates lathe mesh.
  50179. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50180. * * 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
  50181. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50182. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50183. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50184. * * 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
  50185. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50186. * * 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
  50187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50188. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50189. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50191. * @param name defines the name of the mesh
  50192. * @param options defines the options used to create the mesh
  50193. * @param scene defines the hosting scene
  50194. * @returns the lathe mesh
  50195. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50196. */
  50197. static CreateLathe(name: string, options: {
  50198. shape: Vector3[];
  50199. radius?: number;
  50200. tessellation?: number;
  50201. clip?: number;
  50202. arc?: number;
  50203. closed?: boolean;
  50204. updatable?: boolean;
  50205. sideOrientation?: number;
  50206. frontUVs?: Vector4;
  50207. backUVs?: Vector4;
  50208. cap?: number;
  50209. invertUV?: boolean;
  50210. }, scene: Scene): Mesh;
  50211. }
  50212. }
  50213. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  50214. import { Scene } from "babylonjs/scene";
  50215. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50216. import { Mesh } from "babylonjs/Meshes/mesh";
  50217. /**
  50218. * Class containing static functions to help procedurally build meshes
  50219. */
  50220. export class TubeBuilder {
  50221. /**
  50222. * Creates a tube mesh.
  50223. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50224. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50225. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50226. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50227. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50228. * * 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)
  50229. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50230. * * 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
  50231. * * 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
  50232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50233. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50234. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50236. * @param name defines the name of the mesh
  50237. * @param options defines the options used to create the mesh
  50238. * @param scene defines the hosting scene
  50239. * @returns the tube mesh
  50240. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50241. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50242. */
  50243. static CreateTube(name: string, options: {
  50244. path: Vector3[];
  50245. radius?: number;
  50246. tessellation?: number;
  50247. radiusFunction?: {
  50248. (i: number, distance: number): number;
  50249. };
  50250. cap?: number;
  50251. arc?: number;
  50252. updatable?: boolean;
  50253. sideOrientation?: number;
  50254. frontUVs?: Vector4;
  50255. backUVs?: Vector4;
  50256. instance?: Mesh;
  50257. invertUV?: boolean;
  50258. }, scene: Scene): Mesh;
  50259. }
  50260. }
  50261. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  50262. import { Scene } from "babylonjs/scene";
  50263. import { Vector4 } from "babylonjs/Maths/math";
  50264. import { Mesh } from "babylonjs/Meshes/mesh";
  50265. /**
  50266. * Class containing static functions to help procedurally build meshes
  50267. */
  50268. export class IcoSphereBuilder {
  50269. /**
  50270. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50271. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50272. * * 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`)
  50273. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50274. * * 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
  50275. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50276. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50278. * @param name defines the name of the mesh
  50279. * @param options defines the options used to create the mesh
  50280. * @param scene defines the hosting scene
  50281. * @returns the icosahedron mesh
  50282. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50283. */
  50284. static CreateIcoSphere(name: string, options: {
  50285. radius?: number;
  50286. radiusX?: number;
  50287. radiusY?: number;
  50288. radiusZ?: number;
  50289. flat?: boolean;
  50290. subdivisions?: number;
  50291. sideOrientation?: number;
  50292. frontUVs?: Vector4;
  50293. backUVs?: Vector4;
  50294. updatable?: boolean;
  50295. }, scene: Scene): Mesh;
  50296. }
  50297. }
  50298. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  50299. import { Vector3 } from "babylonjs/Maths/math";
  50300. import { Mesh } from "babylonjs/Meshes/mesh";
  50301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50302. /**
  50303. * Class containing static functions to help procedurally build meshes
  50304. */
  50305. export class DecalBuilder {
  50306. /**
  50307. * Creates a decal mesh.
  50308. * 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
  50309. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50310. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50311. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50312. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50313. * @param name defines the name of the mesh
  50314. * @param sourceMesh defines the mesh where the decal must be applied
  50315. * @param options defines the options used to create the mesh
  50316. * @param scene defines the hosting scene
  50317. * @returns the decal mesh
  50318. * @see https://doc.babylonjs.com/how_to/decals
  50319. */
  50320. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50321. position?: Vector3;
  50322. normal?: Vector3;
  50323. size?: Vector3;
  50324. angle?: number;
  50325. }): Mesh;
  50326. }
  50327. }
  50328. declare module "babylonjs/Meshes/meshBuilder" {
  50329. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  50330. import { Nullable } from "babylonjs/types";
  50331. import { Scene } from "babylonjs/scene";
  50332. import { Mesh } from "babylonjs/Meshes/mesh";
  50333. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50334. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  50335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50336. /**
  50337. * Class containing static functions to help procedurally build meshes
  50338. */
  50339. export class MeshBuilder {
  50340. /**
  50341. * Creates a box mesh
  50342. * * The parameter `size` sets the size (float) of each box side (default 1)
  50343. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50344. * * 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)
  50345. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50349. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50350. * @param name defines the name of the mesh
  50351. * @param options defines the options used to create the mesh
  50352. * @param scene defines the hosting scene
  50353. * @returns the box mesh
  50354. */
  50355. static CreateBox(name: string, options: {
  50356. size?: number;
  50357. width?: number;
  50358. height?: number;
  50359. depth?: number;
  50360. faceUV?: Vector4[];
  50361. faceColors?: Color4[];
  50362. sideOrientation?: number;
  50363. frontUVs?: Vector4;
  50364. backUVs?: Vector4;
  50365. updatable?: boolean;
  50366. }, scene?: Nullable<Scene>): Mesh;
  50367. /**
  50368. * Creates a sphere mesh
  50369. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50370. * * 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`)
  50371. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50372. * * 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
  50373. * * 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)
  50374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50377. * @param name defines the name of the mesh
  50378. * @param options defines the options used to create the mesh
  50379. * @param scene defines the hosting scene
  50380. * @returns the sphere mesh
  50381. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50382. */
  50383. static CreateSphere(name: string, options: {
  50384. segments?: number;
  50385. diameter?: number;
  50386. diameterX?: number;
  50387. diameterY?: number;
  50388. diameterZ?: number;
  50389. arc?: number;
  50390. slice?: number;
  50391. sideOrientation?: number;
  50392. frontUVs?: Vector4;
  50393. backUVs?: Vector4;
  50394. updatable?: boolean;
  50395. }, scene: any): Mesh;
  50396. /**
  50397. * Creates a plane polygonal mesh. By default, this is a disc
  50398. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50399. * * 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
  50400. * * 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
  50401. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50402. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50404. * @param name defines the name of the mesh
  50405. * @param options defines the options used to create the mesh
  50406. * @param scene defines the hosting scene
  50407. * @returns the plane polygonal mesh
  50408. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50409. */
  50410. static CreateDisc(name: string, options: {
  50411. radius?: number;
  50412. tessellation?: number;
  50413. arc?: number;
  50414. updatable?: boolean;
  50415. sideOrientation?: number;
  50416. frontUVs?: Vector4;
  50417. backUVs?: Vector4;
  50418. }, scene?: Nullable<Scene>): Mesh;
  50419. /**
  50420. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50421. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50422. * * 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`)
  50423. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50424. * * 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
  50425. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50426. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50428. * @param name defines the name of the mesh
  50429. * @param options defines the options used to create the mesh
  50430. * @param scene defines the hosting scene
  50431. * @returns the icosahedron mesh
  50432. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50433. */
  50434. static CreateIcoSphere(name: string, options: {
  50435. radius?: number;
  50436. radiusX?: number;
  50437. radiusY?: number;
  50438. radiusZ?: number;
  50439. flat?: boolean;
  50440. subdivisions?: number;
  50441. sideOrientation?: number;
  50442. frontUVs?: Vector4;
  50443. backUVs?: Vector4;
  50444. updatable?: boolean;
  50445. }, scene: Scene): Mesh;
  50446. /**
  50447. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50448. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50449. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50450. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50451. * * 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
  50452. * * 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
  50453. * * 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
  50454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50456. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50457. * * 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
  50458. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50459. * * 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
  50460. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50462. * @param name defines the name of the mesh
  50463. * @param options defines the options used to create the mesh
  50464. * @param scene defines the hosting scene
  50465. * @returns the ribbon mesh
  50466. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50467. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50468. */
  50469. static CreateRibbon(name: string, options: {
  50470. pathArray: Vector3[][];
  50471. closeArray?: boolean;
  50472. closePath?: boolean;
  50473. offset?: number;
  50474. updatable?: boolean;
  50475. sideOrientation?: number;
  50476. frontUVs?: Vector4;
  50477. backUVs?: Vector4;
  50478. instance?: Mesh;
  50479. invertUV?: boolean;
  50480. uvs?: Vector2[];
  50481. colors?: Color4[];
  50482. }, scene?: Nullable<Scene>): Mesh;
  50483. /**
  50484. * Creates a cylinder or a cone mesh
  50485. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50486. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50487. * * 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.
  50488. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50489. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50490. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50491. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50492. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50493. * * 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).
  50494. * * 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
  50495. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50496. * * 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
  50497. * * 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.
  50498. * * If `enclose` is false, a ring surface is one element.
  50499. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50500. * * 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
  50501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50504. * @param name defines the name of the mesh
  50505. * @param options defines the options used to create the mesh
  50506. * @param scene defines the hosting scene
  50507. * @returns the cylinder mesh
  50508. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50509. */
  50510. static CreateCylinder(name: string, options: {
  50511. height?: number;
  50512. diameterTop?: number;
  50513. diameterBottom?: number;
  50514. diameter?: number;
  50515. tessellation?: number;
  50516. subdivisions?: number;
  50517. arc?: number;
  50518. faceColors?: Color4[];
  50519. faceUV?: Vector4[];
  50520. updatable?: boolean;
  50521. hasRings?: boolean;
  50522. enclose?: boolean;
  50523. sideOrientation?: number;
  50524. frontUVs?: Vector4;
  50525. backUVs?: Vector4;
  50526. }, scene: any): Mesh;
  50527. /**
  50528. * Creates a torus mesh
  50529. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50530. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50531. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50532. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50533. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50535. * @param name defines the name of the mesh
  50536. * @param options defines the options used to create the mesh
  50537. * @param scene defines the hosting scene
  50538. * @returns the torus mesh
  50539. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50540. */
  50541. static CreateTorus(name: string, options: {
  50542. diameter?: number;
  50543. thickness?: number;
  50544. tessellation?: number;
  50545. updatable?: boolean;
  50546. sideOrientation?: number;
  50547. frontUVs?: Vector4;
  50548. backUVs?: Vector4;
  50549. }, scene: any): Mesh;
  50550. /**
  50551. * Creates a torus knot mesh
  50552. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50553. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50554. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50555. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50557. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50559. * @param name defines the name of the mesh
  50560. * @param options defines the options used to create the mesh
  50561. * @param scene defines the hosting scene
  50562. * @returns the torus knot mesh
  50563. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50564. */
  50565. static CreateTorusKnot(name: string, options: {
  50566. radius?: number;
  50567. tube?: number;
  50568. radialSegments?: number;
  50569. tubularSegments?: number;
  50570. p?: number;
  50571. q?: number;
  50572. updatable?: boolean;
  50573. sideOrientation?: number;
  50574. frontUVs?: Vector4;
  50575. backUVs?: Vector4;
  50576. }, scene: any): Mesh;
  50577. /**
  50578. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50579. * * 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
  50580. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50581. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50582. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50583. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50584. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50585. * * 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
  50586. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50588. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50589. * @param name defines the name of the new line system
  50590. * @param options defines the options used to create the line system
  50591. * @param scene defines the hosting scene
  50592. * @returns a new line system mesh
  50593. */
  50594. static CreateLineSystem(name: string, options: {
  50595. lines: Vector3[][];
  50596. updatable?: boolean;
  50597. instance?: Nullable<LinesMesh>;
  50598. colors?: Nullable<Color4[][]>;
  50599. useVertexAlpha?: boolean;
  50600. }, scene: Nullable<Scene>): LinesMesh;
  50601. /**
  50602. * Creates a line mesh
  50603. * 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
  50604. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50605. * * The parameter `points` is an array successive Vector3
  50606. * * 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
  50607. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50608. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50609. * * When updating an instance, remember that only point positions can change, not the number of points
  50610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50611. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50612. * @param name defines the name of the new line system
  50613. * @param options defines the options used to create the line system
  50614. * @param scene defines the hosting scene
  50615. * @returns a new line mesh
  50616. */
  50617. static CreateLines(name: string, options: {
  50618. points: Vector3[];
  50619. updatable?: boolean;
  50620. instance?: Nullable<LinesMesh>;
  50621. colors?: Color4[];
  50622. useVertexAlpha?: boolean;
  50623. }, scene?: Nullable<Scene>): LinesMesh;
  50624. /**
  50625. * Creates a dashed line mesh
  50626. * * 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
  50627. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50628. * * The parameter `points` is an array successive Vector3
  50629. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50630. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50631. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50632. * * 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
  50633. * * When updating an instance, remember that only point positions can change, not the number of points
  50634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50635. * @param name defines the name of the mesh
  50636. * @param options defines the options used to create the mesh
  50637. * @param scene defines the hosting scene
  50638. * @returns the dashed line mesh
  50639. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50640. */
  50641. static CreateDashedLines(name: string, options: {
  50642. points: Vector3[];
  50643. dashSize?: number;
  50644. gapSize?: number;
  50645. dashNb?: number;
  50646. updatable?: boolean;
  50647. instance?: LinesMesh;
  50648. }, scene?: Nullable<Scene>): LinesMesh;
  50649. /**
  50650. * 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.
  50651. * * 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.
  50652. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50653. * * 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.
  50654. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50655. * * 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
  50656. * * 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
  50657. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50659. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50660. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50662. * @param name defines the name of the mesh
  50663. * @param options defines the options used to create the mesh
  50664. * @param scene defines the hosting scene
  50665. * @returns the extruded shape mesh
  50666. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50667. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50668. */
  50669. static ExtrudeShape(name: string, options: {
  50670. shape: Vector3[];
  50671. path: Vector3[];
  50672. scale?: number;
  50673. rotation?: number;
  50674. cap?: number;
  50675. updatable?: boolean;
  50676. sideOrientation?: number;
  50677. frontUVs?: Vector4;
  50678. backUVs?: Vector4;
  50679. instance?: Mesh;
  50680. invertUV?: boolean;
  50681. }, scene?: Nullable<Scene>): Mesh;
  50682. /**
  50683. * Creates an custom extruded shape mesh.
  50684. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50685. * * 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.
  50686. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50687. * * 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
  50688. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50689. * * 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
  50690. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50691. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50692. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50693. * * 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
  50694. * * 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
  50695. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50697. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50698. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50700. * @param name defines the name of the mesh
  50701. * @param options defines the options used to create the mesh
  50702. * @param scene defines the hosting scene
  50703. * @returns the custom extruded shape mesh
  50704. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50705. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50706. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50707. */
  50708. static ExtrudeShapeCustom(name: string, options: {
  50709. shape: Vector3[];
  50710. path: Vector3[];
  50711. scaleFunction?: any;
  50712. rotationFunction?: any;
  50713. ribbonCloseArray?: boolean;
  50714. ribbonClosePath?: boolean;
  50715. cap?: number;
  50716. updatable?: boolean;
  50717. sideOrientation?: number;
  50718. frontUVs?: Vector4;
  50719. backUVs?: Vector4;
  50720. instance?: Mesh;
  50721. invertUV?: boolean;
  50722. }, scene: Scene): Mesh;
  50723. /**
  50724. * Creates lathe mesh.
  50725. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50726. * * 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
  50727. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50728. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50729. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50730. * * 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
  50731. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50732. * * 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
  50733. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50734. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50735. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50737. * @param name defines the name of the mesh
  50738. * @param options defines the options used to create the mesh
  50739. * @param scene defines the hosting scene
  50740. * @returns the lathe mesh
  50741. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50742. */
  50743. static CreateLathe(name: string, options: {
  50744. shape: Vector3[];
  50745. radius?: number;
  50746. tessellation?: number;
  50747. clip?: number;
  50748. arc?: number;
  50749. closed?: boolean;
  50750. updatable?: boolean;
  50751. sideOrientation?: number;
  50752. frontUVs?: Vector4;
  50753. backUVs?: Vector4;
  50754. cap?: number;
  50755. invertUV?: boolean;
  50756. }, scene: Scene): Mesh;
  50757. /**
  50758. * Creates a plane mesh
  50759. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50760. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50761. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50763. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50765. * @param name defines the name of the mesh
  50766. * @param options defines the options used to create the mesh
  50767. * @param scene defines the hosting scene
  50768. * @returns the plane mesh
  50769. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50770. */
  50771. static CreatePlane(name: string, options: {
  50772. size?: number;
  50773. width?: number;
  50774. height?: number;
  50775. sideOrientation?: number;
  50776. frontUVs?: Vector4;
  50777. backUVs?: Vector4;
  50778. updatable?: boolean;
  50779. sourcePlane?: Plane;
  50780. }, scene: Scene): Mesh;
  50781. /**
  50782. * Creates a ground mesh
  50783. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50784. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50786. * @param name defines the name of the mesh
  50787. * @param options defines the options used to create the mesh
  50788. * @param scene defines the hosting scene
  50789. * @returns the ground mesh
  50790. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50791. */
  50792. static CreateGround(name: string, options: {
  50793. width?: number;
  50794. height?: number;
  50795. subdivisions?: number;
  50796. subdivisionsX?: number;
  50797. subdivisionsY?: number;
  50798. updatable?: boolean;
  50799. }, scene: any): Mesh;
  50800. /**
  50801. * Creates a tiled ground mesh
  50802. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50803. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50804. * * 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
  50805. * * 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
  50806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50807. * @param name defines the name of the mesh
  50808. * @param options defines the options used to create the mesh
  50809. * @param scene defines the hosting scene
  50810. * @returns the tiled ground mesh
  50811. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50812. */
  50813. static CreateTiledGround(name: string, options: {
  50814. xmin: number;
  50815. zmin: number;
  50816. xmax: number;
  50817. zmax: number;
  50818. subdivisions?: {
  50819. w: number;
  50820. h: number;
  50821. };
  50822. precision?: {
  50823. w: number;
  50824. h: number;
  50825. };
  50826. updatable?: boolean;
  50827. }, scene: Scene): Mesh;
  50828. /**
  50829. * Creates a ground mesh from a height map
  50830. * * The parameter `url` sets the URL of the height map image resource.
  50831. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50832. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50833. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50834. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50835. * * 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.
  50836. * * 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).
  50837. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50839. * @param name defines the name of the mesh
  50840. * @param url defines the url to the height map
  50841. * @param options defines the options used to create the mesh
  50842. * @param scene defines the hosting scene
  50843. * @returns the ground mesh
  50844. * @see https://doc.babylonjs.com/babylon101/height_map
  50845. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50846. */
  50847. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50848. width?: number;
  50849. height?: number;
  50850. subdivisions?: number;
  50851. minHeight?: number;
  50852. maxHeight?: number;
  50853. colorFilter?: Color3;
  50854. alphaFilter?: number;
  50855. updatable?: boolean;
  50856. onReady?: (mesh: GroundMesh) => void;
  50857. }, scene: Scene): GroundMesh;
  50858. /**
  50859. * Creates a polygon mesh
  50860. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50861. * * 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
  50862. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50864. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50865. * * Remember you can only change the shape positions, not their number when updating a polygon
  50866. * @param name defines the name of the mesh
  50867. * @param options defines the options used to create the mesh
  50868. * @param scene defines the hosting scene
  50869. * @param earcutInjection can be used to inject your own earcut reference
  50870. * @returns the polygon mesh
  50871. */
  50872. static CreatePolygon(name: string, options: {
  50873. shape: Vector3[];
  50874. holes?: Vector3[][];
  50875. depth?: number;
  50876. faceUV?: Vector4[];
  50877. faceColors?: Color4[];
  50878. updatable?: boolean;
  50879. sideOrientation?: number;
  50880. frontUVs?: Vector4;
  50881. backUVs?: Vector4;
  50882. }, scene: Scene, earcutInjection?: any): Mesh;
  50883. /**
  50884. * Creates an extruded polygon mesh, with depth in the Y direction.
  50885. * * 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)
  50886. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50887. * @param name defines the name of the mesh
  50888. * @param options defines the options used to create the mesh
  50889. * @param scene defines the hosting scene
  50890. * @param earcutInjection can be used to inject your own earcut reference
  50891. * @returns the polygon mesh
  50892. */
  50893. static ExtrudePolygon(name: string, options: {
  50894. shape: Vector3[];
  50895. holes?: Vector3[][];
  50896. depth?: number;
  50897. faceUV?: Vector4[];
  50898. faceColors?: Color4[];
  50899. updatable?: boolean;
  50900. sideOrientation?: number;
  50901. frontUVs?: Vector4;
  50902. backUVs?: Vector4;
  50903. }, scene: Scene, earcutInjection?: any): Mesh;
  50904. /**
  50905. * Creates a tube mesh.
  50906. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50907. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50908. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50909. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50910. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50911. * * 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)
  50912. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50913. * * 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
  50914. * * 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
  50915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50916. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50917. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50919. * @param name defines the name of the mesh
  50920. * @param options defines the options used to create the mesh
  50921. * @param scene defines the hosting scene
  50922. * @returns the tube mesh
  50923. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50924. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50925. */
  50926. static CreateTube(name: string, options: {
  50927. path: Vector3[];
  50928. radius?: number;
  50929. tessellation?: number;
  50930. radiusFunction?: {
  50931. (i: number, distance: number): number;
  50932. };
  50933. cap?: number;
  50934. arc?: number;
  50935. updatable?: boolean;
  50936. sideOrientation?: number;
  50937. frontUVs?: Vector4;
  50938. backUVs?: Vector4;
  50939. instance?: Mesh;
  50940. invertUV?: boolean;
  50941. }, scene: Scene): Mesh;
  50942. /**
  50943. * Creates a polyhedron mesh
  50944. * * 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
  50945. * * The parameter `size` (positive float, default 1) sets the polygon size
  50946. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50947. * * 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`
  50948. * * 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
  50949. * * 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)`)
  50950. * * 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
  50951. * * 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
  50952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50953. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50955. * @param name defines the name of the mesh
  50956. * @param options defines the options used to create the mesh
  50957. * @param scene defines the hosting scene
  50958. * @returns the polyhedron mesh
  50959. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50960. */
  50961. static CreatePolyhedron(name: string, options: {
  50962. type?: number;
  50963. size?: number;
  50964. sizeX?: number;
  50965. sizeY?: number;
  50966. sizeZ?: number;
  50967. custom?: any;
  50968. faceUV?: Vector4[];
  50969. faceColors?: Color4[];
  50970. flat?: boolean;
  50971. updatable?: boolean;
  50972. sideOrientation?: number;
  50973. frontUVs?: Vector4;
  50974. backUVs?: Vector4;
  50975. }, scene: Scene): Mesh;
  50976. /**
  50977. * Creates a decal mesh.
  50978. * 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
  50979. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50980. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50981. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50982. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50983. * @param name defines the name of the mesh
  50984. * @param sourceMesh defines the mesh where the decal must be applied
  50985. * @param options defines the options used to create the mesh
  50986. * @param scene defines the hosting scene
  50987. * @returns the decal mesh
  50988. * @see https://doc.babylonjs.com/how_to/decals
  50989. */
  50990. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50991. position?: Vector3;
  50992. normal?: Vector3;
  50993. size?: Vector3;
  50994. angle?: number;
  50995. }): Mesh;
  50996. }
  50997. }
  50998. declare module "babylonjs/Meshes/meshSimplification" {
  50999. import { Mesh } from "babylonjs/Meshes/mesh";
  51000. /**
  51001. * A simplifier interface for future simplification implementations
  51002. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51003. */
  51004. export interface ISimplifier {
  51005. /**
  51006. * Simplification of a given mesh according to the given settings.
  51007. * Since this requires computation, it is assumed that the function runs async.
  51008. * @param settings The settings of the simplification, including quality and distance
  51009. * @param successCallback A callback that will be called after the mesh was simplified.
  51010. * @param errorCallback in case of an error, this callback will be called. optional.
  51011. */
  51012. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51013. }
  51014. /**
  51015. * Expected simplification settings.
  51016. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51017. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51018. */
  51019. export interface ISimplificationSettings {
  51020. /**
  51021. * Gets or sets the expected quality
  51022. */
  51023. quality: number;
  51024. /**
  51025. * Gets or sets the distance when this optimized version should be used
  51026. */
  51027. distance: number;
  51028. /**
  51029. * Gets an already optimized mesh
  51030. */
  51031. optimizeMesh?: boolean;
  51032. }
  51033. /**
  51034. * Class used to specify simplification options
  51035. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51036. */
  51037. export class SimplificationSettings implements ISimplificationSettings {
  51038. /** expected quality */
  51039. quality: number;
  51040. /** distance when this optimized version should be used */
  51041. distance: number;
  51042. /** already optimized mesh */
  51043. optimizeMesh?: boolean | undefined;
  51044. /**
  51045. * Creates a SimplificationSettings
  51046. * @param quality expected quality
  51047. * @param distance distance when this optimized version should be used
  51048. * @param optimizeMesh already optimized mesh
  51049. */
  51050. constructor(
  51051. /** expected quality */
  51052. quality: number,
  51053. /** distance when this optimized version should be used */
  51054. distance: number,
  51055. /** already optimized mesh */
  51056. optimizeMesh?: boolean | undefined);
  51057. }
  51058. /**
  51059. * Interface used to define a simplification task
  51060. */
  51061. export interface ISimplificationTask {
  51062. /**
  51063. * Array of settings
  51064. */
  51065. settings: Array<ISimplificationSettings>;
  51066. /**
  51067. * Simplification type
  51068. */
  51069. simplificationType: SimplificationType;
  51070. /**
  51071. * Mesh to simplify
  51072. */
  51073. mesh: Mesh;
  51074. /**
  51075. * Callback called on success
  51076. */
  51077. successCallback?: () => void;
  51078. /**
  51079. * Defines if parallel processing can be used
  51080. */
  51081. parallelProcessing: boolean;
  51082. }
  51083. /**
  51084. * Queue used to order the simplification tasks
  51085. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51086. */
  51087. export class SimplificationQueue {
  51088. private _simplificationArray;
  51089. /**
  51090. * Gets a boolean indicating that the process is still running
  51091. */
  51092. running: boolean;
  51093. /**
  51094. * Creates a new queue
  51095. */
  51096. constructor();
  51097. /**
  51098. * Adds a new simplification task
  51099. * @param task defines a task to add
  51100. */
  51101. addTask(task: ISimplificationTask): void;
  51102. /**
  51103. * Execute next task
  51104. */
  51105. executeNext(): void;
  51106. /**
  51107. * Execute a simplification task
  51108. * @param task defines the task to run
  51109. */
  51110. runSimplification(task: ISimplificationTask): void;
  51111. private getSimplifier;
  51112. }
  51113. /**
  51114. * The implemented types of simplification
  51115. * At the moment only Quadratic Error Decimation is implemented
  51116. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51117. */
  51118. export enum SimplificationType {
  51119. /** Quadratic error decimation */
  51120. QUADRATIC = 0
  51121. }
  51122. }
  51123. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  51124. import { Scene } from "babylonjs/scene";
  51125. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  51126. import { ISceneComponent } from "babylonjs/sceneComponent";
  51127. module "babylonjs/scene" {
  51128. interface Scene {
  51129. /** @hidden (Backing field) */
  51130. _simplificationQueue: SimplificationQueue;
  51131. /**
  51132. * Gets or sets the simplification queue attached to the scene
  51133. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51134. */
  51135. simplificationQueue: SimplificationQueue;
  51136. }
  51137. }
  51138. module "babylonjs/Meshes/mesh" {
  51139. interface Mesh {
  51140. /**
  51141. * Simplify the mesh according to the given array of settings.
  51142. * Function will return immediately and will simplify async
  51143. * @param settings a collection of simplification settings
  51144. * @param parallelProcessing should all levels calculate parallel or one after the other
  51145. * @param simplificationType the type of simplification to run
  51146. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  51147. * @returns the current mesh
  51148. */
  51149. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  51150. }
  51151. }
  51152. /**
  51153. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  51154. * created in a scene
  51155. */
  51156. export class SimplicationQueueSceneComponent implements ISceneComponent {
  51157. /**
  51158. * The component name helpfull to identify the component in the list of scene components.
  51159. */
  51160. readonly name: string;
  51161. /**
  51162. * The scene the component belongs to.
  51163. */
  51164. scene: Scene;
  51165. /**
  51166. * Creates a new instance of the component for the given scene
  51167. * @param scene Defines the scene to register the component in
  51168. */
  51169. constructor(scene: Scene);
  51170. /**
  51171. * Registers the component in a given scene
  51172. */
  51173. register(): void;
  51174. /**
  51175. * Rebuilds the elements related to this component in case of
  51176. * context lost for instance.
  51177. */
  51178. rebuild(): void;
  51179. /**
  51180. * Disposes the component and the associated ressources
  51181. */
  51182. dispose(): void;
  51183. private _beforeCameraUpdate;
  51184. }
  51185. }
  51186. declare module "babylonjs/Meshes/Builders/index" {
  51187. export * from "babylonjs/Meshes/Builders/boxBuilder";
  51188. export * from "babylonjs/Meshes/Builders/discBuilder";
  51189. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  51190. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  51191. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  51192. export * from "babylonjs/Meshes/Builders/torusBuilder";
  51193. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  51194. export * from "babylonjs/Meshes/Builders/linesBuilder";
  51195. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  51196. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  51197. export * from "babylonjs/Meshes/Builders/latheBuilder";
  51198. export * from "babylonjs/Meshes/Builders/planeBuilder";
  51199. export * from "babylonjs/Meshes/Builders/groundBuilder";
  51200. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  51201. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  51202. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  51203. export * from "babylonjs/Meshes/Builders/decalBuilder";
  51204. }
  51205. declare module "babylonjs/Meshes/index" {
  51206. export * from "babylonjs/Meshes/abstractMesh";
  51207. export * from "babylonjs/Meshes/buffer";
  51208. export * from "babylonjs/Meshes/Compression/index";
  51209. export * from "babylonjs/Meshes/csg";
  51210. export * from "babylonjs/Meshes/geometry";
  51211. export * from "babylonjs/Meshes/groundMesh";
  51212. export * from "babylonjs/Meshes/trailMesh";
  51213. export * from "babylonjs/Meshes/instancedMesh";
  51214. export * from "babylonjs/Meshes/linesMesh";
  51215. export * from "babylonjs/Meshes/mesh";
  51216. export * from "babylonjs/Meshes/mesh.vertexData";
  51217. export * from "babylonjs/Meshes/meshBuilder";
  51218. export * from "babylonjs/Meshes/meshSimplification";
  51219. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  51220. export * from "babylonjs/Meshes/polygonMesh";
  51221. export * from "babylonjs/Meshes/subMesh";
  51222. export * from "babylonjs/Meshes/transformNode";
  51223. export * from "babylonjs/Meshes/Builders/index";
  51224. }
  51225. declare module "babylonjs/Morph/index" {
  51226. export * from "babylonjs/Morph/morphTarget";
  51227. export * from "babylonjs/Morph/morphTargetManager";
  51228. }
  51229. declare module "babylonjs/Offline/database" {
  51230. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  51231. /**
  51232. * Class used to enable access to IndexedDB
  51233. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51234. */
  51235. export class Database implements IOfflineProvider {
  51236. private _callbackManifestChecked;
  51237. private _currentSceneUrl;
  51238. private _db;
  51239. private _enableSceneOffline;
  51240. private _enableTexturesOffline;
  51241. private _manifestVersionFound;
  51242. private _mustUpdateRessources;
  51243. private _hasReachedQuota;
  51244. private _isSupported;
  51245. private _idbFactory;
  51246. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51247. private static IsUASupportingBlobStorage;
  51248. /**
  51249. * Gets a boolean indicating if Database storate is enabled (off by default)
  51250. */
  51251. static IDBStorageEnabled: boolean;
  51252. /**
  51253. * Gets a boolean indicating if scene must be saved in the database
  51254. */
  51255. readonly enableSceneOffline: boolean;
  51256. /**
  51257. * Gets a boolean indicating if textures must be saved in the database
  51258. */
  51259. readonly enableTexturesOffline: boolean;
  51260. /**
  51261. * Creates a new Database
  51262. * @param urlToScene defines the url to load the scene
  51263. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51264. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51265. */
  51266. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51267. private static _ParseURL;
  51268. private static _ReturnFullUrlLocation;
  51269. private _checkManifestFile;
  51270. /**
  51271. * Open the database and make it available
  51272. * @param successCallback defines the callback to call on success
  51273. * @param errorCallback defines the callback to call on error
  51274. */
  51275. open(successCallback: () => void, errorCallback: () => void): void;
  51276. /**
  51277. * Loads an image from the database
  51278. * @param url defines the url to load from
  51279. * @param image defines the target DOM image
  51280. */
  51281. loadImage(url: string, image: HTMLImageElement): void;
  51282. private _loadImageFromDBAsync;
  51283. private _saveImageIntoDBAsync;
  51284. private _checkVersionFromDB;
  51285. private _loadVersionFromDBAsync;
  51286. private _saveVersionIntoDBAsync;
  51287. /**
  51288. * Loads a file from database
  51289. * @param url defines the URL to load from
  51290. * @param sceneLoaded defines a callback to call on success
  51291. * @param progressCallBack defines a callback to call when progress changed
  51292. * @param errorCallback defines a callback to call on error
  51293. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51294. */
  51295. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51296. private _loadFileAsync;
  51297. private _saveFileAsync;
  51298. /**
  51299. * Validates if xhr data is correct
  51300. * @param xhr defines the request to validate
  51301. * @param dataType defines the expected data type
  51302. * @returns true if data is correct
  51303. */
  51304. private static _ValidateXHRData;
  51305. }
  51306. }
  51307. declare module "babylonjs/Offline/index" {
  51308. export * from "babylonjs/Offline/database";
  51309. export * from "babylonjs/Offline/IOfflineProvider";
  51310. }
  51311. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  51312. /** @hidden */
  51313. export var gpuUpdateParticlesPixelShader: {
  51314. name: string;
  51315. shader: string;
  51316. };
  51317. }
  51318. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  51319. /** @hidden */
  51320. export var gpuUpdateParticlesVertexShader: {
  51321. name: string;
  51322. shader: string;
  51323. };
  51324. }
  51325. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  51326. /** @hidden */
  51327. export var clipPlaneFragmentDeclaration2: {
  51328. name: string;
  51329. shader: string;
  51330. };
  51331. }
  51332. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  51333. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  51334. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51335. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51336. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51337. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51338. /** @hidden */
  51339. export var gpuRenderParticlesPixelShader: {
  51340. name: string;
  51341. shader: string;
  51342. };
  51343. }
  51344. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  51345. /** @hidden */
  51346. export var clipPlaneVertexDeclaration2: {
  51347. name: string;
  51348. shader: string;
  51349. };
  51350. }
  51351. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  51352. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  51353. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51354. /** @hidden */
  51355. export var gpuRenderParticlesVertexShader: {
  51356. name: string;
  51357. shader: string;
  51358. };
  51359. }
  51360. declare module "babylonjs/Particles/gpuParticleSystem" {
  51361. import { Nullable } from "babylonjs/types";
  51362. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  51363. import { Observable } from "babylonjs/Misc/observable";
  51364. import { Color4, Color3 } from "babylonjs/Maths/math";
  51365. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51366. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  51367. import { Scene, IDisposable } from "babylonjs/scene";
  51368. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  51369. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  51370. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  51371. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  51372. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  51373. /**
  51374. * This represents a GPU particle system in Babylon
  51375. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51376. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51377. */
  51378. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51379. /**
  51380. * The layer mask we are rendering the particles through.
  51381. */
  51382. layerMask: number;
  51383. private _capacity;
  51384. private _activeCount;
  51385. private _currentActiveCount;
  51386. private _accumulatedCount;
  51387. private _renderEffect;
  51388. private _updateEffect;
  51389. private _buffer0;
  51390. private _buffer1;
  51391. private _spriteBuffer;
  51392. private _updateVAO;
  51393. private _renderVAO;
  51394. private _targetIndex;
  51395. private _sourceBuffer;
  51396. private _targetBuffer;
  51397. private _engine;
  51398. private _currentRenderId;
  51399. private _started;
  51400. private _stopped;
  51401. private _timeDelta;
  51402. private _randomTexture;
  51403. private _randomTexture2;
  51404. private _attributesStrideSize;
  51405. private _updateEffectOptions;
  51406. private _randomTextureSize;
  51407. private _actualFrame;
  51408. private readonly _rawTextureWidth;
  51409. /**
  51410. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51411. */
  51412. static readonly IsSupported: boolean;
  51413. /**
  51414. * An event triggered when the system is disposed.
  51415. */
  51416. onDisposeObservable: Observable<GPUParticleSystem>;
  51417. /**
  51418. * Gets the maximum number of particles active at the same time.
  51419. * @returns The max number of active particles.
  51420. */
  51421. getCapacity(): number;
  51422. /**
  51423. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51424. * to override the particles.
  51425. */
  51426. forceDepthWrite: boolean;
  51427. /**
  51428. * Gets or set the number of active particles
  51429. */
  51430. activeParticleCount: number;
  51431. private _preWarmDone;
  51432. /**
  51433. * Is this system ready to be used/rendered
  51434. * @return true if the system is ready
  51435. */
  51436. isReady(): boolean;
  51437. /**
  51438. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51439. * @returns True if it has been started, otherwise false.
  51440. */
  51441. isStarted(): boolean;
  51442. /**
  51443. * Starts the particle system and begins to emit
  51444. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51445. */
  51446. start(delay?: number): void;
  51447. /**
  51448. * Stops the particle system.
  51449. */
  51450. stop(): void;
  51451. /**
  51452. * Remove all active particles
  51453. */
  51454. reset(): void;
  51455. /**
  51456. * Returns the string "GPUParticleSystem"
  51457. * @returns a string containing the class name
  51458. */
  51459. getClassName(): string;
  51460. private _colorGradientsTexture;
  51461. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51462. /**
  51463. * Adds a new color gradient
  51464. * @param gradient defines the gradient to use (between 0 and 1)
  51465. * @param color1 defines the color to affect to the specified gradient
  51466. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51467. * @returns the current particle system
  51468. */
  51469. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51470. /**
  51471. * Remove a specific color gradient
  51472. * @param gradient defines the gradient to remove
  51473. * @returns the current particle system
  51474. */
  51475. removeColorGradient(gradient: number): GPUParticleSystem;
  51476. private _angularSpeedGradientsTexture;
  51477. private _sizeGradientsTexture;
  51478. private _velocityGradientsTexture;
  51479. private _limitVelocityGradientsTexture;
  51480. private _dragGradientsTexture;
  51481. private _addFactorGradient;
  51482. /**
  51483. * Adds a new size gradient
  51484. * @param gradient defines the gradient to use (between 0 and 1)
  51485. * @param factor defines the size factor to affect to the specified gradient
  51486. * @returns the current particle system
  51487. */
  51488. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51489. /**
  51490. * Remove a specific size gradient
  51491. * @param gradient defines the gradient to remove
  51492. * @returns the current particle system
  51493. */
  51494. removeSizeGradient(gradient: number): GPUParticleSystem;
  51495. /**
  51496. * Adds a new angular speed gradient
  51497. * @param gradient defines the gradient to use (between 0 and 1)
  51498. * @param factor defines the angular speed to affect to the specified gradient
  51499. * @returns the current particle system
  51500. */
  51501. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51502. /**
  51503. * Remove a specific angular speed gradient
  51504. * @param gradient defines the gradient to remove
  51505. * @returns the current particle system
  51506. */
  51507. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51508. /**
  51509. * Adds a new velocity gradient
  51510. * @param gradient defines the gradient to use (between 0 and 1)
  51511. * @param factor defines the velocity to affect to the specified gradient
  51512. * @returns the current particle system
  51513. */
  51514. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51515. /**
  51516. * Remove a specific velocity gradient
  51517. * @param gradient defines the gradient to remove
  51518. * @returns the current particle system
  51519. */
  51520. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51521. /**
  51522. * Adds a new limit velocity gradient
  51523. * @param gradient defines the gradient to use (between 0 and 1)
  51524. * @param factor defines the limit velocity value to affect to the specified gradient
  51525. * @returns the current particle system
  51526. */
  51527. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51528. /**
  51529. * Remove a specific limit velocity gradient
  51530. * @param gradient defines the gradient to remove
  51531. * @returns the current particle system
  51532. */
  51533. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51534. /**
  51535. * Adds a new drag gradient
  51536. * @param gradient defines the gradient to use (between 0 and 1)
  51537. * @param factor defines the drag value to affect to the specified gradient
  51538. * @returns the current particle system
  51539. */
  51540. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51541. /**
  51542. * Remove a specific drag gradient
  51543. * @param gradient defines the gradient to remove
  51544. * @returns the current particle system
  51545. */
  51546. removeDragGradient(gradient: number): GPUParticleSystem;
  51547. /**
  51548. * Not supported by GPUParticleSystem
  51549. * @param gradient defines the gradient to use (between 0 and 1)
  51550. * @param factor defines the emit rate value to affect to the specified gradient
  51551. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51552. * @returns the current particle system
  51553. */
  51554. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51555. /**
  51556. * Not supported by GPUParticleSystem
  51557. * @param gradient defines the gradient to remove
  51558. * @returns the current particle system
  51559. */
  51560. removeEmitRateGradient(gradient: number): IParticleSystem;
  51561. /**
  51562. * Not supported by GPUParticleSystem
  51563. * @param gradient defines the gradient to use (between 0 and 1)
  51564. * @param factor defines the start size value to affect to the specified gradient
  51565. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51566. * @returns the current particle system
  51567. */
  51568. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51569. /**
  51570. * Not supported by GPUParticleSystem
  51571. * @param gradient defines the gradient to remove
  51572. * @returns the current particle system
  51573. */
  51574. removeStartSizeGradient(gradient: number): IParticleSystem;
  51575. /**
  51576. * Not supported by GPUParticleSystem
  51577. * @param gradient defines the gradient to use (between 0 and 1)
  51578. * @param min defines the color remap minimal range
  51579. * @param max defines the color remap maximal range
  51580. * @returns the current particle system
  51581. */
  51582. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51583. /**
  51584. * Not supported by GPUParticleSystem
  51585. * @param gradient defines the gradient to remove
  51586. * @returns the current particle system
  51587. */
  51588. removeColorRemapGradient(): IParticleSystem;
  51589. /**
  51590. * Not supported by GPUParticleSystem
  51591. * @param gradient defines the gradient to use (between 0 and 1)
  51592. * @param min defines the alpha remap minimal range
  51593. * @param max defines the alpha remap maximal range
  51594. * @returns the current particle system
  51595. */
  51596. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51597. /**
  51598. * Not supported by GPUParticleSystem
  51599. * @param gradient defines the gradient to remove
  51600. * @returns the current particle system
  51601. */
  51602. removeAlphaRemapGradient(): IParticleSystem;
  51603. /**
  51604. * Not supported by GPUParticleSystem
  51605. * @param gradient defines the gradient to use (between 0 and 1)
  51606. * @param color defines the color to affect to the specified gradient
  51607. * @returns the current particle system
  51608. */
  51609. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51610. /**
  51611. * Not supported by GPUParticleSystem
  51612. * @param gradient defines the gradient to remove
  51613. * @returns the current particle system
  51614. */
  51615. removeRampGradient(): IParticleSystem;
  51616. /**
  51617. * Not supported by GPUParticleSystem
  51618. * @returns the list of ramp gradients
  51619. */
  51620. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51621. /**
  51622. * Not supported by GPUParticleSystem
  51623. * Gets or sets a boolean indicating that ramp gradients must be used
  51624. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51625. */
  51626. useRampGradients: boolean;
  51627. /**
  51628. * Not supported by GPUParticleSystem
  51629. * @param gradient defines the gradient to use (between 0 and 1)
  51630. * @param factor defines the life time factor to affect to the specified gradient
  51631. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51632. * @returns the current particle system
  51633. */
  51634. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51635. /**
  51636. * Not supported by GPUParticleSystem
  51637. * @param gradient defines the gradient to remove
  51638. * @returns the current particle system
  51639. */
  51640. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51641. /**
  51642. * Instantiates a GPU particle system.
  51643. * 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.
  51644. * @param name The name of the particle system
  51645. * @param options The options used to create the system
  51646. * @param scene The scene the particle system belongs to
  51647. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51648. */
  51649. constructor(name: string, options: Partial<{
  51650. capacity: number;
  51651. randomTextureSize: number;
  51652. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51653. protected _reset(): void;
  51654. private _createUpdateVAO;
  51655. private _createRenderVAO;
  51656. private _initialize;
  51657. /** @hidden */
  51658. _recreateUpdateEffect(): void;
  51659. /** @hidden */
  51660. _recreateRenderEffect(): void;
  51661. /**
  51662. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51663. * @param preWarm defines if we are in the pre-warmimg phase
  51664. */
  51665. animate(preWarm?: boolean): void;
  51666. private _createFactorGradientTexture;
  51667. private _createSizeGradientTexture;
  51668. private _createAngularSpeedGradientTexture;
  51669. private _createVelocityGradientTexture;
  51670. private _createLimitVelocityGradientTexture;
  51671. private _createDragGradientTexture;
  51672. private _createColorGradientTexture;
  51673. /**
  51674. * Renders the particle system in its current state
  51675. * @param preWarm defines if the system should only update the particles but not render them
  51676. * @returns the current number of particles
  51677. */
  51678. render(preWarm?: boolean): number;
  51679. /**
  51680. * Rebuilds the particle system
  51681. */
  51682. rebuild(): void;
  51683. private _releaseBuffers;
  51684. private _releaseVAOs;
  51685. /**
  51686. * Disposes the particle system and free the associated resources
  51687. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51688. */
  51689. dispose(disposeTexture?: boolean): void;
  51690. /**
  51691. * Clones the particle system.
  51692. * @param name The name of the cloned object
  51693. * @param newEmitter The new emitter to use
  51694. * @returns the cloned particle system
  51695. */
  51696. clone(name: string, newEmitter: any): GPUParticleSystem;
  51697. /**
  51698. * Serializes the particle system to a JSON object.
  51699. * @returns the JSON object
  51700. */
  51701. serialize(): any;
  51702. /**
  51703. * Parses a JSON object to create a GPU particle system.
  51704. * @param parsedParticleSystem The JSON object to parse
  51705. * @param scene The scene to create the particle system in
  51706. * @param rootUrl The root url to use to load external dependencies like texture
  51707. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51708. * @returns the parsed GPU particle system
  51709. */
  51710. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51711. }
  51712. }
  51713. declare module "babylonjs/Particles/particleSystemSet" {
  51714. import { Nullable } from "babylonjs/types";
  51715. import { Color3 } from "babylonjs/Maths/math";
  51716. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51718. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51719. import { Scene, IDisposable } from "babylonjs/scene";
  51720. /**
  51721. * Represents a set of particle systems working together to create a specific effect
  51722. */
  51723. export class ParticleSystemSet implements IDisposable {
  51724. private _emitterCreationOptions;
  51725. private _emitterNode;
  51726. /**
  51727. * Gets the particle system list
  51728. */
  51729. systems: IParticleSystem[];
  51730. /**
  51731. * Gets the emitter node used with this set
  51732. */
  51733. readonly emitterNode: Nullable<TransformNode>;
  51734. /**
  51735. * Creates a new emitter mesh as a sphere
  51736. * @param options defines the options used to create the sphere
  51737. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51738. * @param scene defines the hosting scene
  51739. */
  51740. setEmitterAsSphere(options: {
  51741. diameter: number;
  51742. segments: number;
  51743. color: Color3;
  51744. }, renderingGroupId: number, scene: Scene): void;
  51745. /**
  51746. * Starts all particle systems of the set
  51747. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51748. */
  51749. start(emitter?: AbstractMesh): void;
  51750. /**
  51751. * Release all associated resources
  51752. */
  51753. dispose(): void;
  51754. /**
  51755. * Serialize the set into a JSON compatible object
  51756. * @returns a JSON compatible representation of the set
  51757. */
  51758. serialize(): any;
  51759. /**
  51760. * Parse a new ParticleSystemSet from a serialized source
  51761. * @param data defines a JSON compatible representation of the set
  51762. * @param scene defines the hosting scene
  51763. * @param gpu defines if we want GPU particles or CPU particles
  51764. * @returns a new ParticleSystemSet
  51765. */
  51766. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51767. }
  51768. }
  51769. declare module "babylonjs/Particles/particleHelper" {
  51770. import { Nullable } from "babylonjs/types";
  51771. import { Scene } from "babylonjs/scene";
  51772. import { Vector3 } from "babylonjs/Maths/math";
  51773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51774. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51775. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  51776. /**
  51777. * This class is made for on one-liner static method to help creating particle system set.
  51778. */
  51779. export class ParticleHelper {
  51780. /**
  51781. * Gets or sets base Assets URL
  51782. */
  51783. static BaseAssetsUrl: string;
  51784. /**
  51785. * Create a default particle system that you can tweak
  51786. * @param emitter defines the emitter to use
  51787. * @param capacity defines the system capacity (default is 500 particles)
  51788. * @param scene defines the hosting scene
  51789. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51790. * @returns the new Particle system
  51791. */
  51792. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51793. /**
  51794. * This is the main static method (one-liner) of this helper to create different particle systems
  51795. * @param type This string represents the type to the particle system to create
  51796. * @param scene The scene where the particle system should live
  51797. * @param gpu If the system will use gpu
  51798. * @returns the ParticleSystemSet created
  51799. */
  51800. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51801. /**
  51802. * Static function used to export a particle system to a ParticleSystemSet variable.
  51803. * Please note that the emitter shape is not exported
  51804. * @param systems defines the particle systems to export
  51805. * @returns the created particle system set
  51806. */
  51807. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51808. }
  51809. }
  51810. declare module "babylonjs/Particles/particleSystemComponent" {
  51811. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51812. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  51813. import "babylonjs/Shaders/particles.vertex";
  51814. module "babylonjs/Engines/engine" {
  51815. interface Engine {
  51816. /**
  51817. * Create an effect to use with particle systems.
  51818. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51819. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51820. * @param uniformsNames defines a list of attribute names
  51821. * @param samplers defines an array of string used to represent textures
  51822. * @param defines defines the string containing the defines to use to compile the shaders
  51823. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51824. * @param onCompiled defines a function to call when the effect creation is successful
  51825. * @param onError defines a function to call when the effect creation has failed
  51826. * @returns the new Effect
  51827. */
  51828. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51829. }
  51830. }
  51831. module "babylonjs/Meshes/mesh" {
  51832. interface Mesh {
  51833. /**
  51834. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51835. * @returns an array of IParticleSystem
  51836. */
  51837. getEmittedParticleSystems(): IParticleSystem[];
  51838. /**
  51839. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51840. * @returns an array of IParticleSystem
  51841. */
  51842. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51843. }
  51844. }
  51845. /**
  51846. * @hidden
  51847. */
  51848. export var _IDoNeedToBeInTheBuild: number;
  51849. }
  51850. declare module "babylonjs/Particles/index" {
  51851. export * from "babylonjs/Particles/baseParticleSystem";
  51852. export * from "babylonjs/Particles/EmitterTypes/index";
  51853. export * from "babylonjs/Particles/gpuParticleSystem";
  51854. export * from "babylonjs/Particles/IParticleSystem";
  51855. export * from "babylonjs/Particles/particle";
  51856. export * from "babylonjs/Particles/particleHelper";
  51857. export * from "babylonjs/Particles/particleSystem";
  51858. export * from "babylonjs/Particles/particleSystemComponent";
  51859. export * from "babylonjs/Particles/particleSystemSet";
  51860. export * from "babylonjs/Particles/solidParticle";
  51861. export * from "babylonjs/Particles/solidParticleSystem";
  51862. export * from "babylonjs/Particles/subEmitter";
  51863. }
  51864. declare module "babylonjs/Physics/physicsEngineComponent" {
  51865. import { Nullable } from "babylonjs/types";
  51866. import { Observable, Observer } from "babylonjs/Misc/observable";
  51867. import { Vector3 } from "babylonjs/Maths/math";
  51868. import { Mesh } from "babylonjs/Meshes/mesh";
  51869. import { ISceneComponent } from "babylonjs/sceneComponent";
  51870. import { Scene } from "babylonjs/scene";
  51871. import { Node } from "babylonjs/node";
  51872. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51873. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51874. module "babylonjs/scene" {
  51875. interface Scene {
  51876. /** @hidden (Backing field) */
  51877. _physicsEngine: Nullable<IPhysicsEngine>;
  51878. /**
  51879. * Gets the current physics engine
  51880. * @returns a IPhysicsEngine or null if none attached
  51881. */
  51882. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51883. /**
  51884. * Enables physics to the current scene
  51885. * @param gravity defines the scene's gravity for the physics engine
  51886. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51887. * @return a boolean indicating if the physics engine was initialized
  51888. */
  51889. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51890. /**
  51891. * Disables and disposes the physics engine associated with the scene
  51892. */
  51893. disablePhysicsEngine(): void;
  51894. /**
  51895. * Gets a boolean indicating if there is an active physics engine
  51896. * @returns a boolean indicating if there is an active physics engine
  51897. */
  51898. isPhysicsEnabled(): boolean;
  51899. /**
  51900. * Deletes a physics compound impostor
  51901. * @param compound defines the compound to delete
  51902. */
  51903. deleteCompoundImpostor(compound: any): void;
  51904. /**
  51905. * An event triggered when physic simulation is about to be run
  51906. */
  51907. onBeforePhysicsObservable: Observable<Scene>;
  51908. /**
  51909. * An event triggered when physic simulation has been done
  51910. */
  51911. onAfterPhysicsObservable: Observable<Scene>;
  51912. }
  51913. }
  51914. module "babylonjs/Meshes/abstractMesh" {
  51915. interface AbstractMesh {
  51916. /** @hidden */
  51917. _physicsImpostor: Nullable<PhysicsImpostor>;
  51918. /**
  51919. * Gets or sets impostor used for physic simulation
  51920. * @see http://doc.babylonjs.com/features/physics_engine
  51921. */
  51922. physicsImpostor: Nullable<PhysicsImpostor>;
  51923. /**
  51924. * Gets the current physics impostor
  51925. * @see http://doc.babylonjs.com/features/physics_engine
  51926. * @returns a physics impostor or null
  51927. */
  51928. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51929. /** Apply a physic impulse to the mesh
  51930. * @param force defines the force to apply
  51931. * @param contactPoint defines where to apply the force
  51932. * @returns the current mesh
  51933. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51934. */
  51935. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51936. /**
  51937. * Creates a physic joint between two meshes
  51938. * @param otherMesh defines the other mesh to use
  51939. * @param pivot1 defines the pivot to use on this mesh
  51940. * @param pivot2 defines the pivot to use on the other mesh
  51941. * @param options defines additional options (can be plugin dependent)
  51942. * @returns the current mesh
  51943. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51944. */
  51945. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51946. /** @hidden */
  51947. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51948. }
  51949. }
  51950. /**
  51951. * Defines the physics engine scene component responsible to manage a physics engine
  51952. */
  51953. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51954. /**
  51955. * The component name helpful to identify the component in the list of scene components.
  51956. */
  51957. readonly name: string;
  51958. /**
  51959. * The scene the component belongs to.
  51960. */
  51961. scene: Scene;
  51962. /**
  51963. * Creates a new instance of the component for the given scene
  51964. * @param scene Defines the scene to register the component in
  51965. */
  51966. constructor(scene: Scene);
  51967. /**
  51968. * Registers the component in a given scene
  51969. */
  51970. register(): void;
  51971. /**
  51972. * Rebuilds the elements related to this component in case of
  51973. * context lost for instance.
  51974. */
  51975. rebuild(): void;
  51976. /**
  51977. * Disposes the component and the associated ressources
  51978. */
  51979. dispose(): void;
  51980. }
  51981. }
  51982. declare module "babylonjs/Physics/physicsHelper" {
  51983. import { Nullable } from "babylonjs/types";
  51984. import { Vector3 } from "babylonjs/Maths/math";
  51985. import { Mesh } from "babylonjs/Meshes/mesh";
  51986. import { Ray } from "babylonjs/Culling/ray";
  51987. import { Scene } from "babylonjs/scene";
  51988. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51989. /**
  51990. * A helper for physics simulations
  51991. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51992. */
  51993. export class PhysicsHelper {
  51994. private _scene;
  51995. private _physicsEngine;
  51996. /**
  51997. * Initializes the Physics helper
  51998. * @param scene Babylon.js scene
  51999. */
  52000. constructor(scene: Scene);
  52001. /**
  52002. * Applies a radial explosion impulse
  52003. * @param origin the origin of the explosion
  52004. * @param radius the explosion radius
  52005. * @param strength the explosion strength
  52006. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52007. * @returns A physics radial explosion event, or null
  52008. */
  52009. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52010. /**
  52011. * Applies a radial explosion force
  52012. * @param origin the origin of the explosion
  52013. * @param radius the explosion radius
  52014. * @param strength the explosion strength
  52015. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52016. * @returns A physics radial explosion event, or null
  52017. */
  52018. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52019. /**
  52020. * Creates a gravitational field
  52021. * @param origin the origin of the explosion
  52022. * @param radius the explosion radius
  52023. * @param strength the explosion strength
  52024. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52025. * @returns A physics gravitational field event, or null
  52026. */
  52027. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  52028. /**
  52029. * Creates a physics updraft event
  52030. * @param origin the origin of the updraft
  52031. * @param radius the radius of the updraft
  52032. * @param strength the strength of the updraft
  52033. * @param height the height of the updraft
  52034. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  52035. * @returns A physics updraft event, or null
  52036. */
  52037. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  52038. /**
  52039. * Creates a physics vortex event
  52040. * @param origin the of the vortex
  52041. * @param radius the radius of the vortex
  52042. * @param strength the strength of the vortex
  52043. * @param height the height of the vortex
  52044. * @returns a Physics vortex event, or null
  52045. * A physics vortex event or null
  52046. */
  52047. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  52048. }
  52049. /**
  52050. * Represents a physics radial explosion event
  52051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52052. */
  52053. export class PhysicsRadialExplosionEvent {
  52054. private _scene;
  52055. private _sphere;
  52056. private _sphereOptions;
  52057. private _rays;
  52058. private _dataFetched;
  52059. /**
  52060. * Initializes a radial explosioin event
  52061. * @param scene BabylonJS scene
  52062. */
  52063. constructor(scene: Scene);
  52064. /**
  52065. * Returns the data related to the radial explosion event (sphere & rays).
  52066. * @returns The radial explosion event data
  52067. */
  52068. getData(): PhysicsRadialExplosionEventData;
  52069. /**
  52070. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  52071. * @param impostor A physics imposter
  52072. * @param origin the origin of the explosion
  52073. * @param radius the explosion radius
  52074. * @param strength the explosion strength
  52075. * @param falloff possible options: Constant & Linear
  52076. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  52077. */
  52078. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  52079. /**
  52080. * Disposes the sphere.
  52081. * @param force Specifies if the sphere should be disposed by force
  52082. */
  52083. dispose(force?: boolean): void;
  52084. /*** Helpers ***/
  52085. private _prepareSphere;
  52086. private _intersectsWithSphere;
  52087. }
  52088. /**
  52089. * Represents a gravitational field event
  52090. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52091. */
  52092. export class PhysicsGravitationalFieldEvent {
  52093. private _physicsHelper;
  52094. private _scene;
  52095. private _origin;
  52096. private _radius;
  52097. private _strength;
  52098. private _falloff;
  52099. private _tickCallback;
  52100. private _sphere;
  52101. private _dataFetched;
  52102. /**
  52103. * Initializes the physics gravitational field event
  52104. * @param physicsHelper A physics helper
  52105. * @param scene BabylonJS scene
  52106. * @param origin The origin position of the gravitational field event
  52107. * @param radius The radius of the gravitational field event
  52108. * @param strength The strength of the gravitational field event
  52109. * @param falloff The falloff for the gravitational field event
  52110. */
  52111. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  52112. /**
  52113. * Returns the data related to the gravitational field event (sphere).
  52114. * @returns A gravitational field event
  52115. */
  52116. getData(): PhysicsGravitationalFieldEventData;
  52117. /**
  52118. * Enables the gravitational field.
  52119. */
  52120. enable(): void;
  52121. /**
  52122. * Disables the gravitational field.
  52123. */
  52124. disable(): void;
  52125. /**
  52126. * Disposes the sphere.
  52127. * @param force The force to dispose from the gravitational field event
  52128. */
  52129. dispose(force?: boolean): void;
  52130. private _tick;
  52131. }
  52132. /**
  52133. * Represents a physics updraft event
  52134. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52135. */
  52136. export class PhysicsUpdraftEvent {
  52137. private _scene;
  52138. private _origin;
  52139. private _radius;
  52140. private _strength;
  52141. private _height;
  52142. private _updraftMode;
  52143. private _physicsEngine;
  52144. private _originTop;
  52145. private _originDirection;
  52146. private _tickCallback;
  52147. private _cylinder;
  52148. private _cylinderPosition;
  52149. private _dataFetched;
  52150. /**
  52151. * Initializes the physics updraft event
  52152. * @param _scene BabylonJS scene
  52153. * @param _origin The origin position of the updraft
  52154. * @param _radius The radius of the updraft
  52155. * @param _strength The strength of the updraft
  52156. * @param _height The height of the updraft
  52157. * @param _updraftMode The mode of the updraft
  52158. */
  52159. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  52160. /**
  52161. * Returns the data related to the updraft event (cylinder).
  52162. * @returns A physics updraft event
  52163. */
  52164. getData(): PhysicsUpdraftEventData;
  52165. /**
  52166. * Enables the updraft.
  52167. */
  52168. enable(): void;
  52169. /**
  52170. * Disables the cortex.
  52171. */
  52172. disable(): void;
  52173. /**
  52174. * Disposes the sphere.
  52175. * @param force Specifies if the updraft should be disposed by force
  52176. */
  52177. dispose(force?: boolean): void;
  52178. private getImpostorForceAndContactPoint;
  52179. private _tick;
  52180. /*** Helpers ***/
  52181. private _prepareCylinder;
  52182. private _intersectsWithCylinder;
  52183. }
  52184. /**
  52185. * Represents a physics vortex event
  52186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52187. */
  52188. export class PhysicsVortexEvent {
  52189. private _scene;
  52190. private _origin;
  52191. private _radius;
  52192. private _strength;
  52193. private _height;
  52194. private _physicsEngine;
  52195. private _originTop;
  52196. private _centripetalForceThreshold;
  52197. private _updraftMultiplier;
  52198. private _tickCallback;
  52199. private _cylinder;
  52200. private _cylinderPosition;
  52201. private _dataFetched;
  52202. /**
  52203. * Initializes the physics vortex event
  52204. * @param _scene The BabylonJS scene
  52205. * @param _origin The origin position of the vortex
  52206. * @param _radius The radius of the vortex
  52207. * @param _strength The strength of the vortex
  52208. * @param _height The height of the vortex
  52209. */
  52210. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  52211. /**
  52212. * Returns the data related to the vortex event (cylinder).
  52213. * @returns The physics vortex event data
  52214. */
  52215. getData(): PhysicsVortexEventData;
  52216. /**
  52217. * Enables the vortex.
  52218. */
  52219. enable(): void;
  52220. /**
  52221. * Disables the cortex.
  52222. */
  52223. disable(): void;
  52224. /**
  52225. * Disposes the sphere.
  52226. * @param force
  52227. */
  52228. dispose(force?: boolean): void;
  52229. private getImpostorForceAndContactPoint;
  52230. private _tick;
  52231. /*** Helpers ***/
  52232. private _prepareCylinder;
  52233. private _intersectsWithCylinder;
  52234. }
  52235. /**
  52236. * The strenght of the force in correspondence to the distance of the affected object
  52237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52238. */
  52239. export enum PhysicsRadialImpulseFalloff {
  52240. /** Defines that impulse is constant in strength across it's whole radius */
  52241. Constant = 0,
  52242. /** DEfines that impulse gets weaker if it's further from the origin */
  52243. Linear = 1
  52244. }
  52245. /**
  52246. * The strength of the force in correspondence to the distance of the affected object
  52247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52248. */
  52249. export enum PhysicsUpdraftMode {
  52250. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52251. Center = 0,
  52252. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52253. Perpendicular = 1
  52254. }
  52255. /**
  52256. * Interface for a physics force and contact point
  52257. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52258. */
  52259. export interface PhysicsForceAndContactPoint {
  52260. /**
  52261. * The force applied at the contact point
  52262. */
  52263. force: Vector3;
  52264. /**
  52265. * The contact point
  52266. */
  52267. contactPoint: Vector3;
  52268. }
  52269. /**
  52270. * Interface for radial explosion event data
  52271. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52272. */
  52273. export interface PhysicsRadialExplosionEventData {
  52274. /**
  52275. * A sphere used for the radial explosion event
  52276. */
  52277. sphere: Mesh;
  52278. /**
  52279. * An array of rays for the radial explosion event
  52280. */
  52281. rays: Array<Ray>;
  52282. }
  52283. /**
  52284. * Interface for gravitational field event data
  52285. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52286. */
  52287. export interface PhysicsGravitationalFieldEventData {
  52288. /**
  52289. * A sphere mesh used for the gravitational field event
  52290. */
  52291. sphere: Mesh;
  52292. }
  52293. /**
  52294. * Interface for updraft event data
  52295. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52296. */
  52297. export interface PhysicsUpdraftEventData {
  52298. /**
  52299. * A cylinder used for the updraft event
  52300. */
  52301. cylinder: Mesh;
  52302. }
  52303. /**
  52304. * Interface for vortex event data
  52305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52306. */
  52307. export interface PhysicsVortexEventData {
  52308. /**
  52309. * A cylinder used for the vortex event
  52310. */
  52311. cylinder: Mesh;
  52312. }
  52313. }
  52314. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52315. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  52316. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52317. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52318. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52319. import { Nullable } from "babylonjs/types";
  52320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52321. /**
  52322. * AmmoJS Physics plugin
  52323. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52324. * @see https://github.com/kripken/ammo.js/
  52325. */
  52326. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52327. private _useDeltaForWorldStep;
  52328. /**
  52329. * Reference to the Ammo library
  52330. */
  52331. bjsAMMO: any;
  52332. /**
  52333. * Created ammoJS world which physics bodies are added to
  52334. */
  52335. world: any;
  52336. /**
  52337. * Name of the plugin
  52338. */
  52339. name: string;
  52340. private _timeStep;
  52341. private _fixedTimeStep;
  52342. private _maxSteps;
  52343. private _tmpQuaternion;
  52344. private _tmpAmmoTransform;
  52345. private _tmpAmmoQuaternion;
  52346. private _tmpAmmoConcreteContactResultCallback;
  52347. private _collisionConfiguration;
  52348. private _dispatcher;
  52349. private _overlappingPairCache;
  52350. private _solver;
  52351. private _tmpAmmoVectorA;
  52352. private _tmpAmmoVectorB;
  52353. private _tmpAmmoVectorC;
  52354. private _tmpContactCallbackResult;
  52355. private static readonly DISABLE_COLLISION_FLAG;
  52356. private static readonly KINEMATIC_FLAG;
  52357. private static readonly DISABLE_DEACTIVATION_FLAG;
  52358. /**
  52359. * Initializes the ammoJS plugin
  52360. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52361. * @param ammoInjection can be used to inject your own ammo reference
  52362. */
  52363. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  52364. /**
  52365. * Sets the gravity of the physics world (m/(s^2))
  52366. * @param gravity Gravity to set
  52367. */
  52368. setGravity(gravity: Vector3): void;
  52369. /**
  52370. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52371. * @param timeStep timestep to use in seconds
  52372. */
  52373. setTimeStep(timeStep: number): void;
  52374. /**
  52375. * 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)
  52376. * @param fixedTimeStep fixedTimeStep to use in seconds
  52377. */
  52378. setFixedTimeStep(fixedTimeStep: number): void;
  52379. /**
  52380. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52381. * @param maxSteps the maximum number of steps by the physics engine per frame
  52382. */
  52383. setMaxSteps(maxSteps: number): void;
  52384. /**
  52385. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52386. * @returns the current timestep in seconds
  52387. */
  52388. getTimeStep(): number;
  52389. private _isImpostorInContact;
  52390. private _isImpostorPairInContact;
  52391. private _stepSimulation;
  52392. /**
  52393. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52394. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52395. * After the step the babylon meshes are set to the position of the physics imposters
  52396. * @param delta amount of time to step forward
  52397. * @param impostors array of imposters to update before/after the step
  52398. */
  52399. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52400. private _tmpVector;
  52401. private _tmpMatrix;
  52402. /**
  52403. * Applies an implulse on the imposter
  52404. * @param impostor imposter to apply impulse
  52405. * @param force amount of force to be applied to the imposter
  52406. * @param contactPoint the location to apply the impulse on the imposter
  52407. */
  52408. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52409. /**
  52410. * Applies a force on the imposter
  52411. * @param impostor imposter to apply force
  52412. * @param force amount of force to be applied to the imposter
  52413. * @param contactPoint the location to apply the force on the imposter
  52414. */
  52415. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52416. /**
  52417. * Creates a physics body using the plugin
  52418. * @param impostor the imposter to create the physics body on
  52419. */
  52420. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52421. /**
  52422. * Removes the physics body from the imposter and disposes of the body's memory
  52423. * @param impostor imposter to remove the physics body from
  52424. */
  52425. removePhysicsBody(impostor: PhysicsImpostor): void;
  52426. /**
  52427. * Generates a joint
  52428. * @param impostorJoint the imposter joint to create the joint with
  52429. */
  52430. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52431. /**
  52432. * Removes a joint
  52433. * @param impostorJoint the imposter joint to remove the joint from
  52434. */
  52435. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52436. private _addMeshVerts;
  52437. private _createShape;
  52438. /**
  52439. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52440. * @param impostor imposter containing the physics body and babylon object
  52441. */
  52442. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52443. /**
  52444. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52445. * @param impostor imposter containing the physics body and babylon object
  52446. * @param newPosition new position
  52447. * @param newRotation new rotation
  52448. */
  52449. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52450. /**
  52451. * If this plugin is supported
  52452. * @returns true if its supported
  52453. */
  52454. isSupported(): boolean;
  52455. /**
  52456. * Sets the linear velocity of the physics body
  52457. * @param impostor imposter to set the velocity on
  52458. * @param velocity velocity to set
  52459. */
  52460. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52461. /**
  52462. * Sets the angular velocity of the physics body
  52463. * @param impostor imposter to set the velocity on
  52464. * @param velocity velocity to set
  52465. */
  52466. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52467. /**
  52468. * gets the linear velocity
  52469. * @param impostor imposter to get linear velocity from
  52470. * @returns linear velocity
  52471. */
  52472. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52473. /**
  52474. * gets the angular velocity
  52475. * @param impostor imposter to get angular velocity from
  52476. * @returns angular velocity
  52477. */
  52478. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52479. /**
  52480. * Sets the mass of physics body
  52481. * @param impostor imposter to set the mass on
  52482. * @param mass mass to set
  52483. */
  52484. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52485. /**
  52486. * Gets the mass of the physics body
  52487. * @param impostor imposter to get the mass from
  52488. * @returns mass
  52489. */
  52490. getBodyMass(impostor: PhysicsImpostor): number;
  52491. /**
  52492. * Gets friction of the impostor
  52493. * @param impostor impostor to get friction from
  52494. * @returns friction value
  52495. */
  52496. getBodyFriction(impostor: PhysicsImpostor): number;
  52497. /**
  52498. * Sets friction of the impostor
  52499. * @param impostor impostor to set friction on
  52500. * @param friction friction value
  52501. */
  52502. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52503. /**
  52504. * Gets restitution of the impostor
  52505. * @param impostor impostor to get restitution from
  52506. * @returns restitution value
  52507. */
  52508. getBodyRestitution(impostor: PhysicsImpostor): number;
  52509. /**
  52510. * Sets resitution of the impostor
  52511. * @param impostor impostor to set resitution on
  52512. * @param restitution resitution value
  52513. */
  52514. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52515. /**
  52516. * Sleeps the physics body and stops it from being active
  52517. * @param impostor impostor to sleep
  52518. */
  52519. sleepBody(impostor: PhysicsImpostor): void;
  52520. /**
  52521. * Activates the physics body
  52522. * @param impostor impostor to activate
  52523. */
  52524. wakeUpBody(impostor: PhysicsImpostor): void;
  52525. /**
  52526. * Updates the distance parameters of the joint
  52527. * @param joint joint to update
  52528. * @param maxDistance maximum distance of the joint
  52529. * @param minDistance minimum distance of the joint
  52530. */
  52531. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52532. /**
  52533. * Sets a motor on the joint
  52534. * @param joint joint to set motor on
  52535. * @param speed speed of the motor
  52536. * @param maxForce maximum force of the motor
  52537. * @param motorIndex index of the motor
  52538. */
  52539. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52540. /**
  52541. * Sets the motors limit
  52542. * @param joint joint to set limit on
  52543. * @param upperLimit upper limit
  52544. * @param lowerLimit lower limit
  52545. */
  52546. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52547. /**
  52548. * Syncs the position and rotation of a mesh with the impostor
  52549. * @param mesh mesh to sync
  52550. * @param impostor impostor to update the mesh with
  52551. */
  52552. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52553. /**
  52554. * Gets the radius of the impostor
  52555. * @param impostor impostor to get radius from
  52556. * @returns the radius
  52557. */
  52558. getRadius(impostor: PhysicsImpostor): number;
  52559. /**
  52560. * Gets the box size of the impostor
  52561. * @param impostor impostor to get box size from
  52562. * @param result the resulting box size
  52563. */
  52564. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52565. /**
  52566. * Disposes of the impostor
  52567. */
  52568. dispose(): void;
  52569. }
  52570. }
  52571. declare module "babylonjs/Physics/Plugins/index" {
  52572. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  52573. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  52574. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  52575. }
  52576. declare module "babylonjs/Physics/index" {
  52577. export * from "babylonjs/Physics/IPhysicsEngine";
  52578. export * from "babylonjs/Physics/physicsEngine";
  52579. export * from "babylonjs/Physics/physicsEngineComponent";
  52580. export * from "babylonjs/Physics/physicsHelper";
  52581. export * from "babylonjs/Physics/physicsImpostor";
  52582. export * from "babylonjs/Physics/physicsJoint";
  52583. export * from "babylonjs/Physics/Plugins/index";
  52584. }
  52585. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  52586. /** @hidden */
  52587. export var blackAndWhitePixelShader: {
  52588. name: string;
  52589. shader: string;
  52590. };
  52591. }
  52592. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  52593. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52594. import { Camera } from "babylonjs/Cameras/camera";
  52595. import { Engine } from "babylonjs/Engines/engine";
  52596. import "babylonjs/Shaders/blackAndWhite.fragment";
  52597. /**
  52598. * Post process used to render in black and white
  52599. */
  52600. export class BlackAndWhitePostProcess extends PostProcess {
  52601. /**
  52602. * Linear about to convert he result to black and white (default: 1)
  52603. */
  52604. degree: number;
  52605. /**
  52606. * Creates a black and white post process
  52607. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  52608. * @param name The name of the effect.
  52609. * @param options The required width/height ratio to downsize to before computing the render pass.
  52610. * @param camera The camera to apply the render pass to.
  52611. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52612. * @param engine The engine which the post process will be applied. (default: current engine)
  52613. * @param reusable If the post process can be reused on the same frame. (default: false)
  52614. */
  52615. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52616. }
  52617. }
  52618. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  52619. import { Nullable } from "babylonjs/types";
  52620. import { Camera } from "babylonjs/Cameras/camera";
  52621. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52622. import { Engine } from "babylonjs/Engines/engine";
  52623. /**
  52624. * This represents a set of one or more post processes in Babylon.
  52625. * A post process can be used to apply a shader to a texture after it is rendered.
  52626. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52627. */
  52628. export class PostProcessRenderEffect {
  52629. private _postProcesses;
  52630. private _getPostProcesses;
  52631. private _singleInstance;
  52632. private _cameras;
  52633. private _indicesForCamera;
  52634. /**
  52635. * Name of the effect
  52636. * @hidden
  52637. */
  52638. _name: string;
  52639. /**
  52640. * Instantiates a post process render effect.
  52641. * A post process can be used to apply a shader to a texture after it is rendered.
  52642. * @param engine The engine the effect is tied to
  52643. * @param name The name of the effect
  52644. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  52645. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  52646. */
  52647. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  52648. /**
  52649. * Checks if all the post processes in the effect are supported.
  52650. */
  52651. readonly isSupported: boolean;
  52652. /**
  52653. * Updates the current state of the effect
  52654. * @hidden
  52655. */
  52656. _update(): void;
  52657. /**
  52658. * Attaches the effect on cameras
  52659. * @param cameras The camera to attach to.
  52660. * @hidden
  52661. */
  52662. _attachCameras(cameras: Camera): void;
  52663. /**
  52664. * Attaches the effect on cameras
  52665. * @param cameras The camera to attach to.
  52666. * @hidden
  52667. */
  52668. _attachCameras(cameras: Camera[]): void;
  52669. /**
  52670. * Detatches the effect on cameras
  52671. * @param cameras The camera to detatch from.
  52672. * @hidden
  52673. */
  52674. _detachCameras(cameras: Camera): void;
  52675. /**
  52676. * Detatches the effect on cameras
  52677. * @param cameras The camera to detatch from.
  52678. * @hidden
  52679. */
  52680. _detachCameras(cameras: Camera[]): void;
  52681. /**
  52682. * Enables the effect on given cameras
  52683. * @param cameras The camera to enable.
  52684. * @hidden
  52685. */
  52686. _enable(cameras: Camera): void;
  52687. /**
  52688. * Enables the effect on given cameras
  52689. * @param cameras The camera to enable.
  52690. * @hidden
  52691. */
  52692. _enable(cameras: Nullable<Camera[]>): void;
  52693. /**
  52694. * Disables the effect on the given cameras
  52695. * @param cameras The camera to disable.
  52696. * @hidden
  52697. */
  52698. _disable(cameras: Camera): void;
  52699. /**
  52700. * Disables the effect on the given cameras
  52701. * @param cameras The camera to disable.
  52702. * @hidden
  52703. */
  52704. _disable(cameras: Nullable<Camera[]>): void;
  52705. /**
  52706. * Gets a list of the post processes contained in the effect.
  52707. * @param camera The camera to get the post processes on.
  52708. * @returns The list of the post processes in the effect.
  52709. */
  52710. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52711. }
  52712. }
  52713. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  52714. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52715. /** @hidden */
  52716. export var extractHighlightsPixelShader: {
  52717. name: string;
  52718. shader: string;
  52719. };
  52720. }
  52721. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  52722. import { Nullable } from "babylonjs/types";
  52723. import { Camera } from "babylonjs/Cameras/camera";
  52724. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52725. import { Engine } from "babylonjs/Engines/engine";
  52726. import "babylonjs/Shaders/extractHighlights.fragment";
  52727. /**
  52728. * 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.
  52729. */
  52730. export class ExtractHighlightsPostProcess extends PostProcess {
  52731. /**
  52732. * The luminance threshold, pixels below this value will be set to black.
  52733. */
  52734. threshold: number;
  52735. /** @hidden */
  52736. _exposure: number;
  52737. /**
  52738. * Post process which has the input texture to be used when performing highlight extraction
  52739. * @hidden
  52740. */
  52741. _inputPostProcess: Nullable<PostProcess>;
  52742. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52743. }
  52744. }
  52745. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  52746. /** @hidden */
  52747. export var bloomMergePixelShader: {
  52748. name: string;
  52749. shader: string;
  52750. };
  52751. }
  52752. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  52753. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52754. import { Nullable } from "babylonjs/types";
  52755. import { Engine } from "babylonjs/Engines/engine";
  52756. import { Camera } from "babylonjs/Cameras/camera";
  52757. import "babylonjs/Shaders/bloomMerge.fragment";
  52758. /**
  52759. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52760. */
  52761. export class BloomMergePostProcess extends PostProcess {
  52762. /** Weight of the bloom to be added to the original input. */
  52763. weight: number;
  52764. /**
  52765. * Creates a new instance of @see BloomMergePostProcess
  52766. * @param name The name of the effect.
  52767. * @param originalFromInput Post process which's input will be used for the merge.
  52768. * @param blurred Blurred highlights post process which's output will be used.
  52769. * @param weight Weight of the bloom to be added to the original input.
  52770. * @param options The required width/height ratio to downsize to before computing the render pass.
  52771. * @param camera The camera to apply the render pass to.
  52772. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52773. * @param engine The engine which the post process will be applied. (default: current engine)
  52774. * @param reusable If the post process can be reused on the same frame. (default: false)
  52775. * @param textureType Type of textures used when performing the post process. (default: 0)
  52776. * @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)
  52777. */
  52778. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52779. /** Weight of the bloom to be added to the original input. */
  52780. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52781. }
  52782. }
  52783. declare module "babylonjs/PostProcesses/bloomEffect" {
  52784. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52785. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52786. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  52787. import { Camera } from "babylonjs/Cameras/camera";
  52788. import { Scene } from "babylonjs/scene";
  52789. /**
  52790. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52791. */
  52792. export class BloomEffect extends PostProcessRenderEffect {
  52793. private bloomScale;
  52794. /**
  52795. * @hidden Internal
  52796. */
  52797. _effects: Array<PostProcess>;
  52798. /**
  52799. * @hidden Internal
  52800. */
  52801. _downscale: ExtractHighlightsPostProcess;
  52802. private _blurX;
  52803. private _blurY;
  52804. private _merge;
  52805. /**
  52806. * The luminance threshold to find bright areas of the image to bloom.
  52807. */
  52808. threshold: number;
  52809. /**
  52810. * The strength of the bloom.
  52811. */
  52812. weight: number;
  52813. /**
  52814. * Specifies the size of the bloom blur kernel, relative to the final output size
  52815. */
  52816. kernel: number;
  52817. /**
  52818. * Creates a new instance of @see BloomEffect
  52819. * @param scene The scene the effect belongs to.
  52820. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52821. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52822. * @param bloomWeight The the strength of bloom.
  52823. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52824. * @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)
  52825. */
  52826. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52827. /**
  52828. * Disposes each of the internal effects for a given camera.
  52829. * @param camera The camera to dispose the effect on.
  52830. */
  52831. disposeEffects(camera: Camera): void;
  52832. /**
  52833. * @hidden Internal
  52834. */
  52835. _updateEffects(): void;
  52836. /**
  52837. * Internal
  52838. * @returns if all the contained post processes are ready.
  52839. * @hidden
  52840. */
  52841. _isReady(): boolean;
  52842. }
  52843. }
  52844. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  52845. /** @hidden */
  52846. export var chromaticAberrationPixelShader: {
  52847. name: string;
  52848. shader: string;
  52849. };
  52850. }
  52851. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  52852. import { Vector2 } from "babylonjs/Maths/math";
  52853. import { Nullable } from "babylonjs/types";
  52854. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52855. import { Camera } from "babylonjs/Cameras/camera";
  52856. import { Engine } from "babylonjs/Engines/engine";
  52857. import "babylonjs/Shaders/chromaticAberration.fragment";
  52858. /**
  52859. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52860. */
  52861. export class ChromaticAberrationPostProcess extends PostProcess {
  52862. /**
  52863. * The amount of seperation of rgb channels (default: 30)
  52864. */
  52865. aberrationAmount: number;
  52866. /**
  52867. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52868. */
  52869. radialIntensity: number;
  52870. /**
  52871. * 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))
  52872. */
  52873. direction: Vector2;
  52874. /**
  52875. * 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))
  52876. */
  52877. centerPosition: Vector2;
  52878. /**
  52879. * Creates a new instance ChromaticAberrationPostProcess
  52880. * @param name The name of the effect.
  52881. * @param screenWidth The width of the screen to apply the effect on.
  52882. * @param screenHeight The height of the screen to apply the effect on.
  52883. * @param options The required width/height ratio to downsize to before computing the render pass.
  52884. * @param camera The camera to apply the render pass to.
  52885. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52886. * @param engine The engine which the post process will be applied. (default: current engine)
  52887. * @param reusable If the post process can be reused on the same frame. (default: false)
  52888. * @param textureType Type of textures used when performing the post process. (default: 0)
  52889. * @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)
  52890. */
  52891. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52892. }
  52893. }
  52894. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  52895. /** @hidden */
  52896. export var circleOfConfusionPixelShader: {
  52897. name: string;
  52898. shader: string;
  52899. };
  52900. }
  52901. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  52902. import { Nullable } from "babylonjs/types";
  52903. import { Engine } from "babylonjs/Engines/engine";
  52904. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52905. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52906. import { Camera } from "babylonjs/Cameras/camera";
  52907. import "babylonjs/Shaders/circleOfConfusion.fragment";
  52908. /**
  52909. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52910. */
  52911. export class CircleOfConfusionPostProcess extends PostProcess {
  52912. /**
  52913. * 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.
  52914. */
  52915. lensSize: number;
  52916. /**
  52917. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52918. */
  52919. fStop: number;
  52920. /**
  52921. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52922. */
  52923. focusDistance: number;
  52924. /**
  52925. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52926. */
  52927. focalLength: number;
  52928. private _depthTexture;
  52929. /**
  52930. * Creates a new instance CircleOfConfusionPostProcess
  52931. * @param name The name of the effect.
  52932. * @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.
  52933. * @param options The required width/height ratio to downsize to before computing the render pass.
  52934. * @param camera The camera to apply the render pass to.
  52935. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52936. * @param engine The engine which the post process will be applied. (default: current engine)
  52937. * @param reusable If the post process can be reused on the same frame. (default: false)
  52938. * @param textureType Type of textures used when performing the post process. (default: 0)
  52939. * @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)
  52940. */
  52941. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52942. /**
  52943. * 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.
  52944. */
  52945. depthTexture: RenderTargetTexture;
  52946. }
  52947. }
  52948. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  52949. /** @hidden */
  52950. export var colorCorrectionPixelShader: {
  52951. name: string;
  52952. shader: string;
  52953. };
  52954. }
  52955. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  52956. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52957. import { Engine } from "babylonjs/Engines/engine";
  52958. import { Camera } from "babylonjs/Cameras/camera";
  52959. import "babylonjs/Shaders/colorCorrection.fragment";
  52960. /**
  52961. *
  52962. * This post-process allows the modification of rendered colors by using
  52963. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52964. *
  52965. * The object needs to be provided an url to a texture containing the color
  52966. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52967. * Use an image editing software to tweak the LUT to match your needs.
  52968. *
  52969. * For an example of a color LUT, see here:
  52970. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  52971. * For explanations on color grading, see here:
  52972. * @see http://udn.epicgames.com/Three/ColorGrading.html
  52973. *
  52974. */
  52975. export class ColorCorrectionPostProcess extends PostProcess {
  52976. private _colorTableTexture;
  52977. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52978. }
  52979. }
  52980. declare module "babylonjs/Shaders/convolution.fragment" {
  52981. /** @hidden */
  52982. export var convolutionPixelShader: {
  52983. name: string;
  52984. shader: string;
  52985. };
  52986. }
  52987. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  52988. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52989. import { Nullable } from "babylonjs/types";
  52990. import { Camera } from "babylonjs/Cameras/camera";
  52991. import { Engine } from "babylonjs/Engines/engine";
  52992. import "babylonjs/Shaders/convolution.fragment";
  52993. /**
  52994. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  52995. * input texture to perform effects such as edge detection or sharpening
  52996. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52997. */
  52998. export class ConvolutionPostProcess extends PostProcess {
  52999. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53000. kernel: number[];
  53001. /**
  53002. * Creates a new instance ConvolutionPostProcess
  53003. * @param name The name of the effect.
  53004. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  53005. * @param options The required width/height ratio to downsize to before computing the render pass.
  53006. * @param camera The camera to apply the render pass to.
  53007. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53008. * @param engine The engine which the post process will be applied. (default: current engine)
  53009. * @param reusable If the post process can be reused on the same frame. (default: false)
  53010. * @param textureType Type of textures used when performing the post process. (default: 0)
  53011. */
  53012. constructor(name: string,
  53013. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53014. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53015. /**
  53016. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53017. */
  53018. static EdgeDetect0Kernel: number[];
  53019. /**
  53020. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53021. */
  53022. static EdgeDetect1Kernel: number[];
  53023. /**
  53024. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53025. */
  53026. static EdgeDetect2Kernel: number[];
  53027. /**
  53028. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53029. */
  53030. static SharpenKernel: number[];
  53031. /**
  53032. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53033. */
  53034. static EmbossKernel: number[];
  53035. /**
  53036. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53037. */
  53038. static GaussianKernel: number[];
  53039. }
  53040. }
  53041. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  53042. import { Nullable } from "babylonjs/types";
  53043. import { Vector2 } from "babylonjs/Maths/math";
  53044. import { Camera } from "babylonjs/Cameras/camera";
  53045. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53046. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53047. import { Engine } from "babylonjs/Engines/engine";
  53048. import { Scene } from "babylonjs/scene";
  53049. /**
  53050. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  53051. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  53052. * based on samples that have a large difference in distance than the center pixel.
  53053. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  53054. */
  53055. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  53056. direction: Vector2;
  53057. /**
  53058. * Creates a new instance CircleOfConfusionPostProcess
  53059. * @param name The name of the effect.
  53060. * @param scene The scene the effect belongs to.
  53061. * @param direction The direction the blur should be applied.
  53062. * @param kernel The size of the kernel used to blur.
  53063. * @param options The required width/height ratio to downsize to before computing the render pass.
  53064. * @param camera The camera to apply the render pass to.
  53065. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  53066. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  53067. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53068. * @param engine The engine which the post process will be applied. (default: current engine)
  53069. * @param reusable If the post process can be reused on the same frame. (default: false)
  53070. * @param textureType Type of textures used when performing the post process. (default: 0)
  53071. * @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)
  53072. */
  53073. 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);
  53074. }
  53075. }
  53076. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  53077. /** @hidden */
  53078. export var depthOfFieldMergePixelShader: {
  53079. name: string;
  53080. shader: string;
  53081. };
  53082. }
  53083. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  53084. import { Nullable } from "babylonjs/types";
  53085. import { Camera } from "babylonjs/Cameras/camera";
  53086. import { Effect } from "babylonjs/Materials/effect";
  53087. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53088. import { Engine } from "babylonjs/Engines/engine";
  53089. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  53090. /**
  53091. * Options to be set when merging outputs from the default pipeline.
  53092. */
  53093. export class DepthOfFieldMergePostProcessOptions {
  53094. /**
  53095. * The original image to merge on top of
  53096. */
  53097. originalFromInput: PostProcess;
  53098. /**
  53099. * Parameters to perform the merge of the depth of field effect
  53100. */
  53101. depthOfField?: {
  53102. circleOfConfusion: PostProcess;
  53103. blurSteps: Array<PostProcess>;
  53104. };
  53105. /**
  53106. * Parameters to perform the merge of bloom effect
  53107. */
  53108. bloom?: {
  53109. blurred: PostProcess;
  53110. weight: number;
  53111. };
  53112. }
  53113. /**
  53114. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53115. */
  53116. export class DepthOfFieldMergePostProcess extends PostProcess {
  53117. private blurSteps;
  53118. /**
  53119. * Creates a new instance of DepthOfFieldMergePostProcess
  53120. * @param name The name of the effect.
  53121. * @param originalFromInput Post process which's input will be used for the merge.
  53122. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  53123. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  53124. * @param options The required width/height ratio to downsize to before computing the render pass.
  53125. * @param camera The camera to apply the render pass to.
  53126. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53127. * @param engine The engine which the post process will be applied. (default: current engine)
  53128. * @param reusable If the post process can be reused on the same frame. (default: false)
  53129. * @param textureType Type of textures used when performing the post process. (default: 0)
  53130. * @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)
  53131. */
  53132. 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);
  53133. /**
  53134. * Updates the effect with the current post process compile time values and recompiles the shader.
  53135. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  53136. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  53137. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  53138. * @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
  53139. * @param onCompiled Called when the shader has been compiled.
  53140. * @param onError Called if there is an error when compiling a shader.
  53141. */
  53142. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  53143. }
  53144. }
  53145. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  53146. import { Nullable } from "babylonjs/types";
  53147. import { Camera } from "babylonjs/Cameras/camera";
  53148. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53149. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53150. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53151. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53152. import { Scene } from "babylonjs/scene";
  53153. /**
  53154. * Specifies the level of max blur that should be applied when using the depth of field effect
  53155. */
  53156. export enum DepthOfFieldEffectBlurLevel {
  53157. /**
  53158. * Subtle blur
  53159. */
  53160. Low = 0,
  53161. /**
  53162. * Medium blur
  53163. */
  53164. Medium = 1,
  53165. /**
  53166. * Large blur
  53167. */
  53168. High = 2
  53169. }
  53170. /**
  53171. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  53172. */
  53173. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  53174. private _circleOfConfusion;
  53175. /**
  53176. * @hidden Internal, blurs from high to low
  53177. */
  53178. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  53179. private _depthOfFieldBlurY;
  53180. private _dofMerge;
  53181. /**
  53182. * @hidden Internal post processes in depth of field effect
  53183. */
  53184. _effects: Array<PostProcess>;
  53185. /**
  53186. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  53187. */
  53188. focalLength: number;
  53189. /**
  53190. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53191. */
  53192. fStop: number;
  53193. /**
  53194. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53195. */
  53196. focusDistance: number;
  53197. /**
  53198. * 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.
  53199. */
  53200. lensSize: number;
  53201. /**
  53202. * Creates a new instance DepthOfFieldEffect
  53203. * @param scene The scene the effect belongs to.
  53204. * @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.
  53205. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53206. * @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)
  53207. */
  53208. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  53209. /**
  53210. * 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.
  53211. */
  53212. depthTexture: RenderTargetTexture;
  53213. /**
  53214. * Disposes each of the internal effects for a given camera.
  53215. * @param camera The camera to dispose the effect on.
  53216. */
  53217. disposeEffects(camera: Camera): void;
  53218. /**
  53219. * @hidden Internal
  53220. */
  53221. _updateEffects(): void;
  53222. /**
  53223. * Internal
  53224. * @returns if all the contained post processes are ready.
  53225. * @hidden
  53226. */
  53227. _isReady(): boolean;
  53228. }
  53229. }
  53230. declare module "babylonjs/Shaders/displayPass.fragment" {
  53231. /** @hidden */
  53232. export var displayPassPixelShader: {
  53233. name: string;
  53234. shader: string;
  53235. };
  53236. }
  53237. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  53238. import { Nullable } from "babylonjs/types";
  53239. import { Camera } from "babylonjs/Cameras/camera";
  53240. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53241. import { Engine } from "babylonjs/Engines/engine";
  53242. import "babylonjs/Shaders/displayPass.fragment";
  53243. /**
  53244. * DisplayPassPostProcess which produces an output the same as it's input
  53245. */
  53246. export class DisplayPassPostProcess extends PostProcess {
  53247. /**
  53248. * Creates the DisplayPassPostProcess
  53249. * @param name The name of the effect.
  53250. * @param options The required width/height ratio to downsize to before computing the render pass.
  53251. * @param camera The camera to apply the render pass to.
  53252. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53253. * @param engine The engine which the post process will be applied. (default: current engine)
  53254. * @param reusable If the post process can be reused on the same frame. (default: false)
  53255. */
  53256. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53257. }
  53258. }
  53259. declare module "babylonjs/Shaders/filter.fragment" {
  53260. /** @hidden */
  53261. export var filterPixelShader: {
  53262. name: string;
  53263. shader: string;
  53264. };
  53265. }
  53266. declare module "babylonjs/PostProcesses/filterPostProcess" {
  53267. import { Nullable } from "babylonjs/types";
  53268. import { Matrix } from "babylonjs/Maths/math";
  53269. import { Camera } from "babylonjs/Cameras/camera";
  53270. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53271. import { Engine } from "babylonjs/Engines/engine";
  53272. import "babylonjs/Shaders/filter.fragment";
  53273. /**
  53274. * Applies a kernel filter to the image
  53275. */
  53276. export class FilterPostProcess extends PostProcess {
  53277. /** The matrix to be applied to the image */
  53278. kernelMatrix: Matrix;
  53279. /**
  53280. *
  53281. * @param name The name of the effect.
  53282. * @param kernelMatrix The matrix to be applied to the image
  53283. * @param options The required width/height ratio to downsize to before computing the render pass.
  53284. * @param camera The camera to apply the render pass to.
  53285. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53286. * @param engine The engine which the post process will be applied. (default: current engine)
  53287. * @param reusable If the post process can be reused on the same frame. (default: false)
  53288. */
  53289. constructor(name: string,
  53290. /** The matrix to be applied to the image */
  53291. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53292. }
  53293. }
  53294. declare module "babylonjs/Shaders/fxaa.fragment" {
  53295. /** @hidden */
  53296. export var fxaaPixelShader: {
  53297. name: string;
  53298. shader: string;
  53299. };
  53300. }
  53301. declare module "babylonjs/Shaders/fxaa.vertex" {
  53302. /** @hidden */
  53303. export var fxaaVertexShader: {
  53304. name: string;
  53305. shader: string;
  53306. };
  53307. }
  53308. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  53309. import { Nullable } from "babylonjs/types";
  53310. import { Camera } from "babylonjs/Cameras/camera";
  53311. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53312. import { Engine } from "babylonjs/Engines/engine";
  53313. import "babylonjs/Shaders/fxaa.fragment";
  53314. import "babylonjs/Shaders/fxaa.vertex";
  53315. /**
  53316. * Fxaa post process
  53317. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  53318. */
  53319. export class FxaaPostProcess extends PostProcess {
  53320. /** @hidden */
  53321. texelWidth: number;
  53322. /** @hidden */
  53323. texelHeight: number;
  53324. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53325. private _getDefines;
  53326. }
  53327. }
  53328. declare module "babylonjs/Shaders/grain.fragment" {
  53329. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53330. /** @hidden */
  53331. export var grainPixelShader: {
  53332. name: string;
  53333. shader: string;
  53334. };
  53335. }
  53336. declare module "babylonjs/PostProcesses/grainPostProcess" {
  53337. import { Nullable } from "babylonjs/types";
  53338. import { Camera } from "babylonjs/Cameras/camera";
  53339. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53340. import { Engine } from "babylonjs/Engines/engine";
  53341. import "babylonjs/Shaders/grain.fragment";
  53342. /**
  53343. * The GrainPostProcess adds noise to the image at mid luminance levels
  53344. */
  53345. export class GrainPostProcess extends PostProcess {
  53346. /**
  53347. * The intensity of the grain added (default: 30)
  53348. */
  53349. intensity: number;
  53350. /**
  53351. * If the grain should be randomized on every frame
  53352. */
  53353. animated: boolean;
  53354. /**
  53355. * Creates a new instance of @see GrainPostProcess
  53356. * @param name The name of the effect.
  53357. * @param options The required width/height ratio to downsize to before computing the render pass.
  53358. * @param camera The camera to apply the render pass to.
  53359. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53360. * @param engine The engine which the post process will be applied. (default: current engine)
  53361. * @param reusable If the post process can be reused on the same frame. (default: false)
  53362. * @param textureType Type of textures used when performing the post process. (default: 0)
  53363. * @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)
  53364. */
  53365. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53366. }
  53367. }
  53368. declare module "babylonjs/Shaders/highlights.fragment" {
  53369. /** @hidden */
  53370. export var highlightsPixelShader: {
  53371. name: string;
  53372. shader: string;
  53373. };
  53374. }
  53375. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  53376. import { Nullable } from "babylonjs/types";
  53377. import { Camera } from "babylonjs/Cameras/camera";
  53378. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53379. import { Engine } from "babylonjs/Engines/engine";
  53380. import "babylonjs/Shaders/highlights.fragment";
  53381. /**
  53382. * Extracts highlights from the image
  53383. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53384. */
  53385. export class HighlightsPostProcess extends PostProcess {
  53386. /**
  53387. * Extracts highlights from the image
  53388. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53389. * @param name The name of the effect.
  53390. * @param options The required width/height ratio to downsize to before computing the render pass.
  53391. * @param camera The camera to apply the render pass to.
  53392. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53393. * @param engine The engine which the post process will be applied. (default: current engine)
  53394. * @param reusable If the post process can be reused on the same frame. (default: false)
  53395. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  53396. */
  53397. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53398. }
  53399. }
  53400. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  53401. /** @hidden */
  53402. export var mrtFragmentDeclaration: {
  53403. name: string;
  53404. shader: string;
  53405. };
  53406. }
  53407. declare module "babylonjs/Shaders/geometry.fragment" {
  53408. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  53409. /** @hidden */
  53410. export var geometryPixelShader: {
  53411. name: string;
  53412. shader: string;
  53413. };
  53414. }
  53415. declare module "babylonjs/Shaders/geometry.vertex" {
  53416. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53417. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53418. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53419. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53420. /** @hidden */
  53421. export var geometryVertexShader: {
  53422. name: string;
  53423. shader: string;
  53424. };
  53425. }
  53426. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  53427. import { Matrix } from "babylonjs/Maths/math";
  53428. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53429. import { Mesh } from "babylonjs/Meshes/mesh";
  53430. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  53431. import { Effect } from "babylonjs/Materials/effect";
  53432. import { Scene } from "babylonjs/scene";
  53433. import "babylonjs/Shaders/geometry.fragment";
  53434. import "babylonjs/Shaders/geometry.vertex";
  53435. /**
  53436. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  53437. */
  53438. export class GeometryBufferRenderer {
  53439. /**
  53440. * Constant used to retrieve the position texture index in the G-Buffer textures array
  53441. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  53442. */
  53443. static readonly POSITION_TEXTURE_TYPE: number;
  53444. /**
  53445. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  53446. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  53447. */
  53448. static readonly VELOCITY_TEXTURE_TYPE: number;
  53449. /**
  53450. * Dictionary used to store the previous transformation matrices of each rendered mesh
  53451. * in order to compute objects velocities when enableVelocity is set to "true"
  53452. * @hidden
  53453. */
  53454. _previousTransformationMatrices: {
  53455. [index: number]: Matrix;
  53456. };
  53457. private _scene;
  53458. private _multiRenderTarget;
  53459. private _ratio;
  53460. private _enablePosition;
  53461. private _enableVelocity;
  53462. private _positionIndex;
  53463. private _velocityIndex;
  53464. protected _effect: Effect;
  53465. protected _cachedDefines: string;
  53466. /**
  53467. * Set the render list (meshes to be rendered) used in the G buffer.
  53468. */
  53469. renderList: Mesh[];
  53470. /**
  53471. * Gets wether or not G buffer are supported by the running hardware.
  53472. * This requires draw buffer supports
  53473. */
  53474. readonly isSupported: boolean;
  53475. /**
  53476. * Returns the index of the given texture type in the G-Buffer textures array
  53477. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  53478. * @returns the index of the given texture type in the G-Buffer textures array
  53479. */
  53480. getTextureIndex(textureType: number): number;
  53481. /**
  53482. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  53483. */
  53484. /**
  53485. * Sets whether or not objects positions are enabled for the G buffer.
  53486. */
  53487. enablePosition: boolean;
  53488. /**
  53489. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  53490. */
  53491. /**
  53492. * Sets wether or not objects velocities are enabled for the G buffer.
  53493. */
  53494. enableVelocity: boolean;
  53495. /**
  53496. * Gets the scene associated with the buffer.
  53497. */
  53498. readonly scene: Scene;
  53499. /**
  53500. * Gets the ratio used by the buffer during its creation.
  53501. * How big is the buffer related to the main canvas.
  53502. */
  53503. readonly ratio: number;
  53504. /** @hidden */
  53505. static _SceneComponentInitialization: (scene: Scene) => void;
  53506. /**
  53507. * Creates a new G Buffer for the scene
  53508. * @param scene The scene the buffer belongs to
  53509. * @param ratio How big is the buffer related to the main canvas.
  53510. */
  53511. constructor(scene: Scene, ratio?: number);
  53512. /**
  53513. * Checks wether everything is ready to render a submesh to the G buffer.
  53514. * @param subMesh the submesh to check readiness for
  53515. * @param useInstances is the mesh drawn using instance or not
  53516. * @returns true if ready otherwise false
  53517. */
  53518. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53519. /**
  53520. * Gets the current underlying G Buffer.
  53521. * @returns the buffer
  53522. */
  53523. getGBuffer(): MultiRenderTarget;
  53524. /**
  53525. * Gets the number of samples used to render the buffer (anti aliasing).
  53526. */
  53527. /**
  53528. * Sets the number of samples used to render the buffer (anti aliasing).
  53529. */
  53530. samples: number;
  53531. /**
  53532. * Disposes the renderer and frees up associated resources.
  53533. */
  53534. dispose(): void;
  53535. protected _createRenderTargets(): void;
  53536. }
  53537. }
  53538. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  53539. import { Nullable } from "babylonjs/types";
  53540. import { Scene } from "babylonjs/scene";
  53541. import { ISceneComponent } from "babylonjs/sceneComponent";
  53542. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  53543. module "babylonjs/scene" {
  53544. interface Scene {
  53545. /** @hidden (Backing field) */
  53546. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53547. /**
  53548. * Gets or Sets the current geometry buffer associated to the scene.
  53549. */
  53550. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53551. /**
  53552. * Enables a GeometryBufferRender and associates it with the scene
  53553. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  53554. * @returns the GeometryBufferRenderer
  53555. */
  53556. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  53557. /**
  53558. * Disables the GeometryBufferRender associated with the scene
  53559. */
  53560. disableGeometryBufferRenderer(): void;
  53561. }
  53562. }
  53563. /**
  53564. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  53565. * in several rendering techniques.
  53566. */
  53567. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  53568. /**
  53569. * The component name helpful to identify the component in the list of scene components.
  53570. */
  53571. readonly name: string;
  53572. /**
  53573. * The scene the component belongs to.
  53574. */
  53575. scene: Scene;
  53576. /**
  53577. * Creates a new instance of the component for the given scene
  53578. * @param scene Defines the scene to register the component in
  53579. */
  53580. constructor(scene: Scene);
  53581. /**
  53582. * Registers the component in a given scene
  53583. */
  53584. register(): void;
  53585. /**
  53586. * Rebuilds the elements related to this component in case of
  53587. * context lost for instance.
  53588. */
  53589. rebuild(): void;
  53590. /**
  53591. * Disposes the component and the associated ressources
  53592. */
  53593. dispose(): void;
  53594. private _gatherRenderTargets;
  53595. }
  53596. }
  53597. declare module "babylonjs/Shaders/motionBlur.fragment" {
  53598. /** @hidden */
  53599. export var motionBlurPixelShader: {
  53600. name: string;
  53601. shader: string;
  53602. };
  53603. }
  53604. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  53605. import { Nullable } from "babylonjs/types";
  53606. import { Camera } from "babylonjs/Cameras/camera";
  53607. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53608. import { Scene } from "babylonjs/scene";
  53609. import "babylonjs/Animations/animatable";
  53610. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  53611. import "babylonjs/Shaders/motionBlur.fragment";
  53612. import { Engine } from "babylonjs/Engines/engine";
  53613. /**
  53614. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  53615. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  53616. * As an example, all you have to do is to create the post-process:
  53617. * var mb = new BABYLON.MotionBlurPostProcess(
  53618. * 'mb', // The name of the effect.
  53619. * scene, // The scene containing the objects to blur according to their velocity.
  53620. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  53621. * camera // The camera to apply the render pass to.
  53622. * );
  53623. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  53624. */
  53625. export class MotionBlurPostProcess extends PostProcess {
  53626. /**
  53627. * Defines how much the image is blurred by the movement. Default value is equal to 1
  53628. */
  53629. motionStrength: number;
  53630. /**
  53631. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  53632. */
  53633. /**
  53634. * Sets the number of iterations to be used for motion blur quality
  53635. */
  53636. motionBlurSamples: number;
  53637. private _motionBlurSamples;
  53638. private _geometryBufferRenderer;
  53639. /**
  53640. * Creates a new instance MotionBlurPostProcess
  53641. * @param name The name of the effect.
  53642. * @param scene The scene containing the objects to blur according to their velocity.
  53643. * @param options The required width/height ratio to downsize to before computing the render pass.
  53644. * @param camera The camera to apply the render pass to.
  53645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53646. * @param engine The engine which the post process will be applied. (default: current engine)
  53647. * @param reusable If the post process can be reused on the same frame. (default: false)
  53648. * @param textureType Type of textures used when performing the post process. (default: 0)
  53649. * @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)
  53650. */
  53651. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53652. /**
  53653. * Disposes the post process.
  53654. * @param camera The camera to dispose the post process on.
  53655. */
  53656. dispose(camera?: Camera): void;
  53657. }
  53658. }
  53659. declare module "babylonjs/Shaders/refraction.fragment" {
  53660. /** @hidden */
  53661. export var refractionPixelShader: {
  53662. name: string;
  53663. shader: string;
  53664. };
  53665. }
  53666. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  53667. import { Color3 } from "babylonjs/Maths/math";
  53668. import { Camera } from "babylonjs/Cameras/camera";
  53669. import { Texture } from "babylonjs/Materials/Textures/texture";
  53670. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53671. import { Engine } from "babylonjs/Engines/engine";
  53672. import "babylonjs/Shaders/refraction.fragment";
  53673. /**
  53674. * Post process which applies a refractin texture
  53675. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53676. */
  53677. export class RefractionPostProcess extends PostProcess {
  53678. /** the base color of the refraction (used to taint the rendering) */
  53679. color: Color3;
  53680. /** simulated refraction depth */
  53681. depth: number;
  53682. /** the coefficient of the base color (0 to remove base color tainting) */
  53683. colorLevel: number;
  53684. private _refTexture;
  53685. private _ownRefractionTexture;
  53686. /**
  53687. * Gets or sets the refraction texture
  53688. * Please note that you are responsible for disposing the texture if you set it manually
  53689. */
  53690. refractionTexture: Texture;
  53691. /**
  53692. * Initializes the RefractionPostProcess
  53693. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53694. * @param name The name of the effect.
  53695. * @param refractionTextureUrl Url of the refraction texture to use
  53696. * @param color the base color of the refraction (used to taint the rendering)
  53697. * @param depth simulated refraction depth
  53698. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  53699. * @param camera The camera to apply the render pass to.
  53700. * @param options The required width/height ratio to downsize to before computing the render pass.
  53701. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53702. * @param engine The engine which the post process will be applied. (default: current engine)
  53703. * @param reusable If the post process can be reused on the same frame. (default: false)
  53704. */
  53705. constructor(name: string, refractionTextureUrl: string,
  53706. /** the base color of the refraction (used to taint the rendering) */
  53707. color: Color3,
  53708. /** simulated refraction depth */
  53709. depth: number,
  53710. /** the coefficient of the base color (0 to remove base color tainting) */
  53711. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53712. /**
  53713. * Disposes of the post process
  53714. * @param camera Camera to dispose post process on
  53715. */
  53716. dispose(camera: Camera): void;
  53717. }
  53718. }
  53719. declare module "babylonjs/Shaders/sharpen.fragment" {
  53720. /** @hidden */
  53721. export var sharpenPixelShader: {
  53722. name: string;
  53723. shader: string;
  53724. };
  53725. }
  53726. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  53727. import { Nullable } from "babylonjs/types";
  53728. import { Camera } from "babylonjs/Cameras/camera";
  53729. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53730. import "babylonjs/Shaders/sharpen.fragment";
  53731. import { Engine } from "babylonjs/Engines/engine";
  53732. /**
  53733. * The SharpenPostProcess applies a sharpen kernel to every pixel
  53734. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53735. */
  53736. export class SharpenPostProcess extends PostProcess {
  53737. /**
  53738. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  53739. */
  53740. colorAmount: number;
  53741. /**
  53742. * How much sharpness should be applied (default: 0.3)
  53743. */
  53744. edgeAmount: number;
  53745. /**
  53746. * Creates a new instance ConvolutionPostProcess
  53747. * @param name The name of the effect.
  53748. * @param options The required width/height ratio to downsize to before computing the render pass.
  53749. * @param camera The camera to apply the render pass to.
  53750. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53751. * @param engine The engine which the post process will be applied. (default: current engine)
  53752. * @param reusable If the post process can be reused on the same frame. (default: false)
  53753. * @param textureType Type of textures used when performing the post process. (default: 0)
  53754. * @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)
  53755. */
  53756. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53757. }
  53758. }
  53759. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  53760. import { Nullable } from "babylonjs/types";
  53761. import { Camera } from "babylonjs/Cameras/camera";
  53762. import { Engine } from "babylonjs/Engines/engine";
  53763. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53764. /**
  53765. * PostProcessRenderPipeline
  53766. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53767. */
  53768. export class PostProcessRenderPipeline {
  53769. private engine;
  53770. private _renderEffects;
  53771. private _renderEffectsForIsolatedPass;
  53772. /**
  53773. * @hidden
  53774. */
  53775. protected _cameras: Camera[];
  53776. /** @hidden */
  53777. _name: string;
  53778. /**
  53779. * Gets pipeline name
  53780. */
  53781. readonly name: string;
  53782. /**
  53783. * Initializes a PostProcessRenderPipeline
  53784. * @param engine engine to add the pipeline to
  53785. * @param name name of the pipeline
  53786. */
  53787. constructor(engine: Engine, name: string);
  53788. /**
  53789. * Gets the class name
  53790. * @returns "PostProcessRenderPipeline"
  53791. */
  53792. getClassName(): string;
  53793. /**
  53794. * If all the render effects in the pipeline are supported
  53795. */
  53796. readonly isSupported: boolean;
  53797. /**
  53798. * Adds an effect to the pipeline
  53799. * @param renderEffect the effect to add
  53800. */
  53801. addEffect(renderEffect: PostProcessRenderEffect): void;
  53802. /** @hidden */
  53803. _rebuild(): void;
  53804. /** @hidden */
  53805. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53806. /** @hidden */
  53807. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53808. /** @hidden */
  53809. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53810. /** @hidden */
  53811. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53812. /** @hidden */
  53813. _attachCameras(cameras: Camera, unique: boolean): void;
  53814. /** @hidden */
  53815. _attachCameras(cameras: Camera[], unique: boolean): void;
  53816. /** @hidden */
  53817. _detachCameras(cameras: Camera): void;
  53818. /** @hidden */
  53819. _detachCameras(cameras: Nullable<Camera[]>): void;
  53820. /** @hidden */
  53821. _update(): void;
  53822. /** @hidden */
  53823. _reset(): void;
  53824. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53825. /**
  53826. * Disposes of the pipeline
  53827. */
  53828. dispose(): void;
  53829. }
  53830. }
  53831. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  53832. import { Camera } from "babylonjs/Cameras/camera";
  53833. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53834. /**
  53835. * PostProcessRenderPipelineManager class
  53836. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53837. */
  53838. export class PostProcessRenderPipelineManager {
  53839. private _renderPipelines;
  53840. /**
  53841. * Initializes a PostProcessRenderPipelineManager
  53842. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53843. */
  53844. constructor();
  53845. /**
  53846. * Gets the list of supported render pipelines
  53847. */
  53848. readonly supportedPipelines: PostProcessRenderPipeline[];
  53849. /**
  53850. * Adds a pipeline to the manager
  53851. * @param renderPipeline The pipeline to add
  53852. */
  53853. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53854. /**
  53855. * Attaches a camera to the pipeline
  53856. * @param renderPipelineName The name of the pipeline to attach to
  53857. * @param cameras the camera to attach
  53858. * @param unique if the camera can be attached multiple times to the pipeline
  53859. */
  53860. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53861. /**
  53862. * Detaches a camera from the pipeline
  53863. * @param renderPipelineName The name of the pipeline to detach from
  53864. * @param cameras the camera to detach
  53865. */
  53866. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53867. /**
  53868. * Enables an effect by name on a pipeline
  53869. * @param renderPipelineName the name of the pipeline to enable the effect in
  53870. * @param renderEffectName the name of the effect to enable
  53871. * @param cameras the cameras that the effect should be enabled on
  53872. */
  53873. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53874. /**
  53875. * Disables an effect by name on a pipeline
  53876. * @param renderPipelineName the name of the pipeline to disable the effect in
  53877. * @param renderEffectName the name of the effect to disable
  53878. * @param cameras the cameras that the effect should be disabled on
  53879. */
  53880. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53881. /**
  53882. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53883. */
  53884. update(): void;
  53885. /** @hidden */
  53886. _rebuild(): void;
  53887. /**
  53888. * Disposes of the manager and pipelines
  53889. */
  53890. dispose(): void;
  53891. }
  53892. }
  53893. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  53894. import { ISceneComponent } from "babylonjs/sceneComponent";
  53895. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53896. import { Scene } from "babylonjs/scene";
  53897. module "babylonjs/scene" {
  53898. interface Scene {
  53899. /** @hidden (Backing field) */
  53900. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53901. /**
  53902. * Gets the postprocess render pipeline manager
  53903. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53904. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53905. */
  53906. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53907. }
  53908. }
  53909. /**
  53910. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53911. */
  53912. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53913. /**
  53914. * The component name helpfull to identify the component in the list of scene components.
  53915. */
  53916. readonly name: string;
  53917. /**
  53918. * The scene the component belongs to.
  53919. */
  53920. scene: Scene;
  53921. /**
  53922. * Creates a new instance of the component for the given scene
  53923. * @param scene Defines the scene to register the component in
  53924. */
  53925. constructor(scene: Scene);
  53926. /**
  53927. * Registers the component in a given scene
  53928. */
  53929. register(): void;
  53930. /**
  53931. * Rebuilds the elements related to this component in case of
  53932. * context lost for instance.
  53933. */
  53934. rebuild(): void;
  53935. /**
  53936. * Disposes the component and the associated ressources
  53937. */
  53938. dispose(): void;
  53939. private _gatherRenderTargets;
  53940. }
  53941. }
  53942. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  53943. import { IAnimatable } from "babylonjs/Misc/tools";
  53944. import { Camera } from "babylonjs/Cameras/camera";
  53945. import { IDisposable } from "babylonjs/scene";
  53946. import { Scene } from "babylonjs/scene";
  53947. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  53948. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  53949. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  53950. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  53951. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  53952. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53953. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  53954. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  53955. import { Animation } from "babylonjs/Animations/animation";
  53956. /**
  53957. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  53958. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53959. */
  53960. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53961. private _scene;
  53962. private _camerasToBeAttached;
  53963. /**
  53964. * ID of the sharpen post process,
  53965. */
  53966. private readonly SharpenPostProcessId;
  53967. /**
  53968. * @ignore
  53969. * ID of the image processing post process;
  53970. */
  53971. readonly ImageProcessingPostProcessId: string;
  53972. /**
  53973. * @ignore
  53974. * ID of the Fast Approximate Anti-Aliasing post process;
  53975. */
  53976. readonly FxaaPostProcessId: string;
  53977. /**
  53978. * ID of the chromatic aberration post process,
  53979. */
  53980. private readonly ChromaticAberrationPostProcessId;
  53981. /**
  53982. * ID of the grain post process
  53983. */
  53984. private readonly GrainPostProcessId;
  53985. /**
  53986. * Sharpen post process which will apply a sharpen convolution to enhance edges
  53987. */
  53988. sharpen: SharpenPostProcess;
  53989. private _sharpenEffect;
  53990. private bloom;
  53991. /**
  53992. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  53993. */
  53994. depthOfField: DepthOfFieldEffect;
  53995. /**
  53996. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53997. */
  53998. fxaa: FxaaPostProcess;
  53999. /**
  54000. * Image post processing pass used to perform operations such as tone mapping or color grading.
  54001. */
  54002. imageProcessing: ImageProcessingPostProcess;
  54003. /**
  54004. * Chromatic aberration post process which will shift rgb colors in the image
  54005. */
  54006. chromaticAberration: ChromaticAberrationPostProcess;
  54007. private _chromaticAberrationEffect;
  54008. /**
  54009. * Grain post process which add noise to the image
  54010. */
  54011. grain: GrainPostProcess;
  54012. private _grainEffect;
  54013. /**
  54014. * Glow post process which adds a glow to emissive areas of the image
  54015. */
  54016. private _glowLayer;
  54017. /**
  54018. * Animations which can be used to tweak settings over a period of time
  54019. */
  54020. animations: Animation[];
  54021. private _imageProcessingConfigurationObserver;
  54022. private _sharpenEnabled;
  54023. private _bloomEnabled;
  54024. private _depthOfFieldEnabled;
  54025. private _depthOfFieldBlurLevel;
  54026. private _fxaaEnabled;
  54027. private _imageProcessingEnabled;
  54028. private _defaultPipelineTextureType;
  54029. private _bloomScale;
  54030. private _chromaticAberrationEnabled;
  54031. private _grainEnabled;
  54032. private _buildAllowed;
  54033. /**
  54034. * Gets active scene
  54035. */
  54036. readonly scene: Scene;
  54037. /**
  54038. * Enable or disable the sharpen process from the pipeline
  54039. */
  54040. sharpenEnabled: boolean;
  54041. private _resizeObserver;
  54042. private _hardwareScaleLevel;
  54043. private _bloomKernel;
  54044. /**
  54045. * Specifies the size of the bloom blur kernel, relative to the final output size
  54046. */
  54047. bloomKernel: number;
  54048. /**
  54049. * Specifies the weight of the bloom in the final rendering
  54050. */
  54051. private _bloomWeight;
  54052. /**
  54053. * Specifies the luma threshold for the area that will be blurred by the bloom
  54054. */
  54055. private _bloomThreshold;
  54056. private _hdr;
  54057. /**
  54058. * The strength of the bloom.
  54059. */
  54060. bloomWeight: number;
  54061. /**
  54062. * The strength of the bloom.
  54063. */
  54064. bloomThreshold: number;
  54065. /**
  54066. * The scale of the bloom, lower value will provide better performance.
  54067. */
  54068. bloomScale: number;
  54069. /**
  54070. * Enable or disable the bloom from the pipeline
  54071. */
  54072. bloomEnabled: boolean;
  54073. private _rebuildBloom;
  54074. /**
  54075. * If the depth of field is enabled.
  54076. */
  54077. depthOfFieldEnabled: boolean;
  54078. /**
  54079. * Blur level of the depth of field effect. (Higher blur will effect performance)
  54080. */
  54081. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  54082. /**
  54083. * If the anti aliasing is enabled.
  54084. */
  54085. fxaaEnabled: boolean;
  54086. private _samples;
  54087. /**
  54088. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54089. */
  54090. samples: number;
  54091. /**
  54092. * If image processing is enabled.
  54093. */
  54094. imageProcessingEnabled: boolean;
  54095. /**
  54096. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  54097. */
  54098. glowLayerEnabled: boolean;
  54099. /**
  54100. * Enable or disable the chromaticAberration process from the pipeline
  54101. */
  54102. chromaticAberrationEnabled: boolean;
  54103. /**
  54104. * Enable or disable the grain process from the pipeline
  54105. */
  54106. grainEnabled: boolean;
  54107. /**
  54108. * @constructor
  54109. * @param name - The rendering pipeline name (default: "")
  54110. * @param hdr - If high dynamic range textures should be used (default: true)
  54111. * @param scene - The scene linked to this pipeline (default: the last created scene)
  54112. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  54113. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  54114. */
  54115. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  54116. /**
  54117. * Get the class name
  54118. * @returns "DefaultRenderingPipeline"
  54119. */
  54120. getClassName(): string;
  54121. /**
  54122. * Force the compilation of the entire pipeline.
  54123. */
  54124. prepare(): void;
  54125. private _hasCleared;
  54126. private _prevPostProcess;
  54127. private _prevPrevPostProcess;
  54128. private _setAutoClearAndTextureSharing;
  54129. private _depthOfFieldSceneObserver;
  54130. private _buildPipeline;
  54131. private _disposePostProcesses;
  54132. /**
  54133. * Adds a camera to the pipeline
  54134. * @param camera the camera to be added
  54135. */
  54136. addCamera(camera: Camera): void;
  54137. /**
  54138. * Removes a camera from the pipeline
  54139. * @param camera the camera to remove
  54140. */
  54141. removeCamera(camera: Camera): void;
  54142. /**
  54143. * Dispose of the pipeline and stop all post processes
  54144. */
  54145. dispose(): void;
  54146. /**
  54147. * Serialize the rendering pipeline (Used when exporting)
  54148. * @returns the serialized object
  54149. */
  54150. serialize(): any;
  54151. /**
  54152. * Parse the serialized pipeline
  54153. * @param source Source pipeline.
  54154. * @param scene The scene to load the pipeline to.
  54155. * @param rootUrl The URL of the serialized pipeline.
  54156. * @returns An instantiated pipeline from the serialized object.
  54157. */
  54158. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  54159. }
  54160. }
  54161. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  54162. /** @hidden */
  54163. export var lensHighlightsPixelShader: {
  54164. name: string;
  54165. shader: string;
  54166. };
  54167. }
  54168. declare module "babylonjs/Shaders/depthOfField.fragment" {
  54169. /** @hidden */
  54170. export var depthOfFieldPixelShader: {
  54171. name: string;
  54172. shader: string;
  54173. };
  54174. }
  54175. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  54176. import { Camera } from "babylonjs/Cameras/camera";
  54177. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54178. import { Scene } from "babylonjs/scene";
  54179. import "babylonjs/Shaders/chromaticAberration.fragment";
  54180. import "babylonjs/Shaders/lensHighlights.fragment";
  54181. import "babylonjs/Shaders/depthOfField.fragment";
  54182. /**
  54183. * BABYLON.JS Chromatic Aberration GLSL Shader
  54184. * Author: Olivier Guyot
  54185. * Separates very slightly R, G and B colors on the edges of the screen
  54186. * Inspired by Francois Tarlier & Martins Upitis
  54187. */
  54188. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  54189. /**
  54190. * @ignore
  54191. * The chromatic aberration PostProcess id in the pipeline
  54192. */
  54193. LensChromaticAberrationEffect: string;
  54194. /**
  54195. * @ignore
  54196. * The highlights enhancing PostProcess id in the pipeline
  54197. */
  54198. HighlightsEnhancingEffect: string;
  54199. /**
  54200. * @ignore
  54201. * The depth-of-field PostProcess id in the pipeline
  54202. */
  54203. LensDepthOfFieldEffect: string;
  54204. private _scene;
  54205. private _depthTexture;
  54206. private _grainTexture;
  54207. private _chromaticAberrationPostProcess;
  54208. private _highlightsPostProcess;
  54209. private _depthOfFieldPostProcess;
  54210. private _edgeBlur;
  54211. private _grainAmount;
  54212. private _chromaticAberration;
  54213. private _distortion;
  54214. private _highlightsGain;
  54215. private _highlightsThreshold;
  54216. private _dofDistance;
  54217. private _dofAperture;
  54218. private _dofDarken;
  54219. private _dofPentagon;
  54220. private _blurNoise;
  54221. /**
  54222. * @constructor
  54223. *
  54224. * Effect parameters are as follow:
  54225. * {
  54226. * chromatic_aberration: number; // from 0 to x (1 for realism)
  54227. * edge_blur: number; // from 0 to x (1 for realism)
  54228. * distortion: number; // from 0 to x (1 for realism)
  54229. * grain_amount: number; // from 0 to 1
  54230. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  54231. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  54232. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  54233. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  54234. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  54235. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  54236. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  54237. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  54238. * }
  54239. * Note: if an effect parameter is unset, effect is disabled
  54240. *
  54241. * @param name The rendering pipeline name
  54242. * @param parameters - An object containing all parameters (see above)
  54243. * @param scene The scene linked to this pipeline
  54244. * @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)
  54245. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54246. */
  54247. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  54248. /**
  54249. * Sets the amount of blur at the edges
  54250. * @param amount blur amount
  54251. */
  54252. setEdgeBlur(amount: number): void;
  54253. /**
  54254. * Sets edge blur to 0
  54255. */
  54256. disableEdgeBlur(): void;
  54257. /**
  54258. * Sets the amout of grain
  54259. * @param amount Amount of grain
  54260. */
  54261. setGrainAmount(amount: number): void;
  54262. /**
  54263. * Set grain amount to 0
  54264. */
  54265. disableGrain(): void;
  54266. /**
  54267. * Sets the chromatic aberration amount
  54268. * @param amount amount of chromatic aberration
  54269. */
  54270. setChromaticAberration(amount: number): void;
  54271. /**
  54272. * Sets chromatic aberration amount to 0
  54273. */
  54274. disableChromaticAberration(): void;
  54275. /**
  54276. * Sets the EdgeDistortion amount
  54277. * @param amount amount of EdgeDistortion
  54278. */
  54279. setEdgeDistortion(amount: number): void;
  54280. /**
  54281. * Sets edge distortion to 0
  54282. */
  54283. disableEdgeDistortion(): void;
  54284. /**
  54285. * Sets the FocusDistance amount
  54286. * @param amount amount of FocusDistance
  54287. */
  54288. setFocusDistance(amount: number): void;
  54289. /**
  54290. * Disables depth of field
  54291. */
  54292. disableDepthOfField(): void;
  54293. /**
  54294. * Sets the Aperture amount
  54295. * @param amount amount of Aperture
  54296. */
  54297. setAperture(amount: number): void;
  54298. /**
  54299. * Sets the DarkenOutOfFocus amount
  54300. * @param amount amount of DarkenOutOfFocus
  54301. */
  54302. setDarkenOutOfFocus(amount: number): void;
  54303. /**
  54304. * Creates a pentagon bokeh effect
  54305. */
  54306. enablePentagonBokeh(): void;
  54307. /**
  54308. * Disables the pentagon bokeh effect
  54309. */
  54310. disablePentagonBokeh(): void;
  54311. /**
  54312. * Enables noise blur
  54313. */
  54314. enableNoiseBlur(): void;
  54315. /**
  54316. * Disables noise blur
  54317. */
  54318. disableNoiseBlur(): void;
  54319. /**
  54320. * Sets the HighlightsGain amount
  54321. * @param amount amount of HighlightsGain
  54322. */
  54323. setHighlightsGain(amount: number): void;
  54324. /**
  54325. * Sets the HighlightsThreshold amount
  54326. * @param amount amount of HighlightsThreshold
  54327. */
  54328. setHighlightsThreshold(amount: number): void;
  54329. /**
  54330. * Disables highlights
  54331. */
  54332. disableHighlights(): void;
  54333. /**
  54334. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  54335. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  54336. */
  54337. dispose(disableDepthRender?: boolean): void;
  54338. private _createChromaticAberrationPostProcess;
  54339. private _createHighlightsPostProcess;
  54340. private _createDepthOfFieldPostProcess;
  54341. private _createGrainTexture;
  54342. }
  54343. }
  54344. declare module "babylonjs/Shaders/ssao2.fragment" {
  54345. /** @hidden */
  54346. export var ssao2PixelShader: {
  54347. name: string;
  54348. shader: string;
  54349. };
  54350. }
  54351. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  54352. /** @hidden */
  54353. export var ssaoCombinePixelShader: {
  54354. name: string;
  54355. shader: string;
  54356. };
  54357. }
  54358. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  54359. import { Camera } from "babylonjs/Cameras/camera";
  54360. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54361. import { Scene } from "babylonjs/scene";
  54362. import "babylonjs/Shaders/ssao2.fragment";
  54363. import "babylonjs/Shaders/ssaoCombine.fragment";
  54364. /**
  54365. * Render pipeline to produce ssao effect
  54366. */
  54367. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  54368. /**
  54369. * @ignore
  54370. * The PassPostProcess id in the pipeline that contains the original scene color
  54371. */
  54372. SSAOOriginalSceneColorEffect: string;
  54373. /**
  54374. * @ignore
  54375. * The SSAO PostProcess id in the pipeline
  54376. */
  54377. SSAORenderEffect: string;
  54378. /**
  54379. * @ignore
  54380. * The horizontal blur PostProcess id in the pipeline
  54381. */
  54382. SSAOBlurHRenderEffect: string;
  54383. /**
  54384. * @ignore
  54385. * The vertical blur PostProcess id in the pipeline
  54386. */
  54387. SSAOBlurVRenderEffect: string;
  54388. /**
  54389. * @ignore
  54390. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54391. */
  54392. SSAOCombineRenderEffect: string;
  54393. /**
  54394. * The output strength of the SSAO post-process. Default value is 1.0.
  54395. */
  54396. totalStrength: number;
  54397. /**
  54398. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  54399. */
  54400. maxZ: number;
  54401. /**
  54402. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  54403. */
  54404. minZAspect: number;
  54405. private _samples;
  54406. /**
  54407. * Number of samples used for the SSAO calculations. Default value is 8
  54408. */
  54409. samples: number;
  54410. private _textureSamples;
  54411. /**
  54412. * Number of samples to use for antialiasing
  54413. */
  54414. textureSamples: number;
  54415. /**
  54416. * Ratio object used for SSAO ratio and blur ratio
  54417. */
  54418. private _ratio;
  54419. /**
  54420. * Dynamically generated sphere sampler.
  54421. */
  54422. private _sampleSphere;
  54423. /**
  54424. * Blur filter offsets
  54425. */
  54426. private _samplerOffsets;
  54427. private _expensiveBlur;
  54428. /**
  54429. * If bilateral blur should be used
  54430. */
  54431. expensiveBlur: boolean;
  54432. /**
  54433. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  54434. */
  54435. radius: number;
  54436. /**
  54437. * The base color of the SSAO post-process
  54438. * The final result is "base + ssao" between [0, 1]
  54439. */
  54440. base: number;
  54441. /**
  54442. * Support test.
  54443. */
  54444. static readonly IsSupported: boolean;
  54445. private _scene;
  54446. private _depthTexture;
  54447. private _normalTexture;
  54448. private _randomTexture;
  54449. private _originalColorPostProcess;
  54450. private _ssaoPostProcess;
  54451. private _blurHPostProcess;
  54452. private _blurVPostProcess;
  54453. private _ssaoCombinePostProcess;
  54454. private _firstUpdate;
  54455. /**
  54456. * Gets active scene
  54457. */
  54458. readonly scene: Scene;
  54459. /**
  54460. * @constructor
  54461. * @param name The rendering pipeline name
  54462. * @param scene The scene linked to this pipeline
  54463. * @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 }
  54464. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54465. */
  54466. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54467. /**
  54468. * Get the class name
  54469. * @returns "SSAO2RenderingPipeline"
  54470. */
  54471. getClassName(): string;
  54472. /**
  54473. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54474. */
  54475. dispose(disableGeometryBufferRenderer?: boolean): void;
  54476. private _createBlurPostProcess;
  54477. /** @hidden */
  54478. _rebuild(): void;
  54479. private _bits;
  54480. private _radicalInverse_VdC;
  54481. private _hammersley;
  54482. private _hemisphereSample_uniform;
  54483. private _generateHemisphere;
  54484. private _createSSAOPostProcess;
  54485. private _createSSAOCombinePostProcess;
  54486. private _createRandomTexture;
  54487. /**
  54488. * Serialize the rendering pipeline (Used when exporting)
  54489. * @returns the serialized object
  54490. */
  54491. serialize(): any;
  54492. /**
  54493. * Parse the serialized pipeline
  54494. * @param source Source pipeline.
  54495. * @param scene The scene to load the pipeline to.
  54496. * @param rootUrl The URL of the serialized pipeline.
  54497. * @returns An instantiated pipeline from the serialized object.
  54498. */
  54499. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  54500. }
  54501. }
  54502. declare module "babylonjs/Shaders/ssao.fragment" {
  54503. /** @hidden */
  54504. export var ssaoPixelShader: {
  54505. name: string;
  54506. shader: string;
  54507. };
  54508. }
  54509. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  54510. import { Camera } from "babylonjs/Cameras/camera";
  54511. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54512. import { Scene } from "babylonjs/scene";
  54513. import "babylonjs/Shaders/ssao.fragment";
  54514. import "babylonjs/Shaders/ssaoCombine.fragment";
  54515. /**
  54516. * Render pipeline to produce ssao effect
  54517. */
  54518. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  54519. /**
  54520. * @ignore
  54521. * The PassPostProcess id in the pipeline that contains the original scene color
  54522. */
  54523. SSAOOriginalSceneColorEffect: string;
  54524. /**
  54525. * @ignore
  54526. * The SSAO PostProcess id in the pipeline
  54527. */
  54528. SSAORenderEffect: string;
  54529. /**
  54530. * @ignore
  54531. * The horizontal blur PostProcess id in the pipeline
  54532. */
  54533. SSAOBlurHRenderEffect: string;
  54534. /**
  54535. * @ignore
  54536. * The vertical blur PostProcess id in the pipeline
  54537. */
  54538. SSAOBlurVRenderEffect: string;
  54539. /**
  54540. * @ignore
  54541. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54542. */
  54543. SSAOCombineRenderEffect: string;
  54544. /**
  54545. * The output strength of the SSAO post-process. Default value is 1.0.
  54546. */
  54547. totalStrength: number;
  54548. /**
  54549. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  54550. */
  54551. radius: number;
  54552. /**
  54553. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  54554. * Must not be equal to fallOff and superior to fallOff.
  54555. * Default value is 0.0075
  54556. */
  54557. area: number;
  54558. /**
  54559. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  54560. * Must not be equal to area and inferior to area.
  54561. * Default value is 0.000001
  54562. */
  54563. fallOff: number;
  54564. /**
  54565. * The base color of the SSAO post-process
  54566. * The final result is "base + ssao" between [0, 1]
  54567. */
  54568. base: number;
  54569. private _scene;
  54570. private _depthTexture;
  54571. private _randomTexture;
  54572. private _originalColorPostProcess;
  54573. private _ssaoPostProcess;
  54574. private _blurHPostProcess;
  54575. private _blurVPostProcess;
  54576. private _ssaoCombinePostProcess;
  54577. private _firstUpdate;
  54578. /**
  54579. * Gets active scene
  54580. */
  54581. readonly scene: Scene;
  54582. /**
  54583. * @constructor
  54584. * @param name - The rendering pipeline name
  54585. * @param scene - The scene linked to this pipeline
  54586. * @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 }
  54587. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  54588. */
  54589. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54590. /**
  54591. * Get the class name
  54592. * @returns "SSAORenderingPipeline"
  54593. */
  54594. getClassName(): string;
  54595. /**
  54596. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54597. */
  54598. dispose(disableDepthRender?: boolean): void;
  54599. private _createBlurPostProcess;
  54600. /** @hidden */
  54601. _rebuild(): void;
  54602. private _createSSAOPostProcess;
  54603. private _createSSAOCombinePostProcess;
  54604. private _createRandomTexture;
  54605. }
  54606. }
  54607. declare module "babylonjs/Shaders/standard.fragment" {
  54608. /** @hidden */
  54609. export var standardPixelShader: {
  54610. name: string;
  54611. shader: string;
  54612. };
  54613. }
  54614. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  54615. import { Nullable } from "babylonjs/types";
  54616. import { IAnimatable } from "babylonjs/Misc/tools";
  54617. import { Camera } from "babylonjs/Cameras/camera";
  54618. import { Texture } from "babylonjs/Materials/Textures/texture";
  54619. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54620. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54621. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54622. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54623. import { IDisposable } from "babylonjs/scene";
  54624. import { SpotLight } from "babylonjs/Lights/spotLight";
  54625. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  54626. import { Scene } from "babylonjs/scene";
  54627. import { Animation } from "babylonjs/Animations/animation";
  54628. import "babylonjs/Shaders/standard.fragment";
  54629. /**
  54630. * Standard rendering pipeline
  54631. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54632. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  54633. */
  54634. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54635. /**
  54636. * Public members
  54637. */
  54638. /**
  54639. * Post-process which contains the original scene color before the pipeline applies all the effects
  54640. */
  54641. originalPostProcess: Nullable<PostProcess>;
  54642. /**
  54643. * Post-process used to down scale an image x4
  54644. */
  54645. downSampleX4PostProcess: Nullable<PostProcess>;
  54646. /**
  54647. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  54648. */
  54649. brightPassPostProcess: Nullable<PostProcess>;
  54650. /**
  54651. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  54652. */
  54653. blurHPostProcesses: PostProcess[];
  54654. /**
  54655. * Post-process array storing all the vertical blur post-processes used by the pipeline
  54656. */
  54657. blurVPostProcesses: PostProcess[];
  54658. /**
  54659. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  54660. */
  54661. textureAdderPostProcess: Nullable<PostProcess>;
  54662. /**
  54663. * Post-process used to create volumetric lighting effect
  54664. */
  54665. volumetricLightPostProcess: Nullable<PostProcess>;
  54666. /**
  54667. * Post-process used to smooth the previous volumetric light post-process on the X axis
  54668. */
  54669. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  54670. /**
  54671. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  54672. */
  54673. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  54674. /**
  54675. * Post-process used to merge the volumetric light effect and the real scene color
  54676. */
  54677. volumetricLightMergePostProces: Nullable<PostProcess>;
  54678. /**
  54679. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  54680. */
  54681. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  54682. /**
  54683. * Base post-process used to calculate the average luminance of the final image for HDR
  54684. */
  54685. luminancePostProcess: Nullable<PostProcess>;
  54686. /**
  54687. * Post-processes used to create down sample post-processes in order to get
  54688. * the average luminance of the final image for HDR
  54689. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  54690. */
  54691. luminanceDownSamplePostProcesses: PostProcess[];
  54692. /**
  54693. * Post-process used to create a HDR effect (light adaptation)
  54694. */
  54695. hdrPostProcess: Nullable<PostProcess>;
  54696. /**
  54697. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  54698. */
  54699. textureAdderFinalPostProcess: Nullable<PostProcess>;
  54700. /**
  54701. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  54702. */
  54703. lensFlareFinalPostProcess: Nullable<PostProcess>;
  54704. /**
  54705. * Post-process used to merge the final HDR post-process and the real scene color
  54706. */
  54707. hdrFinalPostProcess: Nullable<PostProcess>;
  54708. /**
  54709. * Post-process used to create a lens flare effect
  54710. */
  54711. lensFlarePostProcess: Nullable<PostProcess>;
  54712. /**
  54713. * Post-process that merges the result of the lens flare post-process and the real scene color
  54714. */
  54715. lensFlareComposePostProcess: Nullable<PostProcess>;
  54716. /**
  54717. * Post-process used to create a motion blur effect
  54718. */
  54719. motionBlurPostProcess: Nullable<PostProcess>;
  54720. /**
  54721. * Post-process used to create a depth of field effect
  54722. */
  54723. depthOfFieldPostProcess: Nullable<PostProcess>;
  54724. /**
  54725. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54726. */
  54727. fxaaPostProcess: Nullable<FxaaPostProcess>;
  54728. /**
  54729. * Represents the brightness threshold in order to configure the illuminated surfaces
  54730. */
  54731. brightThreshold: number;
  54732. /**
  54733. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  54734. */
  54735. blurWidth: number;
  54736. /**
  54737. * Sets if the blur for highlighted surfaces must be only horizontal
  54738. */
  54739. horizontalBlur: boolean;
  54740. /**
  54741. * Sets the overall exposure used by the pipeline
  54742. */
  54743. exposure: number;
  54744. /**
  54745. * Texture used typically to simulate "dirty" on camera lens
  54746. */
  54747. lensTexture: Nullable<Texture>;
  54748. /**
  54749. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  54750. */
  54751. volumetricLightCoefficient: number;
  54752. /**
  54753. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  54754. */
  54755. volumetricLightPower: number;
  54756. /**
  54757. * Used the set the blur intensity to smooth the volumetric lights
  54758. */
  54759. volumetricLightBlurScale: number;
  54760. /**
  54761. * Light (spot or directional) used to generate the volumetric lights rays
  54762. * The source light must have a shadow generate so the pipeline can get its
  54763. * depth map
  54764. */
  54765. sourceLight: Nullable<SpotLight | DirectionalLight>;
  54766. /**
  54767. * For eye adaptation, represents the minimum luminance the eye can see
  54768. */
  54769. hdrMinimumLuminance: number;
  54770. /**
  54771. * For eye adaptation, represents the decrease luminance speed
  54772. */
  54773. hdrDecreaseRate: number;
  54774. /**
  54775. * For eye adaptation, represents the increase luminance speed
  54776. */
  54777. hdrIncreaseRate: number;
  54778. /**
  54779. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  54780. */
  54781. lensColorTexture: Nullable<Texture>;
  54782. /**
  54783. * The overall strengh for the lens flare effect
  54784. */
  54785. lensFlareStrength: number;
  54786. /**
  54787. * Dispersion coefficient for lens flare ghosts
  54788. */
  54789. lensFlareGhostDispersal: number;
  54790. /**
  54791. * Main lens flare halo width
  54792. */
  54793. lensFlareHaloWidth: number;
  54794. /**
  54795. * Based on the lens distortion effect, defines how much the lens flare result
  54796. * is distorted
  54797. */
  54798. lensFlareDistortionStrength: number;
  54799. /**
  54800. * Lens star texture must be used to simulate rays on the flares and is available
  54801. * in the documentation
  54802. */
  54803. lensStarTexture: Nullable<Texture>;
  54804. /**
  54805. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  54806. * flare effect by taking account of the dirt texture
  54807. */
  54808. lensFlareDirtTexture: Nullable<Texture>;
  54809. /**
  54810. * Represents the focal length for the depth of field effect
  54811. */
  54812. depthOfFieldDistance: number;
  54813. /**
  54814. * Represents the blur intensity for the blurred part of the depth of field effect
  54815. */
  54816. depthOfFieldBlurWidth: number;
  54817. /**
  54818. * For motion blur, defines how much the image is blurred by the movement
  54819. */
  54820. motionStrength: number;
  54821. /**
  54822. * List of animations for the pipeline (IAnimatable implementation)
  54823. */
  54824. animations: Animation[];
  54825. /**
  54826. * Private members
  54827. */
  54828. private _scene;
  54829. private _currentDepthOfFieldSource;
  54830. private _basePostProcess;
  54831. private _hdrCurrentLuminance;
  54832. private _floatTextureType;
  54833. private _ratio;
  54834. private _bloomEnabled;
  54835. private _depthOfFieldEnabled;
  54836. private _vlsEnabled;
  54837. private _lensFlareEnabled;
  54838. private _hdrEnabled;
  54839. private _motionBlurEnabled;
  54840. private _fxaaEnabled;
  54841. private _motionBlurSamples;
  54842. private _volumetricLightStepsCount;
  54843. private _samples;
  54844. /**
  54845. * @ignore
  54846. * Specifies if the bloom pipeline is enabled
  54847. */
  54848. BloomEnabled: boolean;
  54849. /**
  54850. * @ignore
  54851. * Specifies if the depth of field pipeline is enabed
  54852. */
  54853. DepthOfFieldEnabled: boolean;
  54854. /**
  54855. * @ignore
  54856. * Specifies if the lens flare pipeline is enabed
  54857. */
  54858. LensFlareEnabled: boolean;
  54859. /**
  54860. * @ignore
  54861. * Specifies if the HDR pipeline is enabled
  54862. */
  54863. HDREnabled: boolean;
  54864. /**
  54865. * @ignore
  54866. * Specifies if the volumetric lights scattering effect is enabled
  54867. */
  54868. VLSEnabled: boolean;
  54869. /**
  54870. * @ignore
  54871. * Specifies if the motion blur effect is enabled
  54872. */
  54873. MotionBlurEnabled: boolean;
  54874. /**
  54875. * Specifies if anti-aliasing is enabled
  54876. */
  54877. fxaaEnabled: boolean;
  54878. /**
  54879. * Specifies the number of steps used to calculate the volumetric lights
  54880. * Typically in interval [50, 200]
  54881. */
  54882. volumetricLightStepsCount: number;
  54883. /**
  54884. * Specifies the number of samples used for the motion blur effect
  54885. * Typically in interval [16, 64]
  54886. */
  54887. motionBlurSamples: number;
  54888. /**
  54889. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54890. */
  54891. samples: number;
  54892. /**
  54893. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54894. * @constructor
  54895. * @param name The rendering pipeline name
  54896. * @param scene The scene linked to this pipeline
  54897. * @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)
  54898. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  54899. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54900. */
  54901. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  54902. private _buildPipeline;
  54903. private _createDownSampleX4PostProcess;
  54904. private _createBrightPassPostProcess;
  54905. private _createBlurPostProcesses;
  54906. private _createTextureAdderPostProcess;
  54907. private _createVolumetricLightPostProcess;
  54908. private _createLuminancePostProcesses;
  54909. private _createHdrPostProcess;
  54910. private _createLensFlarePostProcess;
  54911. private _createDepthOfFieldPostProcess;
  54912. private _createMotionBlurPostProcess;
  54913. private _getDepthTexture;
  54914. private _disposePostProcesses;
  54915. /**
  54916. * Dispose of the pipeline and stop all post processes
  54917. */
  54918. dispose(): void;
  54919. /**
  54920. * Serialize the rendering pipeline (Used when exporting)
  54921. * @returns the serialized object
  54922. */
  54923. serialize(): any;
  54924. /**
  54925. * Parse the serialized pipeline
  54926. * @param source Source pipeline.
  54927. * @param scene The scene to load the pipeline to.
  54928. * @param rootUrl The URL of the serialized pipeline.
  54929. * @returns An instantiated pipeline from the serialized object.
  54930. */
  54931. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  54932. /**
  54933. * Luminance steps
  54934. */
  54935. static LuminanceSteps: number;
  54936. }
  54937. }
  54938. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  54939. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  54940. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  54941. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  54942. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  54943. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  54944. }
  54945. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  54946. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  54947. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54948. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54949. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54950. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54951. }
  54952. declare module "babylonjs/Shaders/tonemap.fragment" {
  54953. /** @hidden */
  54954. export var tonemapPixelShader: {
  54955. name: string;
  54956. shader: string;
  54957. };
  54958. }
  54959. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  54960. import { Camera } from "babylonjs/Cameras/camera";
  54961. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54962. import "babylonjs/Shaders/tonemap.fragment";
  54963. import { Engine } from "babylonjs/Engines/engine";
  54964. /** Defines operator used for tonemapping */
  54965. export enum TonemappingOperator {
  54966. /** Hable */
  54967. Hable = 0,
  54968. /** Reinhard */
  54969. Reinhard = 1,
  54970. /** HejiDawson */
  54971. HejiDawson = 2,
  54972. /** Photographic */
  54973. Photographic = 3
  54974. }
  54975. /**
  54976. * Defines a post process to apply tone mapping
  54977. */
  54978. export class TonemapPostProcess extends PostProcess {
  54979. private _operator;
  54980. /** Defines the required exposure adjustement */
  54981. exposureAdjustment: number;
  54982. /**
  54983. * Creates a new TonemapPostProcess
  54984. * @param name defines the name of the postprocess
  54985. * @param _operator defines the operator to use
  54986. * @param exposureAdjustment defines the required exposure adjustement
  54987. * @param camera defines the camera to use (can be null)
  54988. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  54989. * @param engine defines the hosting engine (can be ignore if camera is set)
  54990. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54991. */
  54992. constructor(name: string, _operator: TonemappingOperator,
  54993. /** Defines the required exposure adjustement */
  54994. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  54995. }
  54996. }
  54997. declare module "babylonjs/Shaders/depth.vertex" {
  54998. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54999. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55000. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55001. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55002. /** @hidden */
  55003. export var depthVertexShader: {
  55004. name: string;
  55005. shader: string;
  55006. };
  55007. }
  55008. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  55009. /** @hidden */
  55010. export var volumetricLightScatteringPixelShader: {
  55011. name: string;
  55012. shader: string;
  55013. };
  55014. }
  55015. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  55016. /** @hidden */
  55017. export var volumetricLightScatteringPassPixelShader: {
  55018. name: string;
  55019. shader: string;
  55020. };
  55021. }
  55022. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  55023. import { Vector3 } from "babylonjs/Maths/math";
  55024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55025. import { Mesh } from "babylonjs/Meshes/mesh";
  55026. import { Camera } from "babylonjs/Cameras/camera";
  55027. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55028. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55029. import { Scene } from "babylonjs/scene";
  55030. import "babylonjs/Meshes/Builders/planeBuilder";
  55031. import "babylonjs/Shaders/depth.vertex";
  55032. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  55033. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  55034. import { Engine } from "babylonjs/Engines/engine";
  55035. /**
  55036. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  55037. */
  55038. export class VolumetricLightScatteringPostProcess extends PostProcess {
  55039. private _volumetricLightScatteringPass;
  55040. private _volumetricLightScatteringRTT;
  55041. private _viewPort;
  55042. private _screenCoordinates;
  55043. private _cachedDefines;
  55044. /**
  55045. * If not undefined, the mesh position is computed from the attached node position
  55046. */
  55047. attachedNode: {
  55048. position: Vector3;
  55049. };
  55050. /**
  55051. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  55052. */
  55053. customMeshPosition: Vector3;
  55054. /**
  55055. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  55056. */
  55057. useCustomMeshPosition: boolean;
  55058. /**
  55059. * If the post-process should inverse the light scattering direction
  55060. */
  55061. invert: boolean;
  55062. /**
  55063. * The internal mesh used by the post-process
  55064. */
  55065. mesh: Mesh;
  55066. /**
  55067. * @hidden
  55068. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  55069. */
  55070. useDiffuseColor: boolean;
  55071. /**
  55072. * Array containing the excluded meshes not rendered in the internal pass
  55073. */
  55074. excludedMeshes: AbstractMesh[];
  55075. /**
  55076. * Controls the overall intensity of the post-process
  55077. */
  55078. exposure: number;
  55079. /**
  55080. * Dissipates each sample's contribution in range [0, 1]
  55081. */
  55082. decay: number;
  55083. /**
  55084. * Controls the overall intensity of each sample
  55085. */
  55086. weight: number;
  55087. /**
  55088. * Controls the density of each sample
  55089. */
  55090. density: number;
  55091. /**
  55092. * @constructor
  55093. * @param name The post-process name
  55094. * @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)
  55095. * @param camera The camera that the post-process will be attached to
  55096. * @param mesh The mesh used to create the light scattering
  55097. * @param samples The post-process quality, default 100
  55098. * @param samplingModeThe post-process filtering mode
  55099. * @param engine The babylon engine
  55100. * @param reusable If the post-process is reusable
  55101. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  55102. */
  55103. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  55104. /**
  55105. * Returns the string "VolumetricLightScatteringPostProcess"
  55106. * @returns "VolumetricLightScatteringPostProcess"
  55107. */
  55108. getClassName(): string;
  55109. private _isReady;
  55110. /**
  55111. * Sets the new light position for light scattering effect
  55112. * @param position The new custom light position
  55113. */
  55114. setCustomMeshPosition(position: Vector3): void;
  55115. /**
  55116. * Returns the light position for light scattering effect
  55117. * @return Vector3 The custom light position
  55118. */
  55119. getCustomMeshPosition(): Vector3;
  55120. /**
  55121. * Disposes the internal assets and detaches the post-process from the camera
  55122. */
  55123. dispose(camera: Camera): void;
  55124. /**
  55125. * Returns the render target texture used by the post-process
  55126. * @return the render target texture used by the post-process
  55127. */
  55128. getPass(): RenderTargetTexture;
  55129. private _meshExcluded;
  55130. private _createPass;
  55131. private _updateMeshScreenCoordinates;
  55132. /**
  55133. * Creates a default mesh for the Volumeric Light Scattering post-process
  55134. * @param name The mesh name
  55135. * @param scene The scene where to create the mesh
  55136. * @return the default mesh
  55137. */
  55138. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  55139. }
  55140. }
  55141. declare module "babylonjs/PostProcesses/index" {
  55142. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  55143. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  55144. export * from "babylonjs/PostProcesses/bloomEffect";
  55145. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  55146. export * from "babylonjs/PostProcesses/blurPostProcess";
  55147. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55148. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  55149. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  55150. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  55151. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55152. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  55153. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  55154. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  55155. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  55156. export * from "babylonjs/PostProcesses/filterPostProcess";
  55157. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  55158. export * from "babylonjs/PostProcesses/grainPostProcess";
  55159. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  55160. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55161. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  55162. export * from "babylonjs/PostProcesses/passPostProcess";
  55163. export * from "babylonjs/PostProcesses/postProcess";
  55164. export * from "babylonjs/PostProcesses/postProcessManager";
  55165. export * from "babylonjs/PostProcesses/refractionPostProcess";
  55166. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  55167. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  55168. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  55169. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  55170. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  55171. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  55172. }
  55173. declare module "babylonjs/Probes/index" {
  55174. export * from "babylonjs/Probes/reflectionProbe";
  55175. }
  55176. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  55177. import { Scene } from "babylonjs/scene";
  55178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55179. import { Color3 } from "babylonjs/Maths/math";
  55180. import { SmartArray } from "babylonjs/Misc/smartArray";
  55181. import { ISceneComponent } from "babylonjs/sceneComponent";
  55182. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  55183. import "babylonjs/Meshes/Builders/boxBuilder";
  55184. import "babylonjs/Shaders/color.fragment";
  55185. import "babylonjs/Shaders/color.vertex";
  55186. module "babylonjs/scene" {
  55187. interface Scene {
  55188. /** @hidden (Backing field) */
  55189. _boundingBoxRenderer: BoundingBoxRenderer;
  55190. /** @hidden (Backing field) */
  55191. _forceShowBoundingBoxes: boolean;
  55192. /**
  55193. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  55194. */
  55195. forceShowBoundingBoxes: boolean;
  55196. /**
  55197. * Gets the bounding box renderer associated with the scene
  55198. * @returns a BoundingBoxRenderer
  55199. */
  55200. getBoundingBoxRenderer(): BoundingBoxRenderer;
  55201. }
  55202. }
  55203. module "babylonjs/Meshes/abstractMesh" {
  55204. interface AbstractMesh {
  55205. /** @hidden (Backing field) */
  55206. _showBoundingBox: boolean;
  55207. /**
  55208. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  55209. */
  55210. showBoundingBox: boolean;
  55211. }
  55212. }
  55213. /**
  55214. * Component responsible of rendering the bounding box of the meshes in a scene.
  55215. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  55216. */
  55217. export class BoundingBoxRenderer implements ISceneComponent {
  55218. /**
  55219. * The component name helpfull to identify the component in the list of scene components.
  55220. */
  55221. readonly name: string;
  55222. /**
  55223. * The scene the component belongs to.
  55224. */
  55225. scene: Scene;
  55226. /**
  55227. * Color of the bounding box lines placed in front of an object
  55228. */
  55229. frontColor: Color3;
  55230. /**
  55231. * Color of the bounding box lines placed behind an object
  55232. */
  55233. backColor: Color3;
  55234. /**
  55235. * Defines if the renderer should show the back lines or not
  55236. */
  55237. showBackLines: boolean;
  55238. /**
  55239. * @hidden
  55240. */
  55241. renderList: SmartArray<BoundingBox>;
  55242. private _colorShader;
  55243. private _vertexBuffers;
  55244. private _indexBuffer;
  55245. /**
  55246. * Instantiates a new bounding box renderer in a scene.
  55247. * @param scene the scene the renderer renders in
  55248. */
  55249. constructor(scene: Scene);
  55250. /**
  55251. * Registers the component in a given scene
  55252. */
  55253. register(): void;
  55254. private _evaluateSubMesh;
  55255. private _activeMesh;
  55256. private _prepareRessources;
  55257. private _createIndexBuffer;
  55258. /**
  55259. * Rebuilds the elements related to this component in case of
  55260. * context lost for instance.
  55261. */
  55262. rebuild(): void;
  55263. /**
  55264. * @hidden
  55265. */
  55266. reset(): void;
  55267. /**
  55268. * Render the bounding boxes of a specific rendering group
  55269. * @param renderingGroupId defines the rendering group to render
  55270. */
  55271. render(renderingGroupId: number): void;
  55272. /**
  55273. * In case of occlusion queries, we can render the occlusion bounding box through this method
  55274. * @param mesh Define the mesh to render the occlusion bounding box for
  55275. */
  55276. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  55277. /**
  55278. * Dispose and release the resources attached to this renderer.
  55279. */
  55280. dispose(): void;
  55281. }
  55282. }
  55283. declare module "babylonjs/Shaders/depth.fragment" {
  55284. /** @hidden */
  55285. export var depthPixelShader: {
  55286. name: string;
  55287. shader: string;
  55288. };
  55289. }
  55290. declare module "babylonjs/Rendering/depthRenderer" {
  55291. import { Nullable } from "babylonjs/types";
  55292. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55293. import { Scene } from "babylonjs/scene";
  55294. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55295. import { Camera } from "babylonjs/Cameras/camera";
  55296. import "babylonjs/Shaders/depth.fragment";
  55297. import "babylonjs/Shaders/depth.vertex";
  55298. /**
  55299. * This represents a depth renderer in Babylon.
  55300. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  55301. */
  55302. export class DepthRenderer {
  55303. private _scene;
  55304. private _depthMap;
  55305. private _effect;
  55306. private _cachedDefines;
  55307. private _camera;
  55308. /**
  55309. * Specifiess that the depth renderer will only be used within
  55310. * the camera it is created for.
  55311. * This can help forcing its rendering during the camera processing.
  55312. */
  55313. useOnlyInActiveCamera: boolean;
  55314. /** @hidden */
  55315. static _SceneComponentInitialization: (scene: Scene) => void;
  55316. /**
  55317. * Instantiates a depth renderer
  55318. * @param scene The scene the renderer belongs to
  55319. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  55320. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  55321. */
  55322. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  55323. /**
  55324. * Creates the depth rendering effect and checks if the effect is ready.
  55325. * @param subMesh The submesh to be used to render the depth map of
  55326. * @param useInstances If multiple world instances should be used
  55327. * @returns if the depth renderer is ready to render the depth map
  55328. */
  55329. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55330. /**
  55331. * Gets the texture which the depth map will be written to.
  55332. * @returns The depth map texture
  55333. */
  55334. getDepthMap(): RenderTargetTexture;
  55335. /**
  55336. * Disposes of the depth renderer.
  55337. */
  55338. dispose(): void;
  55339. }
  55340. }
  55341. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  55342. import { Nullable } from "babylonjs/types";
  55343. import { Scene } from "babylonjs/scene";
  55344. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  55345. import { Camera } from "babylonjs/Cameras/camera";
  55346. import { ISceneComponent } from "babylonjs/sceneComponent";
  55347. module "babylonjs/scene" {
  55348. interface Scene {
  55349. /** @hidden (Backing field) */
  55350. _depthRenderer: {
  55351. [id: string]: DepthRenderer;
  55352. };
  55353. /**
  55354. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  55355. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  55356. * @returns the created depth renderer
  55357. */
  55358. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  55359. /**
  55360. * Disables a depth renderer for a given camera
  55361. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  55362. */
  55363. disableDepthRenderer(camera?: Nullable<Camera>): void;
  55364. }
  55365. }
  55366. /**
  55367. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  55368. * in several rendering techniques.
  55369. */
  55370. export class DepthRendererSceneComponent implements ISceneComponent {
  55371. /**
  55372. * The component name helpfull to identify the component in the list of scene components.
  55373. */
  55374. readonly name: string;
  55375. /**
  55376. * The scene the component belongs to.
  55377. */
  55378. scene: Scene;
  55379. /**
  55380. * Creates a new instance of the component for the given scene
  55381. * @param scene Defines the scene to register the component in
  55382. */
  55383. constructor(scene: Scene);
  55384. /**
  55385. * Registers the component in a given scene
  55386. */
  55387. register(): void;
  55388. /**
  55389. * Rebuilds the elements related to this component in case of
  55390. * context lost for instance.
  55391. */
  55392. rebuild(): void;
  55393. /**
  55394. * Disposes the component and the associated ressources
  55395. */
  55396. dispose(): void;
  55397. private _gatherRenderTargets;
  55398. private _gatherActiveCameraRenderTargets;
  55399. }
  55400. }
  55401. declare module "babylonjs/Shaders/outline.fragment" {
  55402. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55403. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  55404. /** @hidden */
  55405. export var outlinePixelShader: {
  55406. name: string;
  55407. shader: string;
  55408. };
  55409. }
  55410. declare module "babylonjs/Shaders/outline.vertex" {
  55411. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55412. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55413. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55414. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55415. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55416. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  55417. /** @hidden */
  55418. export var outlineVertexShader: {
  55419. name: string;
  55420. shader: string;
  55421. };
  55422. }
  55423. declare module "babylonjs/Rendering/outlineRenderer" {
  55424. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55425. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  55426. import { Scene } from "babylonjs/scene";
  55427. import { ISceneComponent } from "babylonjs/sceneComponent";
  55428. import "babylonjs/Shaders/outline.fragment";
  55429. import "babylonjs/Shaders/outline.vertex";
  55430. module "babylonjs/scene" {
  55431. interface Scene {
  55432. /** @hidden */
  55433. _outlineRenderer: OutlineRenderer;
  55434. /**
  55435. * Gets the outline renderer associated with the scene
  55436. * @returns a OutlineRenderer
  55437. */
  55438. getOutlineRenderer(): OutlineRenderer;
  55439. }
  55440. }
  55441. module "babylonjs/Meshes/abstractMesh" {
  55442. interface AbstractMesh {
  55443. /** @hidden (Backing field) */
  55444. _renderOutline: boolean;
  55445. /**
  55446. * Gets or sets a boolean indicating if the outline must be rendered as well
  55447. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  55448. */
  55449. renderOutline: boolean;
  55450. /** @hidden (Backing field) */
  55451. _renderOverlay: boolean;
  55452. /**
  55453. * Gets or sets a boolean indicating if the overlay must be rendered as well
  55454. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  55455. */
  55456. renderOverlay: boolean;
  55457. }
  55458. }
  55459. /**
  55460. * This class is responsible to draw bothe outline/overlay of meshes.
  55461. * It should not be used directly but through the available method on mesh.
  55462. */
  55463. export class OutlineRenderer implements ISceneComponent {
  55464. /**
  55465. * The name of the component. Each component must have a unique name.
  55466. */
  55467. name: string;
  55468. /**
  55469. * The scene the component belongs to.
  55470. */
  55471. scene: Scene;
  55472. /**
  55473. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  55474. */
  55475. zOffset: number;
  55476. private _engine;
  55477. private _effect;
  55478. private _cachedDefines;
  55479. private _savedDepthWrite;
  55480. /**
  55481. * Instantiates a new outline renderer. (There could be only one per scene).
  55482. * @param scene Defines the scene it belongs to
  55483. */
  55484. constructor(scene: Scene);
  55485. /**
  55486. * Register the component to one instance of a scene.
  55487. */
  55488. register(): void;
  55489. /**
  55490. * Rebuilds the elements related to this component in case of
  55491. * context lost for instance.
  55492. */
  55493. rebuild(): void;
  55494. /**
  55495. * Disposes the component and the associated ressources.
  55496. */
  55497. dispose(): void;
  55498. /**
  55499. * Renders the outline in the canvas.
  55500. * @param subMesh Defines the sumesh to render
  55501. * @param batch Defines the batch of meshes in case of instances
  55502. * @param useOverlay Defines if the rendering is for the overlay or the outline
  55503. */
  55504. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  55505. /**
  55506. * Returns whether or not the outline renderer is ready for a given submesh.
  55507. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  55508. * @param subMesh Defines the submesh to check readyness for
  55509. * @param useInstances Defines wheter wee are trying to render instances or not
  55510. * @returns true if ready otherwise false
  55511. */
  55512. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55513. private _beforeRenderingMesh;
  55514. private _afterRenderingMesh;
  55515. }
  55516. }
  55517. declare module "babylonjs/Rendering/index" {
  55518. export * from "babylonjs/Rendering/boundingBoxRenderer";
  55519. export * from "babylonjs/Rendering/depthRenderer";
  55520. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  55521. export * from "babylonjs/Rendering/edgesRenderer";
  55522. export * from "babylonjs/Rendering/geometryBufferRenderer";
  55523. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55524. export * from "babylonjs/Rendering/outlineRenderer";
  55525. export * from "babylonjs/Rendering/renderingGroup";
  55526. export * from "babylonjs/Rendering/renderingManager";
  55527. export * from "babylonjs/Rendering/utilityLayerRenderer";
  55528. }
  55529. declare module "babylonjs/Sprites/index" {
  55530. export * from "babylonjs/Sprites/sprite";
  55531. export * from "babylonjs/Sprites/spriteManager";
  55532. export * from "babylonjs/Sprites/spriteSceneComponent";
  55533. }
  55534. declare module "babylonjs/Misc/assetsManager" {
  55535. import { Scene } from "babylonjs/scene";
  55536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55537. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  55538. import { Skeleton } from "babylonjs/Bones/skeleton";
  55539. import { Observable } from "babylonjs/Misc/observable";
  55540. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55541. import { Texture } from "babylonjs/Materials/Textures/texture";
  55542. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55543. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  55544. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  55545. /**
  55546. * Defines the list of states available for a task inside a AssetsManager
  55547. */
  55548. export enum AssetTaskState {
  55549. /**
  55550. * Initialization
  55551. */
  55552. INIT = 0,
  55553. /**
  55554. * Running
  55555. */
  55556. RUNNING = 1,
  55557. /**
  55558. * Done
  55559. */
  55560. DONE = 2,
  55561. /**
  55562. * Error
  55563. */
  55564. ERROR = 3
  55565. }
  55566. /**
  55567. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  55568. */
  55569. export abstract class AbstractAssetTask {
  55570. /**
  55571. * Task name
  55572. */ name: string;
  55573. /**
  55574. * Callback called when the task is successful
  55575. */
  55576. onSuccess: (task: any) => void;
  55577. /**
  55578. * Callback called when the task is not successful
  55579. */
  55580. onError: (task: any, message?: string, exception?: any) => void;
  55581. /**
  55582. * Creates a new AssetsManager
  55583. * @param name defines the name of the task
  55584. */
  55585. constructor(
  55586. /**
  55587. * Task name
  55588. */ name: string);
  55589. private _isCompleted;
  55590. private _taskState;
  55591. private _errorObject;
  55592. /**
  55593. * Get if the task is completed
  55594. */
  55595. readonly isCompleted: boolean;
  55596. /**
  55597. * Gets the current state of the task
  55598. */
  55599. readonly taskState: AssetTaskState;
  55600. /**
  55601. * Gets the current error object (if task is in error)
  55602. */
  55603. readonly errorObject: {
  55604. message?: string;
  55605. exception?: any;
  55606. };
  55607. /**
  55608. * Internal only
  55609. * @hidden
  55610. */
  55611. _setErrorObject(message?: string, exception?: any): void;
  55612. /**
  55613. * Execute the current task
  55614. * @param scene defines the scene where you want your assets to be loaded
  55615. * @param onSuccess is a callback called when the task is successfully executed
  55616. * @param onError is a callback called if an error occurs
  55617. */
  55618. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55619. /**
  55620. * Execute the current task
  55621. * @param scene defines the scene where you want your assets to be loaded
  55622. * @param onSuccess is a callback called when the task is successfully executed
  55623. * @param onError is a callback called if an error occurs
  55624. */
  55625. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55626. /**
  55627. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  55628. * This can be used with failed tasks that have the reason for failure fixed.
  55629. */
  55630. reset(): void;
  55631. private onErrorCallback;
  55632. private onDoneCallback;
  55633. }
  55634. /**
  55635. * Define the interface used by progress events raised during assets loading
  55636. */
  55637. export interface IAssetsProgressEvent {
  55638. /**
  55639. * Defines the number of remaining tasks to process
  55640. */
  55641. remainingCount: number;
  55642. /**
  55643. * Defines the total number of tasks
  55644. */
  55645. totalCount: number;
  55646. /**
  55647. * Defines the task that was just processed
  55648. */
  55649. task: AbstractAssetTask;
  55650. }
  55651. /**
  55652. * Class used to share progress information about assets loading
  55653. */
  55654. export class AssetsProgressEvent implements IAssetsProgressEvent {
  55655. /**
  55656. * Defines the number of remaining tasks to process
  55657. */
  55658. remainingCount: number;
  55659. /**
  55660. * Defines the total number of tasks
  55661. */
  55662. totalCount: number;
  55663. /**
  55664. * Defines the task that was just processed
  55665. */
  55666. task: AbstractAssetTask;
  55667. /**
  55668. * Creates a AssetsProgressEvent
  55669. * @param remainingCount defines the number of remaining tasks to process
  55670. * @param totalCount defines the total number of tasks
  55671. * @param task defines the task that was just processed
  55672. */
  55673. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  55674. }
  55675. /**
  55676. * Define a task used by AssetsManager to load meshes
  55677. */
  55678. export class MeshAssetTask extends AbstractAssetTask {
  55679. /**
  55680. * Defines the name of the task
  55681. */
  55682. name: string;
  55683. /**
  55684. * Defines the list of mesh's names you want to load
  55685. */
  55686. meshesNames: any;
  55687. /**
  55688. * Defines the root url to use as a base to load your meshes and associated resources
  55689. */
  55690. rootUrl: string;
  55691. /**
  55692. * Defines the filename of the scene to load from
  55693. */
  55694. sceneFilename: string;
  55695. /**
  55696. * Gets the list of loaded meshes
  55697. */
  55698. loadedMeshes: Array<AbstractMesh>;
  55699. /**
  55700. * Gets the list of loaded particle systems
  55701. */
  55702. loadedParticleSystems: Array<IParticleSystem>;
  55703. /**
  55704. * Gets the list of loaded skeletons
  55705. */
  55706. loadedSkeletons: Array<Skeleton>;
  55707. /**
  55708. * Gets the list of loaded animation groups
  55709. */
  55710. loadedAnimationGroups: Array<AnimationGroup>;
  55711. /**
  55712. * Callback called when the task is successful
  55713. */
  55714. onSuccess: (task: MeshAssetTask) => void;
  55715. /**
  55716. * Callback called when the task is successful
  55717. */
  55718. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  55719. /**
  55720. * Creates a new MeshAssetTask
  55721. * @param name defines the name of the task
  55722. * @param meshesNames defines the list of mesh's names you want to load
  55723. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  55724. * @param sceneFilename defines the filename of the scene to load from
  55725. */
  55726. constructor(
  55727. /**
  55728. * Defines the name of the task
  55729. */
  55730. name: string,
  55731. /**
  55732. * Defines the list of mesh's names you want to load
  55733. */
  55734. meshesNames: any,
  55735. /**
  55736. * Defines the root url to use as a base to load your meshes and associated resources
  55737. */
  55738. rootUrl: string,
  55739. /**
  55740. * Defines the filename of the scene to load from
  55741. */
  55742. sceneFilename: string);
  55743. /**
  55744. * Execute the current task
  55745. * @param scene defines the scene where you want your assets to be loaded
  55746. * @param onSuccess is a callback called when the task is successfully executed
  55747. * @param onError is a callback called if an error occurs
  55748. */
  55749. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55750. }
  55751. /**
  55752. * Define a task used by AssetsManager to load text content
  55753. */
  55754. export class TextFileAssetTask extends AbstractAssetTask {
  55755. /**
  55756. * Defines the name of the task
  55757. */
  55758. name: string;
  55759. /**
  55760. * Defines the location of the file to load
  55761. */
  55762. url: string;
  55763. /**
  55764. * Gets the loaded text string
  55765. */
  55766. text: string;
  55767. /**
  55768. * Callback called when the task is successful
  55769. */
  55770. onSuccess: (task: TextFileAssetTask) => void;
  55771. /**
  55772. * Callback called when the task is successful
  55773. */
  55774. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  55775. /**
  55776. * Creates a new TextFileAssetTask object
  55777. * @param name defines the name of the task
  55778. * @param url defines the location of the file to load
  55779. */
  55780. constructor(
  55781. /**
  55782. * Defines the name of the task
  55783. */
  55784. name: string,
  55785. /**
  55786. * Defines the location of the file to load
  55787. */
  55788. url: string);
  55789. /**
  55790. * Execute the current task
  55791. * @param scene defines the scene where you want your assets to be loaded
  55792. * @param onSuccess is a callback called when the task is successfully executed
  55793. * @param onError is a callback called if an error occurs
  55794. */
  55795. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55796. }
  55797. /**
  55798. * Define a task used by AssetsManager to load binary data
  55799. */
  55800. export class BinaryFileAssetTask extends AbstractAssetTask {
  55801. /**
  55802. * Defines the name of the task
  55803. */
  55804. name: string;
  55805. /**
  55806. * Defines the location of the file to load
  55807. */
  55808. url: string;
  55809. /**
  55810. * Gets the lodaded data (as an array buffer)
  55811. */
  55812. data: ArrayBuffer;
  55813. /**
  55814. * Callback called when the task is successful
  55815. */
  55816. onSuccess: (task: BinaryFileAssetTask) => void;
  55817. /**
  55818. * Callback called when the task is successful
  55819. */
  55820. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  55821. /**
  55822. * Creates a new BinaryFileAssetTask object
  55823. * @param name defines the name of the new task
  55824. * @param url defines the location of the file to load
  55825. */
  55826. constructor(
  55827. /**
  55828. * Defines the name of the task
  55829. */
  55830. name: string,
  55831. /**
  55832. * Defines the location of the file to load
  55833. */
  55834. url: string);
  55835. /**
  55836. * Execute the current task
  55837. * @param scene defines the scene where you want your assets to be loaded
  55838. * @param onSuccess is a callback called when the task is successfully executed
  55839. * @param onError is a callback called if an error occurs
  55840. */
  55841. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55842. }
  55843. /**
  55844. * Define a task used by AssetsManager to load images
  55845. */
  55846. export class ImageAssetTask extends AbstractAssetTask {
  55847. /**
  55848. * Defines the name of the task
  55849. */
  55850. name: string;
  55851. /**
  55852. * Defines the location of the image to load
  55853. */
  55854. url: string;
  55855. /**
  55856. * Gets the loaded images
  55857. */
  55858. image: HTMLImageElement;
  55859. /**
  55860. * Callback called when the task is successful
  55861. */
  55862. onSuccess: (task: ImageAssetTask) => void;
  55863. /**
  55864. * Callback called when the task is successful
  55865. */
  55866. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  55867. /**
  55868. * Creates a new ImageAssetTask
  55869. * @param name defines the name of the task
  55870. * @param url defines the location of the image to load
  55871. */
  55872. constructor(
  55873. /**
  55874. * Defines the name of the task
  55875. */
  55876. name: string,
  55877. /**
  55878. * Defines the location of the image to load
  55879. */
  55880. url: string);
  55881. /**
  55882. * Execute the current task
  55883. * @param scene defines the scene where you want your assets to be loaded
  55884. * @param onSuccess is a callback called when the task is successfully executed
  55885. * @param onError is a callback called if an error occurs
  55886. */
  55887. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55888. }
  55889. /**
  55890. * Defines the interface used by texture loading tasks
  55891. */
  55892. export interface ITextureAssetTask<TEX extends BaseTexture> {
  55893. /**
  55894. * Gets the loaded texture
  55895. */
  55896. texture: TEX;
  55897. }
  55898. /**
  55899. * Define a task used by AssetsManager to load 2D textures
  55900. */
  55901. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  55902. /**
  55903. * Defines the name of the task
  55904. */
  55905. name: string;
  55906. /**
  55907. * Defines the location of the file to load
  55908. */
  55909. url: string;
  55910. /**
  55911. * Defines if mipmap should not be generated (default is false)
  55912. */
  55913. noMipmap?: boolean | undefined;
  55914. /**
  55915. * Defines if texture must be inverted on Y axis (default is false)
  55916. */
  55917. invertY?: boolean | undefined;
  55918. /**
  55919. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55920. */
  55921. samplingMode: number;
  55922. /**
  55923. * Gets the loaded texture
  55924. */
  55925. texture: Texture;
  55926. /**
  55927. * Callback called when the task is successful
  55928. */
  55929. onSuccess: (task: TextureAssetTask) => void;
  55930. /**
  55931. * Callback called when the task is successful
  55932. */
  55933. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  55934. /**
  55935. * Creates a new TextureAssetTask object
  55936. * @param name defines the name of the task
  55937. * @param url defines the location of the file to load
  55938. * @param noMipmap defines if mipmap should not be generated (default is false)
  55939. * @param invertY defines if texture must be inverted on Y axis (default is false)
  55940. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55941. */
  55942. constructor(
  55943. /**
  55944. * Defines the name of the task
  55945. */
  55946. name: string,
  55947. /**
  55948. * Defines the location of the file to load
  55949. */
  55950. url: string,
  55951. /**
  55952. * Defines if mipmap should not be generated (default is false)
  55953. */
  55954. noMipmap?: boolean | undefined,
  55955. /**
  55956. * Defines if texture must be inverted on Y axis (default is false)
  55957. */
  55958. invertY?: boolean | undefined,
  55959. /**
  55960. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55961. */
  55962. samplingMode?: number);
  55963. /**
  55964. * Execute the current task
  55965. * @param scene defines the scene where you want your assets to be loaded
  55966. * @param onSuccess is a callback called when the task is successfully executed
  55967. * @param onError is a callback called if an error occurs
  55968. */
  55969. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55970. }
  55971. /**
  55972. * Define a task used by AssetsManager to load cube textures
  55973. */
  55974. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  55975. /**
  55976. * Defines the name of the task
  55977. */
  55978. name: string;
  55979. /**
  55980. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55981. */
  55982. url: string;
  55983. /**
  55984. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55985. */
  55986. extensions?: string[] | undefined;
  55987. /**
  55988. * Defines if mipmaps should not be generated (default is false)
  55989. */
  55990. noMipmap?: boolean | undefined;
  55991. /**
  55992. * Defines the explicit list of files (undefined by default)
  55993. */
  55994. files?: string[] | undefined;
  55995. /**
  55996. * Gets the loaded texture
  55997. */
  55998. texture: CubeTexture;
  55999. /**
  56000. * Callback called when the task is successful
  56001. */
  56002. onSuccess: (task: CubeTextureAssetTask) => void;
  56003. /**
  56004. * Callback called when the task is successful
  56005. */
  56006. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  56007. /**
  56008. * Creates a new CubeTextureAssetTask
  56009. * @param name defines the name of the task
  56010. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56011. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56012. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56013. * @param files defines the explicit list of files (undefined by default)
  56014. */
  56015. constructor(
  56016. /**
  56017. * Defines the name of the task
  56018. */
  56019. name: string,
  56020. /**
  56021. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56022. */
  56023. url: string,
  56024. /**
  56025. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56026. */
  56027. extensions?: string[] | undefined,
  56028. /**
  56029. * Defines if mipmaps should not be generated (default is false)
  56030. */
  56031. noMipmap?: boolean | undefined,
  56032. /**
  56033. * Defines the explicit list of files (undefined by default)
  56034. */
  56035. files?: string[] | undefined);
  56036. /**
  56037. * Execute the current task
  56038. * @param scene defines the scene where you want your assets to be loaded
  56039. * @param onSuccess is a callback called when the task is successfully executed
  56040. * @param onError is a callback called if an error occurs
  56041. */
  56042. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56043. }
  56044. /**
  56045. * Define a task used by AssetsManager to load HDR cube textures
  56046. */
  56047. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  56048. /**
  56049. * Defines the name of the task
  56050. */
  56051. name: string;
  56052. /**
  56053. * Defines the location of the file to load
  56054. */
  56055. url: string;
  56056. /**
  56057. * Defines the desired size (the more it increases the longer the generation will be)
  56058. */
  56059. size: number;
  56060. /**
  56061. * Defines if mipmaps should not be generated (default is false)
  56062. */
  56063. noMipmap: boolean;
  56064. /**
  56065. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56066. */
  56067. generateHarmonics: boolean;
  56068. /**
  56069. * 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)
  56070. */
  56071. gammaSpace: boolean;
  56072. /**
  56073. * Internal Use Only
  56074. */
  56075. reserved: boolean;
  56076. /**
  56077. * Gets the loaded texture
  56078. */
  56079. texture: HDRCubeTexture;
  56080. /**
  56081. * Callback called when the task is successful
  56082. */
  56083. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  56084. /**
  56085. * Callback called when the task is successful
  56086. */
  56087. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  56088. /**
  56089. * Creates a new HDRCubeTextureAssetTask object
  56090. * @param name defines the name of the task
  56091. * @param url defines the location of the file to load
  56092. * @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.
  56093. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56094. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56095. * @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)
  56096. * @param reserved Internal use only
  56097. */
  56098. constructor(
  56099. /**
  56100. * Defines the name of the task
  56101. */
  56102. name: string,
  56103. /**
  56104. * Defines the location of the file to load
  56105. */
  56106. url: string,
  56107. /**
  56108. * Defines the desired size (the more it increases the longer the generation will be)
  56109. */
  56110. size: number,
  56111. /**
  56112. * Defines if mipmaps should not be generated (default is false)
  56113. */
  56114. noMipmap?: boolean,
  56115. /**
  56116. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56117. */
  56118. generateHarmonics?: boolean,
  56119. /**
  56120. * 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)
  56121. */
  56122. gammaSpace?: boolean,
  56123. /**
  56124. * Internal Use Only
  56125. */
  56126. reserved?: boolean);
  56127. /**
  56128. * Execute the current task
  56129. * @param scene defines the scene where you want your assets to be loaded
  56130. * @param onSuccess is a callback called when the task is successfully executed
  56131. * @param onError is a callback called if an error occurs
  56132. */
  56133. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56134. }
  56135. /**
  56136. * This class can be used to easily import assets into a scene
  56137. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  56138. */
  56139. export class AssetsManager {
  56140. private _scene;
  56141. private _isLoading;
  56142. protected _tasks: AbstractAssetTask[];
  56143. protected _waitingTasksCount: number;
  56144. protected _totalTasksCount: number;
  56145. /**
  56146. * Callback called when all tasks are processed
  56147. */
  56148. onFinish: (tasks: AbstractAssetTask[]) => void;
  56149. /**
  56150. * Callback called when a task is successful
  56151. */
  56152. onTaskSuccess: (task: AbstractAssetTask) => void;
  56153. /**
  56154. * Callback called when a task had an error
  56155. */
  56156. onTaskError: (task: AbstractAssetTask) => void;
  56157. /**
  56158. * Callback called when a task is done (whatever the result is)
  56159. */
  56160. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  56161. /**
  56162. * Observable called when all tasks are processed
  56163. */
  56164. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  56165. /**
  56166. * Observable called when a task had an error
  56167. */
  56168. onTaskErrorObservable: Observable<AbstractAssetTask>;
  56169. /**
  56170. * Observable called when a task is successful
  56171. */
  56172. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  56173. /**
  56174. * Observable called when a task is done (whatever the result is)
  56175. */
  56176. onProgressObservable: Observable<IAssetsProgressEvent>;
  56177. /**
  56178. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  56179. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  56180. */
  56181. useDefaultLoadingScreen: boolean;
  56182. /**
  56183. * Creates a new AssetsManager
  56184. * @param scene defines the scene to work on
  56185. */
  56186. constructor(scene: Scene);
  56187. /**
  56188. * Add a MeshAssetTask to the list of active tasks
  56189. * @param taskName defines the name of the new task
  56190. * @param meshesNames defines the name of meshes to load
  56191. * @param rootUrl defines the root url to use to locate files
  56192. * @param sceneFilename defines the filename of the scene file
  56193. * @returns a new MeshAssetTask object
  56194. */
  56195. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  56196. /**
  56197. * Add a TextFileAssetTask to the list of active tasks
  56198. * @param taskName defines the name of the new task
  56199. * @param url defines the url of the file to load
  56200. * @returns a new TextFileAssetTask object
  56201. */
  56202. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  56203. /**
  56204. * Add a BinaryFileAssetTask to the list of active tasks
  56205. * @param taskName defines the name of the new task
  56206. * @param url defines the url of the file to load
  56207. * @returns a new BinaryFileAssetTask object
  56208. */
  56209. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  56210. /**
  56211. * Add a ImageAssetTask to the list of active tasks
  56212. * @param taskName defines the name of the new task
  56213. * @param url defines the url of the file to load
  56214. * @returns a new ImageAssetTask object
  56215. */
  56216. addImageTask(taskName: string, url: string): ImageAssetTask;
  56217. /**
  56218. * Add a TextureAssetTask to the list of active tasks
  56219. * @param taskName defines the name of the new task
  56220. * @param url defines the url of the file to load
  56221. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56222. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  56223. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56224. * @returns a new TextureAssetTask object
  56225. */
  56226. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  56227. /**
  56228. * Add a CubeTextureAssetTask to the list of active tasks
  56229. * @param taskName defines the name of the new task
  56230. * @param url defines the url of the file to load
  56231. * @param extensions defines the extension to use to load the cube map (can be null)
  56232. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56233. * @param files defines the list of files to load (can be null)
  56234. * @returns a new CubeTextureAssetTask object
  56235. */
  56236. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  56237. /**
  56238. *
  56239. * Add a HDRCubeTextureAssetTask to the list of active tasks
  56240. * @param taskName defines the name of the new task
  56241. * @param url defines the url of the file to load
  56242. * @param size defines the size you want for the cubemap (can be null)
  56243. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56244. * @param generateHarmonics defines if you want to automatically generate (true by default)
  56245. * @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)
  56246. * @param reserved Internal use only
  56247. * @returns a new HDRCubeTextureAssetTask object
  56248. */
  56249. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  56250. /**
  56251. * Remove a task from the assets manager.
  56252. * @param task the task to remove
  56253. */
  56254. removeTask(task: AbstractAssetTask): void;
  56255. private _decreaseWaitingTasksCount;
  56256. private _runTask;
  56257. /**
  56258. * Reset the AssetsManager and remove all tasks
  56259. * @return the current instance of the AssetsManager
  56260. */
  56261. reset(): AssetsManager;
  56262. /**
  56263. * Start the loading process
  56264. * @return the current instance of the AssetsManager
  56265. */
  56266. load(): AssetsManager;
  56267. }
  56268. }
  56269. declare module "babylonjs/Misc/deferred" {
  56270. /**
  56271. * Wrapper class for promise with external resolve and reject.
  56272. */
  56273. export class Deferred<T> {
  56274. /**
  56275. * The promise associated with this deferred object.
  56276. */
  56277. readonly promise: Promise<T>;
  56278. private _resolve;
  56279. private _reject;
  56280. /**
  56281. * The resolve method of the promise associated with this deferred object.
  56282. */
  56283. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  56284. /**
  56285. * The reject method of the promise associated with this deferred object.
  56286. */
  56287. readonly reject: (reason?: any) => void;
  56288. /**
  56289. * Constructor for this deferred object.
  56290. */
  56291. constructor();
  56292. }
  56293. }
  56294. declare module "babylonjs/Misc/filesInput" {
  56295. import { Engine } from "babylonjs/Engines/engine";
  56296. import { Scene } from "babylonjs/scene";
  56297. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  56298. /**
  56299. * Class used to help managing file picking and drag'n'drop
  56300. */
  56301. export class FilesInput {
  56302. /**
  56303. * List of files ready to be loaded
  56304. */
  56305. static readonly FilesToLoad: {
  56306. [key: string]: File;
  56307. };
  56308. /**
  56309. * Callback called when a file is processed
  56310. */
  56311. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  56312. private _engine;
  56313. private _currentScene;
  56314. private _sceneLoadedCallback;
  56315. private _progressCallback;
  56316. private _additionalRenderLoopLogicCallback;
  56317. private _textureLoadingCallback;
  56318. private _startingProcessingFilesCallback;
  56319. private _onReloadCallback;
  56320. private _errorCallback;
  56321. private _elementToMonitor;
  56322. private _sceneFileToLoad;
  56323. private _filesToLoad;
  56324. /**
  56325. * Creates a new FilesInput
  56326. * @param engine defines the rendering engine
  56327. * @param scene defines the hosting scene
  56328. * @param sceneLoadedCallback callback called when scene is loaded
  56329. * @param progressCallback callback called to track progress
  56330. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  56331. * @param textureLoadingCallback callback called when a texture is loading
  56332. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  56333. * @param onReloadCallback callback called when a reload is requested
  56334. * @param errorCallback callback call if an error occurs
  56335. */
  56336. 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);
  56337. private _dragEnterHandler;
  56338. private _dragOverHandler;
  56339. private _dropHandler;
  56340. /**
  56341. * Calls this function to listen to drag'n'drop events on a specific DOM element
  56342. * @param elementToMonitor defines the DOM element to track
  56343. */
  56344. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  56345. /**
  56346. * Release all associated resources
  56347. */
  56348. dispose(): void;
  56349. private renderFunction;
  56350. private drag;
  56351. private drop;
  56352. private _traverseFolder;
  56353. private _processFiles;
  56354. /**
  56355. * Load files from a drop event
  56356. * @param event defines the drop event to use as source
  56357. */
  56358. loadFiles(event: any): void;
  56359. private _processReload;
  56360. /**
  56361. * Reload the current scene from the loaded files
  56362. */
  56363. reload(): void;
  56364. }
  56365. }
  56366. declare module "babylonjs/Misc/HighDynamicRange/index" {
  56367. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  56368. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  56369. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56370. }
  56371. declare module "babylonjs/Misc/sceneOptimizer" {
  56372. import { Scene, IDisposable } from "babylonjs/scene";
  56373. import { Observable } from "babylonjs/Misc/observable";
  56374. /**
  56375. * Defines the root class used to create scene optimization to use with SceneOptimizer
  56376. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56377. */
  56378. export class SceneOptimization {
  56379. /**
  56380. * Defines the priority of this optimization (0 by default which means first in the list)
  56381. */
  56382. priority: number;
  56383. /**
  56384. * Gets a string describing the action executed by the current optimization
  56385. * @returns description string
  56386. */
  56387. getDescription(): string;
  56388. /**
  56389. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56390. * @param scene defines the current scene where to apply this optimization
  56391. * @param optimizer defines the current optimizer
  56392. * @returns true if everything that can be done was applied
  56393. */
  56394. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56395. /**
  56396. * Creates the SceneOptimization object
  56397. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56398. * @param desc defines the description associated with the optimization
  56399. */
  56400. constructor(
  56401. /**
  56402. * Defines the priority of this optimization (0 by default which means first in the list)
  56403. */
  56404. priority?: number);
  56405. }
  56406. /**
  56407. * Defines an optimization used to reduce the size of render target textures
  56408. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56409. */
  56410. export class TextureOptimization extends SceneOptimization {
  56411. /**
  56412. * Defines the priority of this optimization (0 by default which means first in the list)
  56413. */
  56414. priority: number;
  56415. /**
  56416. * 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
  56417. */
  56418. maximumSize: number;
  56419. /**
  56420. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56421. */
  56422. step: number;
  56423. /**
  56424. * Gets a string describing the action executed by the current optimization
  56425. * @returns description string
  56426. */
  56427. getDescription(): string;
  56428. /**
  56429. * Creates the TextureOptimization object
  56430. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56431. * @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
  56432. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56433. */
  56434. constructor(
  56435. /**
  56436. * Defines the priority of this optimization (0 by default which means first in the list)
  56437. */
  56438. priority?: number,
  56439. /**
  56440. * 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
  56441. */
  56442. maximumSize?: number,
  56443. /**
  56444. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56445. */
  56446. step?: number);
  56447. /**
  56448. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56449. * @param scene defines the current scene where to apply this optimization
  56450. * @param optimizer defines the current optimizer
  56451. * @returns true if everything that can be done was applied
  56452. */
  56453. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56454. }
  56455. /**
  56456. * Defines an optimization used to increase or decrease the rendering resolution
  56457. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56458. */
  56459. export class HardwareScalingOptimization extends SceneOptimization {
  56460. /**
  56461. * Defines the priority of this optimization (0 by default which means first in the list)
  56462. */
  56463. priority: number;
  56464. /**
  56465. * Defines the maximum scale to use (2 by default)
  56466. */
  56467. maximumScale: number;
  56468. /**
  56469. * Defines the step to use between two passes (0.5 by default)
  56470. */
  56471. step: number;
  56472. private _currentScale;
  56473. private _directionOffset;
  56474. /**
  56475. * Gets a string describing the action executed by the current optimization
  56476. * @return description string
  56477. */
  56478. getDescription(): string;
  56479. /**
  56480. * Creates the HardwareScalingOptimization object
  56481. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56482. * @param maximumScale defines the maximum scale to use (2 by default)
  56483. * @param step defines the step to use between two passes (0.5 by default)
  56484. */
  56485. constructor(
  56486. /**
  56487. * Defines the priority of this optimization (0 by default which means first in the list)
  56488. */
  56489. priority?: number,
  56490. /**
  56491. * Defines the maximum scale to use (2 by default)
  56492. */
  56493. maximumScale?: number,
  56494. /**
  56495. * Defines the step to use between two passes (0.5 by default)
  56496. */
  56497. step?: number);
  56498. /**
  56499. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56500. * @param scene defines the current scene where to apply this optimization
  56501. * @param optimizer defines the current optimizer
  56502. * @returns true if everything that can be done was applied
  56503. */
  56504. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56505. }
  56506. /**
  56507. * Defines an optimization used to remove shadows
  56508. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56509. */
  56510. export class ShadowsOptimization extends SceneOptimization {
  56511. /**
  56512. * Gets a string describing the action executed by the current optimization
  56513. * @return description string
  56514. */
  56515. getDescription(): string;
  56516. /**
  56517. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56518. * @param scene defines the current scene where to apply this optimization
  56519. * @param optimizer defines the current optimizer
  56520. * @returns true if everything that can be done was applied
  56521. */
  56522. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56523. }
  56524. /**
  56525. * Defines an optimization used to turn post-processes off
  56526. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56527. */
  56528. export class PostProcessesOptimization extends SceneOptimization {
  56529. /**
  56530. * Gets a string describing the action executed by the current optimization
  56531. * @return description string
  56532. */
  56533. getDescription(): string;
  56534. /**
  56535. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56536. * @param scene defines the current scene where to apply this optimization
  56537. * @param optimizer defines the current optimizer
  56538. * @returns true if everything that can be done was applied
  56539. */
  56540. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56541. }
  56542. /**
  56543. * Defines an optimization used to turn lens flares off
  56544. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56545. */
  56546. export class LensFlaresOptimization extends SceneOptimization {
  56547. /**
  56548. * Gets a string describing the action executed by the current optimization
  56549. * @return description string
  56550. */
  56551. getDescription(): string;
  56552. /**
  56553. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56554. * @param scene defines the current scene where to apply this optimization
  56555. * @param optimizer defines the current optimizer
  56556. * @returns true if everything that can be done was applied
  56557. */
  56558. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56559. }
  56560. /**
  56561. * Defines an optimization based on user defined callback.
  56562. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56563. */
  56564. export class CustomOptimization extends SceneOptimization {
  56565. /**
  56566. * Callback called to apply the custom optimization.
  56567. */
  56568. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  56569. /**
  56570. * Callback called to get custom description
  56571. */
  56572. onGetDescription: () => string;
  56573. /**
  56574. * Gets a string describing the action executed by the current optimization
  56575. * @returns description string
  56576. */
  56577. getDescription(): string;
  56578. /**
  56579. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56580. * @param scene defines the current scene where to apply this optimization
  56581. * @param optimizer defines the current optimizer
  56582. * @returns true if everything that can be done was applied
  56583. */
  56584. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56585. }
  56586. /**
  56587. * Defines an optimization used to turn particles off
  56588. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56589. */
  56590. export class ParticlesOptimization extends SceneOptimization {
  56591. /**
  56592. * Gets a string describing the action executed by the current optimization
  56593. * @return description string
  56594. */
  56595. getDescription(): string;
  56596. /**
  56597. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56598. * @param scene defines the current scene where to apply this optimization
  56599. * @param optimizer defines the current optimizer
  56600. * @returns true if everything that can be done was applied
  56601. */
  56602. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56603. }
  56604. /**
  56605. * Defines an optimization used to turn render targets off
  56606. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56607. */
  56608. export class RenderTargetsOptimization extends SceneOptimization {
  56609. /**
  56610. * Gets a string describing the action executed by the current optimization
  56611. * @return description string
  56612. */
  56613. getDescription(): string;
  56614. /**
  56615. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56616. * @param scene defines the current scene where to apply this optimization
  56617. * @param optimizer defines the current optimizer
  56618. * @returns true if everything that can be done was applied
  56619. */
  56620. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56621. }
  56622. /**
  56623. * Defines an optimization used to merge meshes with compatible materials
  56624. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56625. */
  56626. export class MergeMeshesOptimization extends SceneOptimization {
  56627. private static _UpdateSelectionTree;
  56628. /**
  56629. * Gets or sets a boolean which defines if optimization octree has to be updated
  56630. */
  56631. /**
  56632. * Gets or sets a boolean which defines if optimization octree has to be updated
  56633. */
  56634. static UpdateSelectionTree: boolean;
  56635. /**
  56636. * Gets a string describing the action executed by the current optimization
  56637. * @return description string
  56638. */
  56639. getDescription(): string;
  56640. private _canBeMerged;
  56641. /**
  56642. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56643. * @param scene defines the current scene where to apply this optimization
  56644. * @param optimizer defines the current optimizer
  56645. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  56646. * @returns true if everything that can be done was applied
  56647. */
  56648. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  56649. }
  56650. /**
  56651. * Defines a list of options used by SceneOptimizer
  56652. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56653. */
  56654. export class SceneOptimizerOptions {
  56655. /**
  56656. * Defines the target frame rate to reach (60 by default)
  56657. */
  56658. targetFrameRate: number;
  56659. /**
  56660. * Defines the interval between two checkes (2000ms by default)
  56661. */
  56662. trackerDuration: number;
  56663. /**
  56664. * Gets the list of optimizations to apply
  56665. */
  56666. optimizations: SceneOptimization[];
  56667. /**
  56668. * Creates a new list of options used by SceneOptimizer
  56669. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  56670. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  56671. */
  56672. constructor(
  56673. /**
  56674. * Defines the target frame rate to reach (60 by default)
  56675. */
  56676. targetFrameRate?: number,
  56677. /**
  56678. * Defines the interval between two checkes (2000ms by default)
  56679. */
  56680. trackerDuration?: number);
  56681. /**
  56682. * Add a new optimization
  56683. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  56684. * @returns the current SceneOptimizerOptions
  56685. */
  56686. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  56687. /**
  56688. * Add a new custom optimization
  56689. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  56690. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  56691. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56692. * @returns the current SceneOptimizerOptions
  56693. */
  56694. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  56695. /**
  56696. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  56697. * @param targetFrameRate defines the target frame rate (60 by default)
  56698. * @returns a SceneOptimizerOptions object
  56699. */
  56700. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56701. /**
  56702. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  56703. * @param targetFrameRate defines the target frame rate (60 by default)
  56704. * @returns a SceneOptimizerOptions object
  56705. */
  56706. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56707. /**
  56708. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56709. * @param targetFrameRate defines the target frame rate (60 by default)
  56710. * @returns a SceneOptimizerOptions object
  56711. */
  56712. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56713. }
  56714. /**
  56715. * Class used to run optimizations in order to reach a target frame rate
  56716. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56717. */
  56718. export class SceneOptimizer implements IDisposable {
  56719. private _isRunning;
  56720. private _options;
  56721. private _scene;
  56722. private _currentPriorityLevel;
  56723. private _targetFrameRate;
  56724. private _trackerDuration;
  56725. private _currentFrameRate;
  56726. private _sceneDisposeObserver;
  56727. private _improvementMode;
  56728. /**
  56729. * Defines an observable called when the optimizer reaches the target frame rate
  56730. */
  56731. onSuccessObservable: Observable<SceneOptimizer>;
  56732. /**
  56733. * Defines an observable called when the optimizer enables an optimization
  56734. */
  56735. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  56736. /**
  56737. * Defines an observable called when the optimizer is not able to reach the target frame rate
  56738. */
  56739. onFailureObservable: Observable<SceneOptimizer>;
  56740. /**
  56741. * Gets a boolean indicating if the optimizer is in improvement mode
  56742. */
  56743. readonly isInImprovementMode: boolean;
  56744. /**
  56745. * Gets the current priority level (0 at start)
  56746. */
  56747. readonly currentPriorityLevel: number;
  56748. /**
  56749. * Gets the current frame rate checked by the SceneOptimizer
  56750. */
  56751. readonly currentFrameRate: number;
  56752. /**
  56753. * Gets or sets the current target frame rate (60 by default)
  56754. */
  56755. /**
  56756. * Gets or sets the current target frame rate (60 by default)
  56757. */
  56758. targetFrameRate: number;
  56759. /**
  56760. * Gets or sets the current interval between two checks (every 2000ms by default)
  56761. */
  56762. /**
  56763. * Gets or sets the current interval between two checks (every 2000ms by default)
  56764. */
  56765. trackerDuration: number;
  56766. /**
  56767. * Gets the list of active optimizations
  56768. */
  56769. readonly optimizations: SceneOptimization[];
  56770. /**
  56771. * Creates a new SceneOptimizer
  56772. * @param scene defines the scene to work on
  56773. * @param options defines the options to use with the SceneOptimizer
  56774. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  56775. * @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)
  56776. */
  56777. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  56778. /**
  56779. * Stops the current optimizer
  56780. */
  56781. stop(): void;
  56782. /**
  56783. * Reset the optimizer to initial step (current priority level = 0)
  56784. */
  56785. reset(): void;
  56786. /**
  56787. * Start the optimizer. By default it will try to reach a specific framerate
  56788. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  56789. */
  56790. start(): void;
  56791. private _checkCurrentState;
  56792. /**
  56793. * Release all resources
  56794. */
  56795. dispose(): void;
  56796. /**
  56797. * Helper function to create a SceneOptimizer with one single line of code
  56798. * @param scene defines the scene to work on
  56799. * @param options defines the options to use with the SceneOptimizer
  56800. * @param onSuccess defines a callback to call on success
  56801. * @param onFailure defines a callback to call on failure
  56802. * @returns the new SceneOptimizer object
  56803. */
  56804. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  56805. }
  56806. }
  56807. declare module "babylonjs/Misc/sceneSerializer" {
  56808. import { Scene } from "babylonjs/scene";
  56809. /**
  56810. * Class used to serialize a scene into a string
  56811. */
  56812. export class SceneSerializer {
  56813. /**
  56814. * Clear cache used by a previous serialization
  56815. */
  56816. static ClearCache(): void;
  56817. /**
  56818. * Serialize a scene into a JSON compatible object
  56819. * @param scene defines the scene to serialize
  56820. * @returns a JSON compatible object
  56821. */
  56822. static Serialize(scene: Scene): any;
  56823. /**
  56824. * Serialize a mesh into a JSON compatible object
  56825. * @param toSerialize defines the mesh to serialize
  56826. * @param withParents defines if parents must be serialized as well
  56827. * @param withChildren defines if children must be serialized as well
  56828. * @returns a JSON compatible object
  56829. */
  56830. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  56831. }
  56832. }
  56833. declare module "babylonjs/Misc/videoRecorder" {
  56834. import { Nullable } from "babylonjs/types";
  56835. import { Engine } from "babylonjs/Engines/engine";
  56836. /**
  56837. * This represents the different options avilable for the video capture.
  56838. */
  56839. export interface VideoRecorderOptions {
  56840. /** Defines the mime type of the video */
  56841. mimeType: string;
  56842. /** Defines the video the video should be recorded at */
  56843. fps: number;
  56844. /** Defines the chunk size for the recording data */
  56845. recordChunckSize: number;
  56846. /** The audio tracks to attach to the record */
  56847. audioTracks?: MediaStreamTrack[];
  56848. }
  56849. /**
  56850. * This can helps recording videos from BabylonJS.
  56851. * This is based on the available WebRTC functionalities of the browser.
  56852. *
  56853. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  56854. */
  56855. export class VideoRecorder {
  56856. private static readonly _defaultOptions;
  56857. /**
  56858. * Returns wehther or not the VideoRecorder is available in your browser.
  56859. * @param engine Defines the Babylon Engine to check the support for
  56860. * @returns true if supported otherwise false
  56861. */
  56862. static IsSupported(engine: Engine): boolean;
  56863. private readonly _options;
  56864. private _canvas;
  56865. private _mediaRecorder;
  56866. private _recordedChunks;
  56867. private _fileName;
  56868. private _resolve;
  56869. private _reject;
  56870. /**
  56871. * True wether a recording is already in progress.
  56872. */
  56873. readonly isRecording: boolean;
  56874. /**
  56875. * Create a new VideoCapture object which can help converting what you see in Babylon to
  56876. * a video file.
  56877. * @param engine Defines the BabylonJS Engine you wish to record
  56878. * @param options Defines options that can be used to customized the capture
  56879. */
  56880. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  56881. /**
  56882. * Stops the current recording before the default capture timeout passed in the startRecording
  56883. * functions.
  56884. */
  56885. stopRecording(): void;
  56886. /**
  56887. * Starts recording the canvas for a max duration specified in parameters.
  56888. * @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.
  56889. * @param maxDuration Defines the maximum recording time in seconds.
  56890. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  56891. * @return a promise callback at the end of the recording with the video data in Blob.
  56892. */
  56893. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  56894. /**
  56895. * Releases internal resources used during the recording.
  56896. */
  56897. dispose(): void;
  56898. private _handleDataAvailable;
  56899. private _handleError;
  56900. private _handleStop;
  56901. }
  56902. }
  56903. declare module "babylonjs/Misc/workerPool" {
  56904. import { IDisposable } from "babylonjs/scene";
  56905. /**
  56906. * Helper class to push actions to a pool of workers.
  56907. */
  56908. export class WorkerPool implements IDisposable {
  56909. private _workerInfos;
  56910. private _pendingActions;
  56911. /**
  56912. * Constructor
  56913. * @param workers Array of workers to use for actions
  56914. */
  56915. constructor(workers: Array<Worker>);
  56916. /**
  56917. * Terminates all workers and clears any pending actions.
  56918. */
  56919. dispose(): void;
  56920. /**
  56921. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56922. * pended until a worker has completed its action.
  56923. * @param action The action to perform. Call onComplete when the action is complete.
  56924. */
  56925. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56926. private _execute;
  56927. }
  56928. }
  56929. declare module "babylonjs/Misc/screenshotTools" {
  56930. import { Camera } from "babylonjs/Cameras/camera";
  56931. import { Engine } from "babylonjs/Engines/engine";
  56932. /**
  56933. * Class containing a set of static utilities functions for screenshots
  56934. */
  56935. export class ScreenshotTools {
  56936. /**
  56937. * Captures a screenshot of the current rendering
  56938. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56939. * @param engine defines the rendering engine
  56940. * @param camera defines the source camera
  56941. * @param size This parameter can be set to a single number or to an object with the
  56942. * following (optional) properties: precision, width, height. If a single number is passed,
  56943. * it will be used for both width and height. If an object is passed, the screenshot size
  56944. * will be derived from the parameters. The precision property is a multiplier allowing
  56945. * rendering at a higher or lower resolution
  56946. * @param successCallback defines the callback receives a single parameter which contains the
  56947. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56948. * src parameter of an <img> to display it
  56949. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56950. * Check your browser for supported MIME types
  56951. */
  56952. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56953. /**
  56954. * Generates an image screenshot from the specified camera.
  56955. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56956. * @param engine The engine to use for rendering
  56957. * @param camera The camera to use for rendering
  56958. * @param size This parameter can be set to a single number or to an object with the
  56959. * following (optional) properties: precision, width, height. If a single number is passed,
  56960. * it will be used for both width and height. If an object is passed, the screenshot size
  56961. * will be derived from the parameters. The precision property is a multiplier allowing
  56962. * rendering at a higher or lower resolution
  56963. * @param successCallback The callback receives a single parameter which contains the
  56964. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56965. * src parameter of an <img> to display it
  56966. * @param mimeType The MIME type of the screenshot image (default: image/png).
  56967. * Check your browser for supported MIME types
  56968. * @param samples Texture samples (default: 1)
  56969. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  56970. * @param fileName A name for for the downloaded file.
  56971. */
  56972. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  56973. }
  56974. }
  56975. declare module "babylonjs/Misc/index" {
  56976. export * from "babylonjs/Misc/andOrNotEvaluator";
  56977. export * from "babylonjs/Misc/assetsManager";
  56978. export * from "babylonjs/Misc/dds";
  56979. export * from "babylonjs/Misc/decorators";
  56980. export * from "babylonjs/Misc/deferred";
  56981. export * from "babylonjs/Misc/environmentTextureTools";
  56982. export * from "babylonjs/Misc/filesInput";
  56983. export * from "babylonjs/Misc/HighDynamicRange/index";
  56984. export * from "babylonjs/Misc/khronosTextureContainer";
  56985. export * from "babylonjs/Misc/observable";
  56986. export * from "babylonjs/Misc/performanceMonitor";
  56987. export * from "babylonjs/Misc/promise";
  56988. export * from "babylonjs/Misc/sceneOptimizer";
  56989. export * from "babylonjs/Misc/sceneSerializer";
  56990. export * from "babylonjs/Misc/smartArray";
  56991. export * from "babylonjs/Misc/stringDictionary";
  56992. export * from "babylonjs/Misc/tags";
  56993. export * from "babylonjs/Misc/textureTools";
  56994. export * from "babylonjs/Misc/tga";
  56995. export * from "babylonjs/Misc/tools";
  56996. export * from "babylonjs/Misc/videoRecorder";
  56997. export * from "babylonjs/Misc/virtualJoystick";
  56998. export * from "babylonjs/Misc/workerPool";
  56999. export * from "babylonjs/Misc/logger";
  57000. export * from "babylonjs/Misc/typeStore";
  57001. export * from "babylonjs/Misc/filesInputStore";
  57002. export * from "babylonjs/Misc/deepCopier";
  57003. export * from "babylonjs/Misc/pivotTools";
  57004. export * from "babylonjs/Misc/precisionDate";
  57005. export * from "babylonjs/Misc/screenshotTools";
  57006. export * from "babylonjs/Misc/typeStore";
  57007. }
  57008. declare module "babylonjs/index" {
  57009. export * from "babylonjs/abstractScene";
  57010. export * from "babylonjs/Actions/index";
  57011. export * from "babylonjs/Animations/index";
  57012. export * from "babylonjs/assetContainer";
  57013. export * from "babylonjs/Audio/index";
  57014. export * from "babylonjs/Behaviors/index";
  57015. export * from "babylonjs/Bones/index";
  57016. export * from "babylonjs/Cameras/index";
  57017. export * from "babylonjs/Collisions/index";
  57018. export * from "babylonjs/Culling/index";
  57019. export * from "babylonjs/Debug/index";
  57020. export * from "babylonjs/Engines/index";
  57021. export * from "babylonjs/Events/index";
  57022. export * from "babylonjs/Gamepads/index";
  57023. export * from "babylonjs/Gizmos/index";
  57024. export * from "babylonjs/Helpers/index";
  57025. export * from "babylonjs/Instrumentation/index";
  57026. export * from "babylonjs/Layers/index";
  57027. export * from "babylonjs/LensFlares/index";
  57028. export * from "babylonjs/Lights/index";
  57029. export * from "babylonjs/Loading/index";
  57030. export * from "babylonjs/Materials/index";
  57031. export * from "babylonjs/Maths/index";
  57032. export * from "babylonjs/Meshes/index";
  57033. export * from "babylonjs/Morph/index";
  57034. export * from "babylonjs/node";
  57035. export * from "babylonjs/Offline/index";
  57036. export * from "babylonjs/Particles/index";
  57037. export * from "babylonjs/Physics/index";
  57038. export * from "babylonjs/PostProcesses/index";
  57039. export * from "babylonjs/Probes/index";
  57040. export * from "babylonjs/Rendering/index";
  57041. export * from "babylonjs/scene";
  57042. export * from "babylonjs/sceneComponent";
  57043. export * from "babylonjs/Sprites/index";
  57044. export * from "babylonjs/States/index";
  57045. export * from "babylonjs/Misc/index";
  57046. export * from "babylonjs/types";
  57047. }
  57048. declare module "babylonjs/Animations/pathCursor" {
  57049. import { Path2, Vector3 } from "babylonjs/Maths/math";
  57050. /**
  57051. * A cursor which tracks a point on a path
  57052. */
  57053. export class PathCursor {
  57054. private path;
  57055. /**
  57056. * Stores path cursor callbacks for when an onchange event is triggered
  57057. */
  57058. private _onchange;
  57059. /**
  57060. * The value of the path cursor
  57061. */
  57062. value: number;
  57063. /**
  57064. * The animation array of the path cursor
  57065. */
  57066. animations: Animation[];
  57067. /**
  57068. * Initializes the path cursor
  57069. * @param path The path to track
  57070. */
  57071. constructor(path: Path2);
  57072. /**
  57073. * Gets the cursor point on the path
  57074. * @returns A point on the path cursor at the cursor location
  57075. */
  57076. getPoint(): Vector3;
  57077. /**
  57078. * Moves the cursor ahead by the step amount
  57079. * @param step The amount to move the cursor forward
  57080. * @returns This path cursor
  57081. */
  57082. moveAhead(step?: number): PathCursor;
  57083. /**
  57084. * Moves the cursor behind by the step amount
  57085. * @param step The amount to move the cursor back
  57086. * @returns This path cursor
  57087. */
  57088. moveBack(step?: number): PathCursor;
  57089. /**
  57090. * Moves the cursor by the step amount
  57091. * If the step amount is greater than one, an exception is thrown
  57092. * @param step The amount to move the cursor
  57093. * @returns This path cursor
  57094. */
  57095. move(step: number): PathCursor;
  57096. /**
  57097. * Ensures that the value is limited between zero and one
  57098. * @returns This path cursor
  57099. */
  57100. private ensureLimits;
  57101. /**
  57102. * Runs onchange callbacks on change (used by the animation engine)
  57103. * @returns This path cursor
  57104. */
  57105. private raiseOnChange;
  57106. /**
  57107. * Executes a function on change
  57108. * @param f A path cursor onchange callback
  57109. * @returns This path cursor
  57110. */
  57111. onchange(f: (cursor: PathCursor) => void): PathCursor;
  57112. }
  57113. }
  57114. declare module "babylonjs/Legacy/legacy" {
  57115. import * as Babylon from "babylonjs/index";
  57116. export * from "babylonjs/index";
  57117. }
  57118. declare module "babylonjs/Shaders/blur.fragment" {
  57119. /** @hidden */
  57120. export var blurPixelShader: {
  57121. name: string;
  57122. shader: string;
  57123. };
  57124. }
  57125. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  57126. /** @hidden */
  57127. export var bones300Declaration: {
  57128. name: string;
  57129. shader: string;
  57130. };
  57131. }
  57132. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  57133. /** @hidden */
  57134. export var instances300Declaration: {
  57135. name: string;
  57136. shader: string;
  57137. };
  57138. }
  57139. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  57140. /** @hidden */
  57141. export var pointCloudVertexDeclaration: {
  57142. name: string;
  57143. shader: string;
  57144. };
  57145. }
  57146. // Mixins
  57147. interface Window {
  57148. mozIndexedDB: IDBFactory;
  57149. webkitIndexedDB: IDBFactory;
  57150. msIndexedDB: IDBFactory;
  57151. webkitURL: typeof URL;
  57152. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  57153. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  57154. WebGLRenderingContext: WebGLRenderingContext;
  57155. MSGesture: MSGesture;
  57156. CANNON: any;
  57157. AudioContext: AudioContext;
  57158. webkitAudioContext: AudioContext;
  57159. PointerEvent: any;
  57160. Math: Math;
  57161. Uint8Array: Uint8ArrayConstructor;
  57162. Float32Array: Float32ArrayConstructor;
  57163. mozURL: typeof URL;
  57164. msURL: typeof URL;
  57165. VRFrameData: any; // WebVR, from specs 1.1
  57166. DracoDecoderModule: any;
  57167. setImmediate(handler: (...args: any[]) => void): number;
  57168. }
  57169. interface HTMLCanvasElement {
  57170. requestPointerLock(): void;
  57171. msRequestPointerLock?(): void;
  57172. mozRequestPointerLock?(): void;
  57173. webkitRequestPointerLock?(): void;
  57174. /** Track wether a record is in progress */
  57175. isRecording: boolean;
  57176. /** Capture Stream method defined by some browsers */
  57177. captureStream(fps?: number): MediaStream;
  57178. }
  57179. interface CanvasRenderingContext2D {
  57180. msImageSmoothingEnabled: boolean;
  57181. }
  57182. interface MouseEvent {
  57183. mozMovementX: number;
  57184. mozMovementY: number;
  57185. webkitMovementX: number;
  57186. webkitMovementY: number;
  57187. msMovementX: number;
  57188. msMovementY: number;
  57189. }
  57190. interface Navigator {
  57191. mozGetVRDevices: (any: any) => any;
  57192. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57193. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57194. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57195. webkitGetGamepads(): Gamepad[];
  57196. msGetGamepads(): Gamepad[];
  57197. webkitGamepads(): Gamepad[];
  57198. }
  57199. interface HTMLVideoElement {
  57200. mozSrcObject: any;
  57201. }
  57202. interface Math {
  57203. fround(x: number): number;
  57204. imul(a: number, b: number): number;
  57205. }
  57206. interface WebGLProgram {
  57207. context?: WebGLRenderingContext;
  57208. vertexShader?: WebGLShader;
  57209. fragmentShader?: WebGLShader;
  57210. isParallelCompiled: boolean;
  57211. onCompiled?: () => void;
  57212. }
  57213. interface WebGLRenderingContext {
  57214. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  57215. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  57216. vertexAttribDivisor(index: number, divisor: number): void;
  57217. createVertexArray(): any;
  57218. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  57219. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  57220. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  57221. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  57222. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  57223. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  57224. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  57225. // Queries
  57226. createQuery(): WebGLQuery;
  57227. deleteQuery(query: WebGLQuery): void;
  57228. beginQuery(target: number, query: WebGLQuery): void;
  57229. endQuery(target: number): void;
  57230. getQueryParameter(query: WebGLQuery, pname: number): any;
  57231. getQuery(target: number, pname: number): any;
  57232. MAX_SAMPLES: number;
  57233. RGBA8: number;
  57234. READ_FRAMEBUFFER: number;
  57235. DRAW_FRAMEBUFFER: number;
  57236. UNIFORM_BUFFER: number;
  57237. HALF_FLOAT_OES: number;
  57238. RGBA16F: number;
  57239. RGBA32F: number;
  57240. R32F: number;
  57241. RG32F: number;
  57242. RGB32F: number;
  57243. R16F: number;
  57244. RG16F: number;
  57245. RGB16F: number;
  57246. RED: number;
  57247. RG: number;
  57248. R8: number;
  57249. RG8: number;
  57250. UNSIGNED_INT_24_8: number;
  57251. DEPTH24_STENCIL8: number;
  57252. /* Multiple Render Targets */
  57253. drawBuffers(buffers: number[]): void;
  57254. readBuffer(src: number): void;
  57255. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  57256. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  57257. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  57258. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  57259. // Occlusion Query
  57260. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  57261. ANY_SAMPLES_PASSED: number;
  57262. QUERY_RESULT_AVAILABLE: number;
  57263. QUERY_RESULT: number;
  57264. }
  57265. interface WebGLBuffer {
  57266. references: number;
  57267. capacity: number;
  57268. is32Bits: boolean;
  57269. }
  57270. interface WebGLProgram {
  57271. transformFeedback?: WebGLTransformFeedback | null;
  57272. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  57273. }
  57274. interface EXT_disjoint_timer_query {
  57275. QUERY_COUNTER_BITS_EXT: number;
  57276. TIME_ELAPSED_EXT: number;
  57277. TIMESTAMP_EXT: number;
  57278. GPU_DISJOINT_EXT: number;
  57279. QUERY_RESULT_EXT: number;
  57280. QUERY_RESULT_AVAILABLE_EXT: number;
  57281. queryCounterEXT(query: WebGLQuery, target: number): void;
  57282. createQueryEXT(): WebGLQuery;
  57283. beginQueryEXT(target: number, query: WebGLQuery): void;
  57284. endQueryEXT(target: number): void;
  57285. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  57286. deleteQueryEXT(query: WebGLQuery): void;
  57287. }
  57288. interface WebGLUniformLocation {
  57289. _currentState: any;
  57290. }
  57291. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  57292. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  57293. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  57294. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57295. interface WebGLRenderingContext {
  57296. readonly RASTERIZER_DISCARD: number;
  57297. readonly DEPTH_COMPONENT24: number;
  57298. readonly TEXTURE_3D: number;
  57299. readonly TEXTURE_2D_ARRAY: number;
  57300. readonly TEXTURE_COMPARE_FUNC: number;
  57301. readonly TEXTURE_COMPARE_MODE: number;
  57302. readonly COMPARE_REF_TO_TEXTURE: number;
  57303. readonly TEXTURE_WRAP_R: number;
  57304. readonly HALF_FLOAT: number;
  57305. readonly RGB8: number;
  57306. readonly RED_INTEGER: number;
  57307. readonly RG_INTEGER: number;
  57308. readonly RGB_INTEGER: number;
  57309. readonly RGBA_INTEGER: number;
  57310. readonly R8_SNORM: number;
  57311. readonly RG8_SNORM: number;
  57312. readonly RGB8_SNORM: number;
  57313. readonly RGBA8_SNORM: number;
  57314. readonly R8I: number;
  57315. readonly RG8I: number;
  57316. readonly RGB8I: number;
  57317. readonly RGBA8I: number;
  57318. readonly R8UI: number;
  57319. readonly RG8UI: number;
  57320. readonly RGB8UI: number;
  57321. readonly RGBA8UI: number;
  57322. readonly R16I: number;
  57323. readonly RG16I: number;
  57324. readonly RGB16I: number;
  57325. readonly RGBA16I: number;
  57326. readonly R16UI: number;
  57327. readonly RG16UI: number;
  57328. readonly RGB16UI: number;
  57329. readonly RGBA16UI: number;
  57330. readonly R32I: number;
  57331. readonly RG32I: number;
  57332. readonly RGB32I: number;
  57333. readonly RGBA32I: number;
  57334. readonly R32UI: number;
  57335. readonly RG32UI: number;
  57336. readonly RGB32UI: number;
  57337. readonly RGBA32UI: number;
  57338. readonly RGB10_A2UI: number;
  57339. readonly R11F_G11F_B10F: number;
  57340. readonly RGB9_E5: number;
  57341. readonly RGB10_A2: number;
  57342. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  57343. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  57344. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  57345. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  57346. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  57347. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  57348. 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;
  57349. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  57350. readonly TRANSFORM_FEEDBACK: number;
  57351. readonly INTERLEAVED_ATTRIBS: number;
  57352. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  57353. createTransformFeedback(): WebGLTransformFeedback;
  57354. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  57355. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  57356. beginTransformFeedback(primitiveMode: number): void;
  57357. endTransformFeedback(): void;
  57358. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  57359. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57360. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57361. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57362. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  57363. }
  57364. interface ImageBitmap {
  57365. readonly width: number;
  57366. readonly height: number;
  57367. close(): void;
  57368. }
  57369. interface WebGLQuery extends WebGLObject {
  57370. }
  57371. declare var WebGLQuery: {
  57372. prototype: WebGLQuery;
  57373. new(): WebGLQuery;
  57374. };
  57375. interface WebGLSampler extends WebGLObject {
  57376. }
  57377. declare var WebGLSampler: {
  57378. prototype: WebGLSampler;
  57379. new(): WebGLSampler;
  57380. };
  57381. interface WebGLSync extends WebGLObject {
  57382. }
  57383. declare var WebGLSync: {
  57384. prototype: WebGLSync;
  57385. new(): WebGLSync;
  57386. };
  57387. interface WebGLTransformFeedback extends WebGLObject {
  57388. }
  57389. declare var WebGLTransformFeedback: {
  57390. prototype: WebGLTransformFeedback;
  57391. new(): WebGLTransformFeedback;
  57392. };
  57393. interface WebGLVertexArrayObject extends WebGLObject {
  57394. }
  57395. declare var WebGLVertexArrayObject: {
  57396. prototype: WebGLVertexArrayObject;
  57397. new(): WebGLVertexArrayObject;
  57398. };
  57399. // Type definitions for WebVR API
  57400. // Project: https://w3c.github.io/webvr/
  57401. // Definitions by: six a <https://github.com/lostfictions>
  57402. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57403. interface VRDisplay extends EventTarget {
  57404. /**
  57405. * Dictionary of capabilities describing the VRDisplay.
  57406. */
  57407. readonly capabilities: VRDisplayCapabilities;
  57408. /**
  57409. * z-depth defining the far plane of the eye view frustum
  57410. * enables mapping of values in the render target depth
  57411. * attachment to scene coordinates. Initially set to 10000.0.
  57412. */
  57413. depthFar: number;
  57414. /**
  57415. * z-depth defining the near plane of the eye view frustum
  57416. * enables mapping of values in the render target depth
  57417. * attachment to scene coordinates. Initially set to 0.01.
  57418. */
  57419. depthNear: number;
  57420. /**
  57421. * An identifier for this distinct VRDisplay. Used as an
  57422. * association point in the Gamepad API.
  57423. */
  57424. readonly displayId: number;
  57425. /**
  57426. * A display name, a user-readable name identifying it.
  57427. */
  57428. readonly displayName: string;
  57429. readonly isConnected: boolean;
  57430. readonly isPresenting: boolean;
  57431. /**
  57432. * If this VRDisplay supports room-scale experiences, the optional
  57433. * stage attribute contains details on the room-scale parameters.
  57434. */
  57435. readonly stageParameters: VRStageParameters | null;
  57436. /**
  57437. * Passing the value returned by `requestAnimationFrame` to
  57438. * `cancelAnimationFrame` will unregister the callback.
  57439. * @param handle Define the hanle of the request to cancel
  57440. */
  57441. cancelAnimationFrame(handle: number): void;
  57442. /**
  57443. * Stops presenting to the VRDisplay.
  57444. * @returns a promise to know when it stopped
  57445. */
  57446. exitPresent(): Promise<void>;
  57447. /**
  57448. * Return the current VREyeParameters for the given eye.
  57449. * @param whichEye Define the eye we want the parameter for
  57450. * @returns the eye parameters
  57451. */
  57452. getEyeParameters(whichEye: string): VREyeParameters;
  57453. /**
  57454. * Populates the passed VRFrameData with the information required to render
  57455. * the current frame.
  57456. * @param frameData Define the data structure to populate
  57457. * @returns true if ok otherwise false
  57458. */
  57459. getFrameData(frameData: VRFrameData): boolean;
  57460. /**
  57461. * Get the layers currently being presented.
  57462. * @returns the list of VR layers
  57463. */
  57464. getLayers(): VRLayer[];
  57465. /**
  57466. * Return a VRPose containing the future predicted pose of the VRDisplay
  57467. * when the current frame will be presented. The value returned will not
  57468. * change until JavaScript has returned control to the browser.
  57469. *
  57470. * The VRPose will contain the position, orientation, velocity,
  57471. * and acceleration of each of these properties.
  57472. * @returns the pose object
  57473. */
  57474. getPose(): VRPose;
  57475. /**
  57476. * Return the current instantaneous pose of the VRDisplay, with no
  57477. * prediction applied.
  57478. * @returns the current instantaneous pose
  57479. */
  57480. getImmediatePose(): VRPose;
  57481. /**
  57482. * The callback passed to `requestAnimationFrame` will be called
  57483. * any time a new frame should be rendered. When the VRDisplay is
  57484. * presenting the callback will be called at the native refresh
  57485. * rate of the HMD. When not presenting this function acts
  57486. * identically to how window.requestAnimationFrame acts. Content should
  57487. * make no assumptions of frame rate or vsync behavior as the HMD runs
  57488. * asynchronously from other displays and at differing refresh rates.
  57489. * @param callback Define the eaction to run next frame
  57490. * @returns the request handle it
  57491. */
  57492. requestAnimationFrame(callback: FrameRequestCallback): number;
  57493. /**
  57494. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  57495. * Repeat calls while already presenting will update the VRLayers being displayed.
  57496. * @param layers Define the list of layer to present
  57497. * @returns a promise to know when the request has been fulfilled
  57498. */
  57499. requestPresent(layers: VRLayer[]): Promise<void>;
  57500. /**
  57501. * Reset the pose for this display, treating its current position and
  57502. * orientation as the "origin/zero" values. VRPose.position,
  57503. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  57504. * updated when calling resetPose(). This should be called in only
  57505. * sitting-space experiences.
  57506. */
  57507. resetPose(): void;
  57508. /**
  57509. * The VRLayer provided to the VRDisplay will be captured and presented
  57510. * in the HMD. Calling this function has the same effect on the source
  57511. * canvas as any other operation that uses its source image, and canvases
  57512. * created without preserveDrawingBuffer set to true will be cleared.
  57513. * @param pose Define the pose to submit
  57514. */
  57515. submitFrame(pose?: VRPose): void;
  57516. }
  57517. declare var VRDisplay: {
  57518. prototype: VRDisplay;
  57519. new(): VRDisplay;
  57520. };
  57521. interface VRLayer {
  57522. leftBounds?: number[] | Float32Array | null;
  57523. rightBounds?: number[] | Float32Array | null;
  57524. source?: HTMLCanvasElement | null;
  57525. }
  57526. interface VRDisplayCapabilities {
  57527. readonly canPresent: boolean;
  57528. readonly hasExternalDisplay: boolean;
  57529. readonly hasOrientation: boolean;
  57530. readonly hasPosition: boolean;
  57531. readonly maxLayers: number;
  57532. }
  57533. interface VREyeParameters {
  57534. /** @deprecated */
  57535. readonly fieldOfView: VRFieldOfView;
  57536. readonly offset: Float32Array;
  57537. readonly renderHeight: number;
  57538. readonly renderWidth: number;
  57539. }
  57540. interface VRFieldOfView {
  57541. readonly downDegrees: number;
  57542. readonly leftDegrees: number;
  57543. readonly rightDegrees: number;
  57544. readonly upDegrees: number;
  57545. }
  57546. interface VRFrameData {
  57547. readonly leftProjectionMatrix: Float32Array;
  57548. readonly leftViewMatrix: Float32Array;
  57549. readonly pose: VRPose;
  57550. readonly rightProjectionMatrix: Float32Array;
  57551. readonly rightViewMatrix: Float32Array;
  57552. readonly timestamp: number;
  57553. }
  57554. interface VRPose {
  57555. readonly angularAcceleration: Float32Array | null;
  57556. readonly angularVelocity: Float32Array | null;
  57557. readonly linearAcceleration: Float32Array | null;
  57558. readonly linearVelocity: Float32Array | null;
  57559. readonly orientation: Float32Array | null;
  57560. readonly position: Float32Array | null;
  57561. readonly timestamp: number;
  57562. }
  57563. interface VRStageParameters {
  57564. sittingToStandingTransform?: Float32Array;
  57565. sizeX?: number;
  57566. sizeY?: number;
  57567. }
  57568. interface Navigator {
  57569. getVRDisplays(): Promise<VRDisplay[]>;
  57570. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  57571. }
  57572. interface Window {
  57573. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  57574. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  57575. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  57576. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57577. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57578. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  57579. }
  57580. interface Gamepad {
  57581. readonly displayId: number;
  57582. }
  57583. interface XRDevice {
  57584. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  57585. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  57586. }
  57587. interface XRSession {
  57588. getInputSources(): Array<any>;
  57589. baseLayer: XRWebGLLayer;
  57590. requestFrameOfReference(type: string): Promise<void>;
  57591. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  57592. end(): Promise<void>;
  57593. requestAnimationFrame: Function;
  57594. addEventListener: Function;
  57595. }
  57596. interface XRSessionCreationOptions {
  57597. outputContext?: WebGLRenderingContext | null;
  57598. immersive?: boolean;
  57599. environmentIntegration?: boolean;
  57600. }
  57601. interface XRLayer {
  57602. getViewport: Function;
  57603. framebufferWidth: number;
  57604. framebufferHeight: number;
  57605. }
  57606. interface XRView {
  57607. projectionMatrix: Float32Array;
  57608. }
  57609. interface XRFrame {
  57610. getDevicePose: Function;
  57611. getInputPose: Function;
  57612. views: Array<XRView>;
  57613. baseLayer: XRLayer;
  57614. }
  57615. interface XRFrameOfReference {
  57616. }
  57617. interface XRWebGLLayer extends XRLayer {
  57618. framebuffer: WebGLFramebuffer;
  57619. }
  57620. declare var XRWebGLLayer: {
  57621. prototype: XRWebGLLayer;
  57622. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  57623. };
  57624. declare module "babylonjs" {
  57625. export * from "babylonjs/Legacy/legacy";
  57626. }
  57627. declare module BABYLON {
  57628. /** Alias type for value that can be null */
  57629. export type Nullable<T> = T | null;
  57630. /**
  57631. * Alias type for number that are floats
  57632. * @ignorenaming
  57633. */
  57634. export type float = number;
  57635. /**
  57636. * Alias type for number that are doubles.
  57637. * @ignorenaming
  57638. */
  57639. export type double = number;
  57640. /**
  57641. * Alias type for number that are integer
  57642. * @ignorenaming
  57643. */
  57644. export type int = number;
  57645. /** Alias type for number array or Float32Array */
  57646. export type FloatArray = number[] | Float32Array;
  57647. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  57648. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  57649. /**
  57650. * Alias for types that can be used by a Buffer or VertexBuffer.
  57651. */
  57652. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  57653. /**
  57654. * Alias type for primitive types
  57655. * @ignorenaming
  57656. */
  57657. type Primitive = undefined | null | boolean | string | number | Function;
  57658. /**
  57659. * Type modifier to make all the properties of an object Readonly
  57660. */
  57661. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  57662. /**
  57663. * Type modifier to make all the properties of an object Readonly recursively
  57664. */
  57665. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  57666. /** @hidden */
  57667. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  57668. }
  57669. /** @hidden */
  57670. /** @hidden */
  57671. type DeepImmutableObject<T> = {
  57672. readonly [K in keyof T]: DeepImmutable<T[K]>;
  57673. };
  57674. }
  57675. declare module BABYLON {
  57676. /**
  57677. * Class containing a set of static utilities functions for arrays.
  57678. */
  57679. export class ArrayTools {
  57680. /**
  57681. * Returns an array of the given size filled with element built from the given constructor and the paramters
  57682. * @param size the number of element to construct and put in the array
  57683. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  57684. * @returns a new array filled with new objects
  57685. */
  57686. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  57687. }
  57688. }
  57689. declare module BABYLON {
  57690. /**
  57691. * Scalar computation library
  57692. */
  57693. export class Scalar {
  57694. /**
  57695. * Two pi constants convenient for computation.
  57696. */
  57697. static TwoPi: number;
  57698. /**
  57699. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57700. * @param a number
  57701. * @param b number
  57702. * @param epsilon (default = 1.401298E-45)
  57703. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57704. */
  57705. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  57706. /**
  57707. * Returns a string : the upper case translation of the number i to hexadecimal.
  57708. * @param i number
  57709. * @returns the upper case translation of the number i to hexadecimal.
  57710. */
  57711. static ToHex(i: number): string;
  57712. /**
  57713. * Returns -1 if value is negative and +1 is value is positive.
  57714. * @param value the value
  57715. * @returns the value itself if it's equal to zero.
  57716. */
  57717. static Sign(value: number): number;
  57718. /**
  57719. * Returns the value itself if it's between min and max.
  57720. * Returns min if the value is lower than min.
  57721. * Returns max if the value is greater than max.
  57722. * @param value the value to clmap
  57723. * @param min the min value to clamp to (default: 0)
  57724. * @param max the max value to clamp to (default: 1)
  57725. * @returns the clamped value
  57726. */
  57727. static Clamp(value: number, min?: number, max?: number): number;
  57728. /**
  57729. * the log2 of value.
  57730. * @param value the value to compute log2 of
  57731. * @returns the log2 of value.
  57732. */
  57733. static Log2(value: number): number;
  57734. /**
  57735. * Loops the value, so that it is never larger than length and never smaller than 0.
  57736. *
  57737. * This is similar to the modulo operator but it works with floating point numbers.
  57738. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  57739. * With t = 5 and length = 2.5, the result would be 0.0.
  57740. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  57741. * @param value the value
  57742. * @param length the length
  57743. * @returns the looped value
  57744. */
  57745. static Repeat(value: number, length: number): number;
  57746. /**
  57747. * Normalize the value between 0.0 and 1.0 using min and max values
  57748. * @param value value to normalize
  57749. * @param min max to normalize between
  57750. * @param max min to normalize between
  57751. * @returns the normalized value
  57752. */
  57753. static Normalize(value: number, min: number, max: number): number;
  57754. /**
  57755. * Denormalize the value from 0.0 and 1.0 using min and max values
  57756. * @param normalized value to denormalize
  57757. * @param min max to denormalize between
  57758. * @param max min to denormalize between
  57759. * @returns the denormalized value
  57760. */
  57761. static Denormalize(normalized: number, min: number, max: number): number;
  57762. /**
  57763. * Calculates the shortest difference between two given angles given in degrees.
  57764. * @param current current angle in degrees
  57765. * @param target target angle in degrees
  57766. * @returns the delta
  57767. */
  57768. static DeltaAngle(current: number, target: number): number;
  57769. /**
  57770. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  57771. * @param tx value
  57772. * @param length length
  57773. * @returns The returned value will move back and forth between 0 and length
  57774. */
  57775. static PingPong(tx: number, length: number): number;
  57776. /**
  57777. * Interpolates between min and max with smoothing at the limits.
  57778. *
  57779. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  57780. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  57781. * @param from from
  57782. * @param to to
  57783. * @param tx value
  57784. * @returns the smooth stepped value
  57785. */
  57786. static SmoothStep(from: number, to: number, tx: number): number;
  57787. /**
  57788. * Moves a value current towards target.
  57789. *
  57790. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  57791. * Negative values of maxDelta pushes the value away from target.
  57792. * @param current current value
  57793. * @param target target value
  57794. * @param maxDelta max distance to move
  57795. * @returns resulting value
  57796. */
  57797. static MoveTowards(current: number, target: number, maxDelta: number): number;
  57798. /**
  57799. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57800. *
  57801. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  57802. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  57803. * @param current current value
  57804. * @param target target value
  57805. * @param maxDelta max distance to move
  57806. * @returns resulting angle
  57807. */
  57808. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  57809. /**
  57810. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  57811. * @param start start value
  57812. * @param end target value
  57813. * @param amount amount to lerp between
  57814. * @returns the lerped value
  57815. */
  57816. static Lerp(start: number, end: number, amount: number): number;
  57817. /**
  57818. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57819. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  57820. * @param start start value
  57821. * @param end target value
  57822. * @param amount amount to lerp between
  57823. * @returns the lerped value
  57824. */
  57825. static LerpAngle(start: number, end: number, amount: number): number;
  57826. /**
  57827. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  57828. * @param a start value
  57829. * @param b target value
  57830. * @param value value between a and b
  57831. * @returns the inverseLerp value
  57832. */
  57833. static InverseLerp(a: number, b: number, value: number): number;
  57834. /**
  57835. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  57836. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  57837. * @param value1 spline value
  57838. * @param tangent1 spline value
  57839. * @param value2 spline value
  57840. * @param tangent2 spline value
  57841. * @param amount input value
  57842. * @returns hermite result
  57843. */
  57844. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  57845. /**
  57846. * Returns a random float number between and min and max values
  57847. * @param min min value of random
  57848. * @param max max value of random
  57849. * @returns random value
  57850. */
  57851. static RandomRange(min: number, max: number): number;
  57852. /**
  57853. * This function returns percentage of a number in a given range.
  57854. *
  57855. * RangeToPercent(40,20,60) will return 0.5 (50%)
  57856. * RangeToPercent(34,0,100) will return 0.34 (34%)
  57857. * @param number to convert to percentage
  57858. * @param min min range
  57859. * @param max max range
  57860. * @returns the percentage
  57861. */
  57862. static RangeToPercent(number: number, min: number, max: number): number;
  57863. /**
  57864. * This function returns number that corresponds to the percentage in a given range.
  57865. *
  57866. * PercentToRange(0.34,0,100) will return 34.
  57867. * @param percent to convert to number
  57868. * @param min min range
  57869. * @param max max range
  57870. * @returns the number
  57871. */
  57872. static PercentToRange(percent: number, min: number, max: number): number;
  57873. /**
  57874. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  57875. * @param angle The angle to normalize in radian.
  57876. * @return The converted angle.
  57877. */
  57878. static NormalizeRadians(angle: number): number;
  57879. }
  57880. }
  57881. declare module BABYLON {
  57882. /**
  57883. * Constant used to convert a value to gamma space
  57884. * @ignorenaming
  57885. */
  57886. export const ToGammaSpace: number;
  57887. /**
  57888. * Constant used to convert a value to linear space
  57889. * @ignorenaming
  57890. */
  57891. export const ToLinearSpace = 2.2;
  57892. /**
  57893. * Constant used to define the minimal number value in Babylon.js
  57894. * @ignorenaming
  57895. */
  57896. export const Epsilon = 0.001;
  57897. /**
  57898. * Class used to hold a RBG color
  57899. */
  57900. export class Color3 {
  57901. /**
  57902. * Defines the red component (between 0 and 1, default is 0)
  57903. */
  57904. r: number;
  57905. /**
  57906. * Defines the green component (between 0 and 1, default is 0)
  57907. */
  57908. g: number;
  57909. /**
  57910. * Defines the blue component (between 0 and 1, default is 0)
  57911. */
  57912. b: number;
  57913. /**
  57914. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  57915. * @param r defines the red component (between 0 and 1, default is 0)
  57916. * @param g defines the green component (between 0 and 1, default is 0)
  57917. * @param b defines the blue component (between 0 and 1, default is 0)
  57918. */
  57919. constructor(
  57920. /**
  57921. * Defines the red component (between 0 and 1, default is 0)
  57922. */
  57923. r?: number,
  57924. /**
  57925. * Defines the green component (between 0 and 1, default is 0)
  57926. */
  57927. g?: number,
  57928. /**
  57929. * Defines the blue component (between 0 and 1, default is 0)
  57930. */
  57931. b?: number);
  57932. /**
  57933. * Creates a string with the Color3 current values
  57934. * @returns the string representation of the Color3 object
  57935. */
  57936. toString(): string;
  57937. /**
  57938. * Returns the string "Color3"
  57939. * @returns "Color3"
  57940. */
  57941. getClassName(): string;
  57942. /**
  57943. * Compute the Color3 hash code
  57944. * @returns an unique number that can be used to hash Color3 objects
  57945. */
  57946. getHashCode(): number;
  57947. /**
  57948. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  57949. * @param array defines the array where to store the r,g,b components
  57950. * @param index defines an optional index in the target array to define where to start storing values
  57951. * @returns the current Color3 object
  57952. */
  57953. toArray(array: FloatArray, index?: number): Color3;
  57954. /**
  57955. * Returns a new Color4 object from the current Color3 and the given alpha
  57956. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  57957. * @returns a new Color4 object
  57958. */
  57959. toColor4(alpha?: number): Color4;
  57960. /**
  57961. * Returns a new array populated with 3 numeric elements : red, green and blue values
  57962. * @returns the new array
  57963. */
  57964. asArray(): number[];
  57965. /**
  57966. * Returns the luminance value
  57967. * @returns a float value
  57968. */
  57969. toLuminance(): number;
  57970. /**
  57971. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  57972. * @param otherColor defines the second operand
  57973. * @returns the new Color3 object
  57974. */
  57975. multiply(otherColor: DeepImmutable<Color3>): Color3;
  57976. /**
  57977. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  57978. * @param otherColor defines the second operand
  57979. * @param result defines the Color3 object where to store the result
  57980. * @returns the current Color3
  57981. */
  57982. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57983. /**
  57984. * Determines equality between Color3 objects
  57985. * @param otherColor defines the second operand
  57986. * @returns true if the rgb values are equal to the given ones
  57987. */
  57988. equals(otherColor: DeepImmutable<Color3>): boolean;
  57989. /**
  57990. * Determines equality between the current Color3 object and a set of r,b,g values
  57991. * @param r defines the red component to check
  57992. * @param g defines the green component to check
  57993. * @param b defines the blue component to check
  57994. * @returns true if the rgb values are equal to the given ones
  57995. */
  57996. equalsFloats(r: number, g: number, b: number): boolean;
  57997. /**
  57998. * Multiplies in place each rgb value by scale
  57999. * @param scale defines the scaling factor
  58000. * @returns the updated Color3
  58001. */
  58002. scale(scale: number): Color3;
  58003. /**
  58004. * Multiplies the rgb values by scale and stores the result into "result"
  58005. * @param scale defines the scaling factor
  58006. * @param result defines the Color3 object where to store the result
  58007. * @returns the unmodified current Color3
  58008. */
  58009. scaleToRef(scale: number, result: Color3): Color3;
  58010. /**
  58011. * Scale the current Color3 values by a factor and add the result to a given Color3
  58012. * @param scale defines the scale factor
  58013. * @param result defines color to store the result into
  58014. * @returns the unmodified current Color3
  58015. */
  58016. scaleAndAddToRef(scale: number, result: Color3): Color3;
  58017. /**
  58018. * Clamps the rgb values by the min and max values and stores the result into "result"
  58019. * @param min defines minimum clamping value (default is 0)
  58020. * @param max defines maximum clamping value (default is 1)
  58021. * @param result defines color to store the result into
  58022. * @returns the original Color3
  58023. */
  58024. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  58025. /**
  58026. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  58027. * @param otherColor defines the second operand
  58028. * @returns the new Color3
  58029. */
  58030. add(otherColor: DeepImmutable<Color3>): Color3;
  58031. /**
  58032. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  58033. * @param otherColor defines the second operand
  58034. * @param result defines Color3 object to store the result into
  58035. * @returns the unmodified current Color3
  58036. */
  58037. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58038. /**
  58039. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  58040. * @param otherColor defines the second operand
  58041. * @returns the new Color3
  58042. */
  58043. subtract(otherColor: DeepImmutable<Color3>): Color3;
  58044. /**
  58045. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  58046. * @param otherColor defines the second operand
  58047. * @param result defines Color3 object to store the result into
  58048. * @returns the unmodified current Color3
  58049. */
  58050. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58051. /**
  58052. * Copy the current object
  58053. * @returns a new Color3 copied the current one
  58054. */
  58055. clone(): Color3;
  58056. /**
  58057. * Copies the rgb values from the source in the current Color3
  58058. * @param source defines the source Color3 object
  58059. * @returns the updated Color3 object
  58060. */
  58061. copyFrom(source: DeepImmutable<Color3>): Color3;
  58062. /**
  58063. * Updates the Color3 rgb values from the given floats
  58064. * @param r defines the red component to read from
  58065. * @param g defines the green component to read from
  58066. * @param b defines the blue component to read from
  58067. * @returns the current Color3 object
  58068. */
  58069. copyFromFloats(r: number, g: number, b: number): Color3;
  58070. /**
  58071. * Updates the Color3 rgb values from the given floats
  58072. * @param r defines the red component to read from
  58073. * @param g defines the green component to read from
  58074. * @param b defines the blue component to read from
  58075. * @returns the current Color3 object
  58076. */
  58077. set(r: number, g: number, b: number): Color3;
  58078. /**
  58079. * Compute the Color3 hexadecimal code as a string
  58080. * @returns a string containing the hexadecimal representation of the Color3 object
  58081. */
  58082. toHexString(): string;
  58083. /**
  58084. * Computes a new Color3 converted from the current one to linear space
  58085. * @returns a new Color3 object
  58086. */
  58087. toLinearSpace(): Color3;
  58088. /**
  58089. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  58090. * @param convertedColor defines the Color3 object where to store the linear space version
  58091. * @returns the unmodified Color3
  58092. */
  58093. toLinearSpaceToRef(convertedColor: Color3): Color3;
  58094. /**
  58095. * Computes a new Color3 converted from the current one to gamma space
  58096. * @returns a new Color3 object
  58097. */
  58098. toGammaSpace(): Color3;
  58099. /**
  58100. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  58101. * @param convertedColor defines the Color3 object where to store the gamma space version
  58102. * @returns the unmodified Color3
  58103. */
  58104. toGammaSpaceToRef(convertedColor: Color3): Color3;
  58105. private static _BlackReadOnly;
  58106. /**
  58107. * Creates a new Color3 from the string containing valid hexadecimal values
  58108. * @param hex defines a string containing valid hexadecimal values
  58109. * @returns a new Color3 object
  58110. */
  58111. static FromHexString(hex: string): Color3;
  58112. /**
  58113. * Creates a new Vector3 from the starting index of the given array
  58114. * @param array defines the source array
  58115. * @param offset defines an offset in the source array
  58116. * @returns a new Color3 object
  58117. */
  58118. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  58119. /**
  58120. * Creates a new Color3 from integer values (< 256)
  58121. * @param r defines the red component to read from (value between 0 and 255)
  58122. * @param g defines the green component to read from (value between 0 and 255)
  58123. * @param b defines the blue component to read from (value between 0 and 255)
  58124. * @returns a new Color3 object
  58125. */
  58126. static FromInts(r: number, g: number, b: number): Color3;
  58127. /**
  58128. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58129. * @param start defines the start Color3 value
  58130. * @param end defines the end Color3 value
  58131. * @param amount defines the gradient value between start and end
  58132. * @returns a new Color3 object
  58133. */
  58134. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  58135. /**
  58136. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58137. * @param left defines the start value
  58138. * @param right defines the end value
  58139. * @param amount defines the gradient factor
  58140. * @param result defines the Color3 object where to store the result
  58141. */
  58142. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  58143. /**
  58144. * Returns a Color3 value containing a red color
  58145. * @returns a new Color3 object
  58146. */
  58147. static Red(): Color3;
  58148. /**
  58149. * Returns a Color3 value containing a green color
  58150. * @returns a new Color3 object
  58151. */
  58152. static Green(): Color3;
  58153. /**
  58154. * Returns a Color3 value containing a blue color
  58155. * @returns a new Color3 object
  58156. */
  58157. static Blue(): Color3;
  58158. /**
  58159. * Returns a Color3 value containing a black color
  58160. * @returns a new Color3 object
  58161. */
  58162. static Black(): Color3;
  58163. /**
  58164. * Gets a Color3 value containing a black color that must not be updated
  58165. */
  58166. static readonly BlackReadOnly: DeepImmutable<Color3>;
  58167. /**
  58168. * Returns a Color3 value containing a white color
  58169. * @returns a new Color3 object
  58170. */
  58171. static White(): Color3;
  58172. /**
  58173. * Returns a Color3 value containing a purple color
  58174. * @returns a new Color3 object
  58175. */
  58176. static Purple(): Color3;
  58177. /**
  58178. * Returns a Color3 value containing a magenta color
  58179. * @returns a new Color3 object
  58180. */
  58181. static Magenta(): Color3;
  58182. /**
  58183. * Returns a Color3 value containing a yellow color
  58184. * @returns a new Color3 object
  58185. */
  58186. static Yellow(): Color3;
  58187. /**
  58188. * Returns a Color3 value containing a gray color
  58189. * @returns a new Color3 object
  58190. */
  58191. static Gray(): Color3;
  58192. /**
  58193. * Returns a Color3 value containing a teal color
  58194. * @returns a new Color3 object
  58195. */
  58196. static Teal(): Color3;
  58197. /**
  58198. * Returns a Color3 value containing a random color
  58199. * @returns a new Color3 object
  58200. */
  58201. static Random(): Color3;
  58202. }
  58203. /**
  58204. * Class used to hold a RBGA color
  58205. */
  58206. export class Color4 {
  58207. /**
  58208. * Defines the red component (between 0 and 1, default is 0)
  58209. */
  58210. r: number;
  58211. /**
  58212. * Defines the green component (between 0 and 1, default is 0)
  58213. */
  58214. g: number;
  58215. /**
  58216. * Defines the blue component (between 0 and 1, default is 0)
  58217. */
  58218. b: number;
  58219. /**
  58220. * Defines the alpha component (between 0 and 1, default is 1)
  58221. */
  58222. a: number;
  58223. /**
  58224. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  58225. * @param r defines the red component (between 0 and 1, default is 0)
  58226. * @param g defines the green component (between 0 and 1, default is 0)
  58227. * @param b defines the blue component (between 0 and 1, default is 0)
  58228. * @param a defines the alpha component (between 0 and 1, default is 1)
  58229. */
  58230. constructor(
  58231. /**
  58232. * Defines the red component (between 0 and 1, default is 0)
  58233. */
  58234. r?: number,
  58235. /**
  58236. * Defines the green component (between 0 and 1, default is 0)
  58237. */
  58238. g?: number,
  58239. /**
  58240. * Defines the blue component (between 0 and 1, default is 0)
  58241. */
  58242. b?: number,
  58243. /**
  58244. * Defines the alpha component (between 0 and 1, default is 1)
  58245. */
  58246. a?: number);
  58247. /**
  58248. * Adds in place the given Color4 values to the current Color4 object
  58249. * @param right defines the second operand
  58250. * @returns the current updated Color4 object
  58251. */
  58252. addInPlace(right: DeepImmutable<Color4>): Color4;
  58253. /**
  58254. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  58255. * @returns the new array
  58256. */
  58257. asArray(): number[];
  58258. /**
  58259. * Stores from the starting index in the given array the Color4 successive values
  58260. * @param array defines the array where to store the r,g,b components
  58261. * @param index defines an optional index in the target array to define where to start storing values
  58262. * @returns the current Color4 object
  58263. */
  58264. toArray(array: number[], index?: number): Color4;
  58265. /**
  58266. * Determines equality between Color4 objects
  58267. * @param otherColor defines the second operand
  58268. * @returns true if the rgba values are equal to the given ones
  58269. */
  58270. equals(otherColor: DeepImmutable<Color4>): boolean;
  58271. /**
  58272. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  58273. * @param right defines the second operand
  58274. * @returns a new Color4 object
  58275. */
  58276. add(right: DeepImmutable<Color4>): Color4;
  58277. /**
  58278. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  58279. * @param right defines the second operand
  58280. * @returns a new Color4 object
  58281. */
  58282. subtract(right: DeepImmutable<Color4>): Color4;
  58283. /**
  58284. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  58285. * @param right defines the second operand
  58286. * @param result defines the Color4 object where to store the result
  58287. * @returns the current Color4 object
  58288. */
  58289. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  58290. /**
  58291. * Creates a new Color4 with the current Color4 values multiplied by scale
  58292. * @param scale defines the scaling factor to apply
  58293. * @returns a new Color4 object
  58294. */
  58295. scale(scale: number): Color4;
  58296. /**
  58297. * Multiplies the current Color4 values by scale and stores the result in "result"
  58298. * @param scale defines the scaling factor to apply
  58299. * @param result defines the Color4 object where to store the result
  58300. * @returns the current unmodified Color4
  58301. */
  58302. scaleToRef(scale: number, result: Color4): Color4;
  58303. /**
  58304. * Scale the current Color4 values by a factor and add the result to a given Color4
  58305. * @param scale defines the scale factor
  58306. * @param result defines the Color4 object where to store the result
  58307. * @returns the unmodified current Color4
  58308. */
  58309. scaleAndAddToRef(scale: number, result: Color4): Color4;
  58310. /**
  58311. * Clamps the rgb values by the min and max values and stores the result into "result"
  58312. * @param min defines minimum clamping value (default is 0)
  58313. * @param max defines maximum clamping value (default is 1)
  58314. * @param result defines color to store the result into.
  58315. * @returns the cuurent Color4
  58316. */
  58317. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  58318. /**
  58319. * Multipy an Color4 value by another and return a new Color4 object
  58320. * @param color defines the Color4 value to multiply by
  58321. * @returns a new Color4 object
  58322. */
  58323. multiply(color: Color4): Color4;
  58324. /**
  58325. * Multipy a Color4 value by another and push the result in a reference value
  58326. * @param color defines the Color4 value to multiply by
  58327. * @param result defines the Color4 to fill the result in
  58328. * @returns the result Color4
  58329. */
  58330. multiplyToRef(color: Color4, result: Color4): Color4;
  58331. /**
  58332. * Creates a string with the Color4 current values
  58333. * @returns the string representation of the Color4 object
  58334. */
  58335. toString(): string;
  58336. /**
  58337. * Returns the string "Color4"
  58338. * @returns "Color4"
  58339. */
  58340. getClassName(): string;
  58341. /**
  58342. * Compute the Color4 hash code
  58343. * @returns an unique number that can be used to hash Color4 objects
  58344. */
  58345. getHashCode(): number;
  58346. /**
  58347. * Creates a new Color4 copied from the current one
  58348. * @returns a new Color4 object
  58349. */
  58350. clone(): Color4;
  58351. /**
  58352. * Copies the given Color4 values into the current one
  58353. * @param source defines the source Color4 object
  58354. * @returns the current updated Color4 object
  58355. */
  58356. copyFrom(source: Color4): Color4;
  58357. /**
  58358. * Copies the given float values into the current one
  58359. * @param r defines the red component to read from
  58360. * @param g defines the green component to read from
  58361. * @param b defines the blue component to read from
  58362. * @param a defines the alpha component to read from
  58363. * @returns the current updated Color4 object
  58364. */
  58365. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  58366. /**
  58367. * Copies the given float values into the current one
  58368. * @param r defines the red component to read from
  58369. * @param g defines the green component to read from
  58370. * @param b defines the blue component to read from
  58371. * @param a defines the alpha component to read from
  58372. * @returns the current updated Color4 object
  58373. */
  58374. set(r: number, g: number, b: number, a: number): Color4;
  58375. /**
  58376. * Compute the Color4 hexadecimal code as a string
  58377. * @returns a string containing the hexadecimal representation of the Color4 object
  58378. */
  58379. toHexString(): string;
  58380. /**
  58381. * Computes a new Color4 converted from the current one to linear space
  58382. * @returns a new Color4 object
  58383. */
  58384. toLinearSpace(): Color4;
  58385. /**
  58386. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  58387. * @param convertedColor defines the Color4 object where to store the linear space version
  58388. * @returns the unmodified Color4
  58389. */
  58390. toLinearSpaceToRef(convertedColor: Color4): Color4;
  58391. /**
  58392. * Computes a new Color4 converted from the current one to gamma space
  58393. * @returns a new Color4 object
  58394. */
  58395. toGammaSpace(): Color4;
  58396. /**
  58397. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  58398. * @param convertedColor defines the Color4 object where to store the gamma space version
  58399. * @returns the unmodified Color4
  58400. */
  58401. toGammaSpaceToRef(convertedColor: Color4): Color4;
  58402. /**
  58403. * Creates a new Color4 from the string containing valid hexadecimal values
  58404. * @param hex defines a string containing valid hexadecimal values
  58405. * @returns a new Color4 object
  58406. */
  58407. static FromHexString(hex: string): Color4;
  58408. /**
  58409. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58410. * @param left defines the start value
  58411. * @param right defines the end value
  58412. * @param amount defines the gradient factor
  58413. * @returns a new Color4 object
  58414. */
  58415. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  58416. /**
  58417. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58418. * @param left defines the start value
  58419. * @param right defines the end value
  58420. * @param amount defines the gradient factor
  58421. * @param result defines the Color4 object where to store data
  58422. */
  58423. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  58424. /**
  58425. * Creates a new Color4 from a Color3 and an alpha value
  58426. * @param color3 defines the source Color3 to read from
  58427. * @param alpha defines the alpha component (1.0 by default)
  58428. * @returns a new Color4 object
  58429. */
  58430. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  58431. /**
  58432. * Creates a new Color4 from the starting index element of the given array
  58433. * @param array defines the source array to read from
  58434. * @param offset defines the offset in the source array
  58435. * @returns a new Color4 object
  58436. */
  58437. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  58438. /**
  58439. * Creates a new Color3 from integer values (< 256)
  58440. * @param r defines the red component to read from (value between 0 and 255)
  58441. * @param g defines the green component to read from (value between 0 and 255)
  58442. * @param b defines the blue component to read from (value between 0 and 255)
  58443. * @param a defines the alpha component to read from (value between 0 and 255)
  58444. * @returns a new Color3 object
  58445. */
  58446. static FromInts(r: number, g: number, b: number, a: number): Color4;
  58447. /**
  58448. * Check the content of a given array and convert it to an array containing RGBA data
  58449. * If the original array was already containing count * 4 values then it is returned directly
  58450. * @param colors defines the array to check
  58451. * @param count defines the number of RGBA data to expect
  58452. * @returns an array containing count * 4 values (RGBA)
  58453. */
  58454. static CheckColors4(colors: number[], count: number): number[];
  58455. }
  58456. /**
  58457. * Class representing a vector containing 2 coordinates
  58458. */
  58459. export class Vector2 {
  58460. /** defines the first coordinate */
  58461. x: number;
  58462. /** defines the second coordinate */
  58463. y: number;
  58464. /**
  58465. * Creates a new Vector2 from the given x and y coordinates
  58466. * @param x defines the first coordinate
  58467. * @param y defines the second coordinate
  58468. */
  58469. constructor(
  58470. /** defines the first coordinate */
  58471. x?: number,
  58472. /** defines the second coordinate */
  58473. y?: number);
  58474. /**
  58475. * Gets a string with the Vector2 coordinates
  58476. * @returns a string with the Vector2 coordinates
  58477. */
  58478. toString(): string;
  58479. /**
  58480. * Gets class name
  58481. * @returns the string "Vector2"
  58482. */
  58483. getClassName(): string;
  58484. /**
  58485. * Gets current vector hash code
  58486. * @returns the Vector2 hash code as a number
  58487. */
  58488. getHashCode(): number;
  58489. /**
  58490. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  58491. * @param array defines the source array
  58492. * @param index defines the offset in source array
  58493. * @returns the current Vector2
  58494. */
  58495. toArray(array: FloatArray, index?: number): Vector2;
  58496. /**
  58497. * Copy the current vector to an array
  58498. * @returns a new array with 2 elements: the Vector2 coordinates.
  58499. */
  58500. asArray(): number[];
  58501. /**
  58502. * Sets the Vector2 coordinates with the given Vector2 coordinates
  58503. * @param source defines the source Vector2
  58504. * @returns the current updated Vector2
  58505. */
  58506. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  58507. /**
  58508. * Sets the Vector2 coordinates with the given floats
  58509. * @param x defines the first coordinate
  58510. * @param y defines the second coordinate
  58511. * @returns the current updated Vector2
  58512. */
  58513. copyFromFloats(x: number, y: number): Vector2;
  58514. /**
  58515. * Sets the Vector2 coordinates with the given floats
  58516. * @param x defines the first coordinate
  58517. * @param y defines the second coordinate
  58518. * @returns the current updated Vector2
  58519. */
  58520. set(x: number, y: number): Vector2;
  58521. /**
  58522. * Add another vector with the current one
  58523. * @param otherVector defines the other vector
  58524. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  58525. */
  58526. add(otherVector: DeepImmutable<Vector2>): Vector2;
  58527. /**
  58528. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  58529. * @param otherVector defines the other vector
  58530. * @param result defines the target vector
  58531. * @returns the unmodified current Vector2
  58532. */
  58533. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58534. /**
  58535. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  58536. * @param otherVector defines the other vector
  58537. * @returns the current updated Vector2
  58538. */
  58539. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58540. /**
  58541. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  58542. * @param otherVector defines the other vector
  58543. * @returns a new Vector2
  58544. */
  58545. addVector3(otherVector: Vector3): Vector2;
  58546. /**
  58547. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  58548. * @param otherVector defines the other vector
  58549. * @returns a new Vector2
  58550. */
  58551. subtract(otherVector: Vector2): Vector2;
  58552. /**
  58553. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  58554. * @param otherVector defines the other vector
  58555. * @param result defines the target vector
  58556. * @returns the unmodified current Vector2
  58557. */
  58558. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58559. /**
  58560. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  58561. * @param otherVector defines the other vector
  58562. * @returns the current updated Vector2
  58563. */
  58564. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58565. /**
  58566. * Multiplies in place the current Vector2 coordinates by the given ones
  58567. * @param otherVector defines the other vector
  58568. * @returns the current updated Vector2
  58569. */
  58570. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58571. /**
  58572. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  58573. * @param otherVector defines the other vector
  58574. * @returns a new Vector2
  58575. */
  58576. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  58577. /**
  58578. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  58579. * @param otherVector defines the other vector
  58580. * @param result defines the target vector
  58581. * @returns the unmodified current Vector2
  58582. */
  58583. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58584. /**
  58585. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  58586. * @param x defines the first coordinate
  58587. * @param y defines the second coordinate
  58588. * @returns a new Vector2
  58589. */
  58590. multiplyByFloats(x: number, y: number): Vector2;
  58591. /**
  58592. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  58593. * @param otherVector defines the other vector
  58594. * @returns a new Vector2
  58595. */
  58596. divide(otherVector: Vector2): Vector2;
  58597. /**
  58598. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  58599. * @param otherVector defines the other vector
  58600. * @param result defines the target vector
  58601. * @returns the unmodified current Vector2
  58602. */
  58603. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58604. /**
  58605. * Divides the current Vector2 coordinates by the given ones
  58606. * @param otherVector defines the other vector
  58607. * @returns the current updated Vector2
  58608. */
  58609. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58610. /**
  58611. * Gets a new Vector2 with current Vector2 negated coordinates
  58612. * @returns a new Vector2
  58613. */
  58614. negate(): Vector2;
  58615. /**
  58616. * Multiply the Vector2 coordinates by scale
  58617. * @param scale defines the scaling factor
  58618. * @returns the current updated Vector2
  58619. */
  58620. scaleInPlace(scale: number): Vector2;
  58621. /**
  58622. * Returns a new Vector2 scaled by "scale" from the current Vector2
  58623. * @param scale defines the scaling factor
  58624. * @returns a new Vector2
  58625. */
  58626. scale(scale: number): Vector2;
  58627. /**
  58628. * Scale the current Vector2 values by a factor to a given Vector2
  58629. * @param scale defines the scale factor
  58630. * @param result defines the Vector2 object where to store the result
  58631. * @returns the unmodified current Vector2
  58632. */
  58633. scaleToRef(scale: number, result: Vector2): Vector2;
  58634. /**
  58635. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  58636. * @param scale defines the scale factor
  58637. * @param result defines the Vector2 object where to store the result
  58638. * @returns the unmodified current Vector2
  58639. */
  58640. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  58641. /**
  58642. * Gets a boolean if two vectors are equals
  58643. * @param otherVector defines the other vector
  58644. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  58645. */
  58646. equals(otherVector: DeepImmutable<Vector2>): boolean;
  58647. /**
  58648. * Gets a boolean if two vectors are equals (using an epsilon value)
  58649. * @param otherVector defines the other vector
  58650. * @param epsilon defines the minimal distance to consider equality
  58651. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  58652. */
  58653. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  58654. /**
  58655. * Gets a new Vector2 from current Vector2 floored values
  58656. * @returns a new Vector2
  58657. */
  58658. floor(): Vector2;
  58659. /**
  58660. * Gets a new Vector2 from current Vector2 floored values
  58661. * @returns a new Vector2
  58662. */
  58663. fract(): Vector2;
  58664. /**
  58665. * Gets the length of the vector
  58666. * @returns the vector length (float)
  58667. */
  58668. length(): number;
  58669. /**
  58670. * Gets the vector squared length
  58671. * @returns the vector squared length (float)
  58672. */
  58673. lengthSquared(): number;
  58674. /**
  58675. * Normalize the vector
  58676. * @returns the current updated Vector2
  58677. */
  58678. normalize(): Vector2;
  58679. /**
  58680. * Gets a new Vector2 copied from the Vector2
  58681. * @returns a new Vector2
  58682. */
  58683. clone(): Vector2;
  58684. /**
  58685. * Gets a new Vector2(0, 0)
  58686. * @returns a new Vector2
  58687. */
  58688. static Zero(): Vector2;
  58689. /**
  58690. * Gets a new Vector2(1, 1)
  58691. * @returns a new Vector2
  58692. */
  58693. static One(): Vector2;
  58694. /**
  58695. * Gets a new Vector2 set from the given index element of the given array
  58696. * @param array defines the data source
  58697. * @param offset defines the offset in the data source
  58698. * @returns a new Vector2
  58699. */
  58700. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  58701. /**
  58702. * Sets "result" from the given index element of the given array
  58703. * @param array defines the data source
  58704. * @param offset defines the offset in the data source
  58705. * @param result defines the target vector
  58706. */
  58707. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  58708. /**
  58709. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  58710. * @param value1 defines 1st point of control
  58711. * @param value2 defines 2nd point of control
  58712. * @param value3 defines 3rd point of control
  58713. * @param value4 defines 4th point of control
  58714. * @param amount defines the interpolation factor
  58715. * @returns a new Vector2
  58716. */
  58717. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  58718. /**
  58719. * 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".
  58720. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  58721. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  58722. * @param value defines the value to clamp
  58723. * @param min defines the lower limit
  58724. * @param max defines the upper limit
  58725. * @returns a new Vector2
  58726. */
  58727. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  58728. /**
  58729. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  58730. * @param value1 defines the 1st control point
  58731. * @param tangent1 defines the outgoing tangent
  58732. * @param value2 defines the 2nd control point
  58733. * @param tangent2 defines the incoming tangent
  58734. * @param amount defines the interpolation factor
  58735. * @returns a new Vector2
  58736. */
  58737. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  58738. /**
  58739. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  58740. * @param start defines the start vector
  58741. * @param end defines the end vector
  58742. * @param amount defines the interpolation factor
  58743. * @returns a new Vector2
  58744. */
  58745. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  58746. /**
  58747. * Gets the dot product of the vector "left" and the vector "right"
  58748. * @param left defines first vector
  58749. * @param right defines second vector
  58750. * @returns the dot product (float)
  58751. */
  58752. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  58753. /**
  58754. * Returns a new Vector2 equal to the normalized given vector
  58755. * @param vector defines the vector to normalize
  58756. * @returns a new Vector2
  58757. */
  58758. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  58759. /**
  58760. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  58761. * @param left defines 1st vector
  58762. * @param right defines 2nd vector
  58763. * @returns a new Vector2
  58764. */
  58765. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58766. /**
  58767. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  58768. * @param left defines 1st vector
  58769. * @param right defines 2nd vector
  58770. * @returns a new Vector2
  58771. */
  58772. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58773. /**
  58774. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  58775. * @param vector defines the vector to transform
  58776. * @param transformation defines the matrix to apply
  58777. * @returns a new Vector2
  58778. */
  58779. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  58780. /**
  58781. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  58782. * @param vector defines the vector to transform
  58783. * @param transformation defines the matrix to apply
  58784. * @param result defines the target vector
  58785. */
  58786. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  58787. /**
  58788. * Determines if a given vector is included in a triangle
  58789. * @param p defines the vector to test
  58790. * @param p0 defines 1st triangle point
  58791. * @param p1 defines 2nd triangle point
  58792. * @param p2 defines 3rd triangle point
  58793. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  58794. */
  58795. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  58796. /**
  58797. * Gets the distance between the vectors "value1" and "value2"
  58798. * @param value1 defines first vector
  58799. * @param value2 defines second vector
  58800. * @returns the distance between vectors
  58801. */
  58802. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58803. /**
  58804. * Returns the squared distance between the vectors "value1" and "value2"
  58805. * @param value1 defines first vector
  58806. * @param value2 defines second vector
  58807. * @returns the squared distance between vectors
  58808. */
  58809. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58810. /**
  58811. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  58812. * @param value1 defines first vector
  58813. * @param value2 defines second vector
  58814. * @returns a new Vector2
  58815. */
  58816. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  58817. /**
  58818. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  58819. * @param p defines the middle point
  58820. * @param segA defines one point of the segment
  58821. * @param segB defines the other point of the segment
  58822. * @returns the shortest distance
  58823. */
  58824. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  58825. }
  58826. /**
  58827. * Classed used to store (x,y,z) vector representation
  58828. * A Vector3 is the main object used in 3D geometry
  58829. * It can represent etiher the coordinates of a point the space, either a direction
  58830. * Reminder: js uses a left handed forward facing system
  58831. */
  58832. export class Vector3 {
  58833. /**
  58834. * Defines the first coordinates (on X axis)
  58835. */
  58836. x: number;
  58837. /**
  58838. * Defines the second coordinates (on Y axis)
  58839. */
  58840. y: number;
  58841. /**
  58842. * Defines the third coordinates (on Z axis)
  58843. */
  58844. z: number;
  58845. private static _UpReadOnly;
  58846. /**
  58847. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  58848. * @param x defines the first coordinates (on X axis)
  58849. * @param y defines the second coordinates (on Y axis)
  58850. * @param z defines the third coordinates (on Z axis)
  58851. */
  58852. constructor(
  58853. /**
  58854. * Defines the first coordinates (on X axis)
  58855. */
  58856. x?: number,
  58857. /**
  58858. * Defines the second coordinates (on Y axis)
  58859. */
  58860. y?: number,
  58861. /**
  58862. * Defines the third coordinates (on Z axis)
  58863. */
  58864. z?: number);
  58865. /**
  58866. * Creates a string representation of the Vector3
  58867. * @returns a string with the Vector3 coordinates.
  58868. */
  58869. toString(): string;
  58870. /**
  58871. * Gets the class name
  58872. * @returns the string "Vector3"
  58873. */
  58874. getClassName(): string;
  58875. /**
  58876. * Creates the Vector3 hash code
  58877. * @returns a number which tends to be unique between Vector3 instances
  58878. */
  58879. getHashCode(): number;
  58880. /**
  58881. * Creates an array containing three elements : the coordinates of the Vector3
  58882. * @returns a new array of numbers
  58883. */
  58884. asArray(): number[];
  58885. /**
  58886. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  58887. * @param array defines the destination array
  58888. * @param index defines the offset in the destination array
  58889. * @returns the current Vector3
  58890. */
  58891. toArray(array: FloatArray, index?: number): Vector3;
  58892. /**
  58893. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  58894. * @returns a new Quaternion object, computed from the Vector3 coordinates
  58895. */
  58896. toQuaternion(): Quaternion;
  58897. /**
  58898. * Adds the given vector to the current Vector3
  58899. * @param otherVector defines the second operand
  58900. * @returns the current updated Vector3
  58901. */
  58902. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58903. /**
  58904. * Adds the given coordinates to the current Vector3
  58905. * @param x defines the x coordinate of the operand
  58906. * @param y defines the y coordinate of the operand
  58907. * @param z defines the z coordinate of the operand
  58908. * @returns the current updated Vector3
  58909. */
  58910. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58911. /**
  58912. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  58913. * @param otherVector defines the second operand
  58914. * @returns the resulting Vector3
  58915. */
  58916. add(otherVector: DeepImmutable<Vector3>): Vector3;
  58917. /**
  58918. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  58919. * @param otherVector defines the second operand
  58920. * @param result defines the Vector3 object where to store the result
  58921. * @returns the current Vector3
  58922. */
  58923. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58924. /**
  58925. * Subtract the given vector from the current Vector3
  58926. * @param otherVector defines the second operand
  58927. * @returns the current updated Vector3
  58928. */
  58929. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58930. /**
  58931. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  58932. * @param otherVector defines the second operand
  58933. * @returns the resulting Vector3
  58934. */
  58935. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  58936. /**
  58937. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  58938. * @param otherVector defines the second operand
  58939. * @param result defines the Vector3 object where to store the result
  58940. * @returns the current Vector3
  58941. */
  58942. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58943. /**
  58944. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  58945. * @param x defines the x coordinate of the operand
  58946. * @param y defines the y coordinate of the operand
  58947. * @param z defines the z coordinate of the operand
  58948. * @returns the resulting Vector3
  58949. */
  58950. subtractFromFloats(x: number, y: number, z: number): Vector3;
  58951. /**
  58952. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  58953. * @param x defines the x coordinate of the operand
  58954. * @param y defines the y coordinate of the operand
  58955. * @param z defines the z coordinate of the operand
  58956. * @param result defines the Vector3 object where to store the result
  58957. * @returns the current Vector3
  58958. */
  58959. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  58960. /**
  58961. * Gets a new Vector3 set with the current Vector3 negated coordinates
  58962. * @returns a new Vector3
  58963. */
  58964. negate(): Vector3;
  58965. /**
  58966. * Multiplies the Vector3 coordinates by the float "scale"
  58967. * @param scale defines the multiplier factor
  58968. * @returns the current updated Vector3
  58969. */
  58970. scaleInPlace(scale: number): Vector3;
  58971. /**
  58972. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  58973. * @param scale defines the multiplier factor
  58974. * @returns a new Vector3
  58975. */
  58976. scale(scale: number): Vector3;
  58977. /**
  58978. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  58979. * @param scale defines the multiplier factor
  58980. * @param result defines the Vector3 object where to store the result
  58981. * @returns the current Vector3
  58982. */
  58983. scaleToRef(scale: number, result: Vector3): Vector3;
  58984. /**
  58985. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  58986. * @param scale defines the scale factor
  58987. * @param result defines the Vector3 object where to store the result
  58988. * @returns the unmodified current Vector3
  58989. */
  58990. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  58991. /**
  58992. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  58993. * @param otherVector defines the second operand
  58994. * @returns true if both vectors are equals
  58995. */
  58996. equals(otherVector: DeepImmutable<Vector3>): boolean;
  58997. /**
  58998. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  58999. * @param otherVector defines the second operand
  59000. * @param epsilon defines the minimal distance to define values as equals
  59001. * @returns true if both vectors are distant less than epsilon
  59002. */
  59003. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  59004. /**
  59005. * Returns true if the current Vector3 coordinates equals the given floats
  59006. * @param x defines the x coordinate of the operand
  59007. * @param y defines the y coordinate of the operand
  59008. * @param z defines the z coordinate of the operand
  59009. * @returns true if both vectors are equals
  59010. */
  59011. equalsToFloats(x: number, y: number, z: number): boolean;
  59012. /**
  59013. * Multiplies the current Vector3 coordinates by the given ones
  59014. * @param otherVector defines the second operand
  59015. * @returns the current updated Vector3
  59016. */
  59017. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59018. /**
  59019. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  59020. * @param otherVector defines the second operand
  59021. * @returns the new Vector3
  59022. */
  59023. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  59024. /**
  59025. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  59026. * @param otherVector defines the second operand
  59027. * @param result defines the Vector3 object where to store the result
  59028. * @returns the current Vector3
  59029. */
  59030. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59031. /**
  59032. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  59033. * @param x defines the x coordinate of the operand
  59034. * @param y defines the y coordinate of the operand
  59035. * @param z defines the z coordinate of the operand
  59036. * @returns the new Vector3
  59037. */
  59038. multiplyByFloats(x: number, y: number, z: number): Vector3;
  59039. /**
  59040. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  59041. * @param otherVector defines the second operand
  59042. * @returns the new Vector3
  59043. */
  59044. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  59045. /**
  59046. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  59047. * @param otherVector defines the second operand
  59048. * @param result defines the Vector3 object where to store the result
  59049. * @returns the current Vector3
  59050. */
  59051. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59052. /**
  59053. * Divides the current Vector3 coordinates by the given ones.
  59054. * @param otherVector defines the second operand
  59055. * @returns the current updated Vector3
  59056. */
  59057. divideInPlace(otherVector: Vector3): Vector3;
  59058. /**
  59059. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  59060. * @param other defines the second operand
  59061. * @returns the current updated Vector3
  59062. */
  59063. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59064. /**
  59065. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  59066. * @param other defines the second operand
  59067. * @returns the current updated Vector3
  59068. */
  59069. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59070. /**
  59071. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  59072. * @param x defines the x coordinate of the operand
  59073. * @param y defines the y coordinate of the operand
  59074. * @param z defines the z coordinate of the operand
  59075. * @returns the current updated Vector3
  59076. */
  59077. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59078. /**
  59079. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  59080. * @param x defines the x coordinate of the operand
  59081. * @param y defines the y coordinate of the operand
  59082. * @param z defines the z coordinate of the operand
  59083. * @returns the current updated Vector3
  59084. */
  59085. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59086. /**
  59087. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  59088. * Check if is non uniform within a certain amount of decimal places to account for this
  59089. * @param epsilon the amount the values can differ
  59090. * @returns if the the vector is non uniform to a certain number of decimal places
  59091. */
  59092. isNonUniformWithinEpsilon(epsilon: number): boolean;
  59093. /**
  59094. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  59095. */
  59096. readonly isNonUniform: boolean;
  59097. /**
  59098. * Gets a new Vector3 from current Vector3 floored values
  59099. * @returns a new Vector3
  59100. */
  59101. floor(): Vector3;
  59102. /**
  59103. * Gets a new Vector3 from current Vector3 floored values
  59104. * @returns a new Vector3
  59105. */
  59106. fract(): Vector3;
  59107. /**
  59108. * Gets the length of the Vector3
  59109. * @returns the length of the Vecto3
  59110. */
  59111. length(): number;
  59112. /**
  59113. * Gets the squared length of the Vector3
  59114. * @returns squared length of the Vector3
  59115. */
  59116. lengthSquared(): number;
  59117. /**
  59118. * Normalize the current Vector3.
  59119. * Please note that this is an in place operation.
  59120. * @returns the current updated Vector3
  59121. */
  59122. normalize(): Vector3;
  59123. /**
  59124. * Reorders the x y z properties of the vector in place
  59125. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  59126. * @returns the current updated vector
  59127. */
  59128. reorderInPlace(order: string): this;
  59129. /**
  59130. * Rotates the vector around 0,0,0 by a quaternion
  59131. * @param quaternion the rotation quaternion
  59132. * @param result vector to store the result
  59133. * @returns the resulting vector
  59134. */
  59135. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  59136. /**
  59137. * Rotates a vector around a given point
  59138. * @param quaternion the rotation quaternion
  59139. * @param point the point to rotate around
  59140. * @param result vector to store the result
  59141. * @returns the resulting vector
  59142. */
  59143. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  59144. /**
  59145. * Normalize the current Vector3 with the given input length.
  59146. * Please note that this is an in place operation.
  59147. * @param len the length of the vector
  59148. * @returns the current updated Vector3
  59149. */
  59150. normalizeFromLength(len: number): Vector3;
  59151. /**
  59152. * Normalize the current Vector3 to a new vector
  59153. * @returns the new Vector3
  59154. */
  59155. normalizeToNew(): Vector3;
  59156. /**
  59157. * Normalize the current Vector3 to the reference
  59158. * @param reference define the Vector3 to update
  59159. * @returns the updated Vector3
  59160. */
  59161. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  59162. /**
  59163. * Creates a new Vector3 copied from the current Vector3
  59164. * @returns the new Vector3
  59165. */
  59166. clone(): Vector3;
  59167. /**
  59168. * Copies the given vector coordinates to the current Vector3 ones
  59169. * @param source defines the source Vector3
  59170. * @returns the current updated Vector3
  59171. */
  59172. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  59173. /**
  59174. * Copies the given floats to the current Vector3 coordinates
  59175. * @param x defines the x coordinate of the operand
  59176. * @param y defines the y coordinate of the operand
  59177. * @param z defines the z coordinate of the operand
  59178. * @returns the current updated Vector3
  59179. */
  59180. copyFromFloats(x: number, y: number, z: number): Vector3;
  59181. /**
  59182. * Copies the given floats to the current Vector3 coordinates
  59183. * @param x defines the x coordinate of the operand
  59184. * @param y defines the y coordinate of the operand
  59185. * @param z defines the z coordinate of the operand
  59186. * @returns the current updated Vector3
  59187. */
  59188. set(x: number, y: number, z: number): Vector3;
  59189. /**
  59190. * Copies the given float to the current Vector3 coordinates
  59191. * @param v defines the x, y and z coordinates of the operand
  59192. * @returns the current updated Vector3
  59193. */
  59194. setAll(v: number): Vector3;
  59195. /**
  59196. * Get the clip factor between two vectors
  59197. * @param vector0 defines the first operand
  59198. * @param vector1 defines the second operand
  59199. * @param axis defines the axis to use
  59200. * @param size defines the size along the axis
  59201. * @returns the clip factor
  59202. */
  59203. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  59204. /**
  59205. * Get angle between two vectors
  59206. * @param vector0 angle between vector0 and vector1
  59207. * @param vector1 angle between vector0 and vector1
  59208. * @param normal direction of the normal
  59209. * @return the angle between vector0 and vector1
  59210. */
  59211. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  59212. /**
  59213. * Returns a new Vector3 set from the index "offset" of the given array
  59214. * @param array defines the source array
  59215. * @param offset defines the offset in the source array
  59216. * @returns the new Vector3
  59217. */
  59218. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  59219. /**
  59220. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  59221. * This function is deprecated. Use FromArray instead
  59222. * @param array defines the source array
  59223. * @param offset defines the offset in the source array
  59224. * @returns the new Vector3
  59225. */
  59226. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  59227. /**
  59228. * Sets the given vector "result" with the element values from the index "offset" of the given array
  59229. * @param array defines the source array
  59230. * @param offset defines the offset in the source array
  59231. * @param result defines the Vector3 where to store the result
  59232. */
  59233. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  59234. /**
  59235. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  59236. * This function is deprecated. Use FromArrayToRef instead.
  59237. * @param array defines the source array
  59238. * @param offset defines the offset in the source array
  59239. * @param result defines the Vector3 where to store the result
  59240. */
  59241. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  59242. /**
  59243. * Sets the given vector "result" with the given floats.
  59244. * @param x defines the x coordinate of the source
  59245. * @param y defines the y coordinate of the source
  59246. * @param z defines the z coordinate of the source
  59247. * @param result defines the Vector3 where to store the result
  59248. */
  59249. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  59250. /**
  59251. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  59252. * @returns a new empty Vector3
  59253. */
  59254. static Zero(): Vector3;
  59255. /**
  59256. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  59257. * @returns a new unit Vector3
  59258. */
  59259. static One(): Vector3;
  59260. /**
  59261. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  59262. * @returns a new up Vector3
  59263. */
  59264. static Up(): Vector3;
  59265. /**
  59266. * Gets a up Vector3 that must not be updated
  59267. */
  59268. static readonly UpReadOnly: DeepImmutable<Vector3>;
  59269. /**
  59270. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  59271. * @returns a new down Vector3
  59272. */
  59273. static Down(): Vector3;
  59274. /**
  59275. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  59276. * @returns a new forward Vector3
  59277. */
  59278. static Forward(): Vector3;
  59279. /**
  59280. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  59281. * @returns a new forward Vector3
  59282. */
  59283. static Backward(): Vector3;
  59284. /**
  59285. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  59286. * @returns a new right Vector3
  59287. */
  59288. static Right(): Vector3;
  59289. /**
  59290. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  59291. * @returns a new left Vector3
  59292. */
  59293. static Left(): Vector3;
  59294. /**
  59295. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  59296. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59297. * @param vector defines the Vector3 to transform
  59298. * @param transformation defines the transformation matrix
  59299. * @returns the transformed Vector3
  59300. */
  59301. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59302. /**
  59303. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  59304. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59305. * @param vector defines the Vector3 to transform
  59306. * @param transformation defines the transformation matrix
  59307. * @param result defines the Vector3 where to store the result
  59308. */
  59309. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59310. /**
  59311. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  59312. * This method computes tranformed coordinates only, not transformed direction vectors
  59313. * @param x define the x coordinate of the source vector
  59314. * @param y define the y coordinate of the source vector
  59315. * @param z define the z coordinate of the source vector
  59316. * @param transformation defines the transformation matrix
  59317. * @param result defines the Vector3 where to store the result
  59318. */
  59319. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59320. /**
  59321. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  59322. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59323. * @param vector defines the Vector3 to transform
  59324. * @param transformation defines the transformation matrix
  59325. * @returns the new Vector3
  59326. */
  59327. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59328. /**
  59329. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  59330. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59331. * @param vector defines the Vector3 to transform
  59332. * @param transformation defines the transformation matrix
  59333. * @param result defines the Vector3 where to store the result
  59334. */
  59335. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59336. /**
  59337. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  59338. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59339. * @param x define the x coordinate of the source vector
  59340. * @param y define the y coordinate of the source vector
  59341. * @param z define the z coordinate of the source vector
  59342. * @param transformation defines the transformation matrix
  59343. * @param result defines the Vector3 where to store the result
  59344. */
  59345. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59346. /**
  59347. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  59348. * @param value1 defines the first control point
  59349. * @param value2 defines the second control point
  59350. * @param value3 defines the third control point
  59351. * @param value4 defines the fourth control point
  59352. * @param amount defines the amount on the spline to use
  59353. * @returns the new Vector3
  59354. */
  59355. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  59356. /**
  59357. * 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"
  59358. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59359. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59360. * @param value defines the current value
  59361. * @param min defines the lower range value
  59362. * @param max defines the upper range value
  59363. * @returns the new Vector3
  59364. */
  59365. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  59366. /**
  59367. * 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"
  59368. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59369. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59370. * @param value defines the current value
  59371. * @param min defines the lower range value
  59372. * @param max defines the upper range value
  59373. * @param result defines the Vector3 where to store the result
  59374. */
  59375. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  59376. /**
  59377. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  59378. * @param value1 defines the first control point
  59379. * @param tangent1 defines the first tangent vector
  59380. * @param value2 defines the second control point
  59381. * @param tangent2 defines the second tangent vector
  59382. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  59383. * @returns the new Vector3
  59384. */
  59385. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  59386. /**
  59387. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  59388. * @param start defines the start value
  59389. * @param end defines the end value
  59390. * @param amount max defines amount between both (between 0 and 1)
  59391. * @returns the new Vector3
  59392. */
  59393. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  59394. /**
  59395. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  59396. * @param start defines the start value
  59397. * @param end defines the end value
  59398. * @param amount max defines amount between both (between 0 and 1)
  59399. * @param result defines the Vector3 where to store the result
  59400. */
  59401. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  59402. /**
  59403. * Returns the dot product (float) between the vectors "left" and "right"
  59404. * @param left defines the left operand
  59405. * @param right defines the right operand
  59406. * @returns the dot product
  59407. */
  59408. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  59409. /**
  59410. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  59411. * The cross product is then orthogonal to both "left" and "right"
  59412. * @param left defines the left operand
  59413. * @param right defines the right operand
  59414. * @returns the cross product
  59415. */
  59416. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59417. /**
  59418. * Sets the given vector "result" with the cross product of "left" and "right"
  59419. * The cross product is then orthogonal to both "left" and "right"
  59420. * @param left defines the left operand
  59421. * @param right defines the right operand
  59422. * @param result defines the Vector3 where to store the result
  59423. */
  59424. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  59425. /**
  59426. * Returns a new Vector3 as the normalization of the given vector
  59427. * @param vector defines the Vector3 to normalize
  59428. * @returns the new Vector3
  59429. */
  59430. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  59431. /**
  59432. * Sets the given vector "result" with the normalization of the given first vector
  59433. * @param vector defines the Vector3 to normalize
  59434. * @param result defines the Vector3 where to store the result
  59435. */
  59436. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  59437. /**
  59438. * Project a Vector3 onto screen space
  59439. * @param vector defines the Vector3 to project
  59440. * @param world defines the world matrix to use
  59441. * @param transform defines the transform (view x projection) matrix to use
  59442. * @param viewport defines the screen viewport to use
  59443. * @returns the new Vector3
  59444. */
  59445. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  59446. /** @hidden */
  59447. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  59448. /**
  59449. * Unproject from screen space to object space
  59450. * @param source defines the screen space Vector3 to use
  59451. * @param viewportWidth defines the current width of the viewport
  59452. * @param viewportHeight defines the current height of the viewport
  59453. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59454. * @param transform defines the transform (view x projection) matrix to use
  59455. * @returns the new Vector3
  59456. */
  59457. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  59458. /**
  59459. * Unproject from screen space to object space
  59460. * @param source defines the screen space Vector3 to use
  59461. * @param viewportWidth defines the current width of the viewport
  59462. * @param viewportHeight defines the current height of the viewport
  59463. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59464. * @param view defines the view matrix to use
  59465. * @param projection defines the projection matrix to use
  59466. * @returns the new Vector3
  59467. */
  59468. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  59469. /**
  59470. * Unproject from screen space to object space
  59471. * @param source defines the screen space Vector3 to use
  59472. * @param viewportWidth defines the current width of the viewport
  59473. * @param viewportHeight defines the current height of the viewport
  59474. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59475. * @param view defines the view matrix to use
  59476. * @param projection defines the projection matrix to use
  59477. * @param result defines the Vector3 where to store the result
  59478. */
  59479. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59480. /**
  59481. * Unproject from screen space to object space
  59482. * @param sourceX defines the screen space x coordinate to use
  59483. * @param sourceY defines the screen space y coordinate to use
  59484. * @param sourceZ defines the screen space z coordinate to use
  59485. * @param viewportWidth defines the current width of the viewport
  59486. * @param viewportHeight defines the current height of the viewport
  59487. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59488. * @param view defines the view matrix to use
  59489. * @param projection defines the projection matrix to use
  59490. * @param result defines the Vector3 where to store the result
  59491. */
  59492. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59493. /**
  59494. * Gets the minimal coordinate values between two Vector3
  59495. * @param left defines the first operand
  59496. * @param right defines the second operand
  59497. * @returns the new Vector3
  59498. */
  59499. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59500. /**
  59501. * Gets the maximal coordinate values between two Vector3
  59502. * @param left defines the first operand
  59503. * @param right defines the second operand
  59504. * @returns the new Vector3
  59505. */
  59506. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59507. /**
  59508. * Returns the distance between the vectors "value1" and "value2"
  59509. * @param value1 defines the first operand
  59510. * @param value2 defines the second operand
  59511. * @returns the distance
  59512. */
  59513. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59514. /**
  59515. * Returns the squared distance between the vectors "value1" and "value2"
  59516. * @param value1 defines the first operand
  59517. * @param value2 defines the second operand
  59518. * @returns the squared distance
  59519. */
  59520. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59521. /**
  59522. * Returns a new Vector3 located at the center between "value1" and "value2"
  59523. * @param value1 defines the first operand
  59524. * @param value2 defines the second operand
  59525. * @returns the new Vector3
  59526. */
  59527. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  59528. /**
  59529. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  59530. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  59531. * to something in order to rotate it from its local system to the given target system
  59532. * Note: axis1, axis2 and axis3 are normalized during this operation
  59533. * @param axis1 defines the first axis
  59534. * @param axis2 defines the second axis
  59535. * @param axis3 defines the third axis
  59536. * @returns a new Vector3
  59537. */
  59538. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  59539. /**
  59540. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  59541. * @param axis1 defines the first axis
  59542. * @param axis2 defines the second axis
  59543. * @param axis3 defines the third axis
  59544. * @param ref defines the Vector3 where to store the result
  59545. */
  59546. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  59547. }
  59548. /**
  59549. * Vector4 class created for EulerAngle class conversion to Quaternion
  59550. */
  59551. export class Vector4 {
  59552. /** x value of the vector */
  59553. x: number;
  59554. /** y value of the vector */
  59555. y: number;
  59556. /** z value of the vector */
  59557. z: number;
  59558. /** w value of the vector */
  59559. w: number;
  59560. /**
  59561. * Creates a Vector4 object from the given floats.
  59562. * @param x x value of the vector
  59563. * @param y y value of the vector
  59564. * @param z z value of the vector
  59565. * @param w w value of the vector
  59566. */
  59567. constructor(
  59568. /** x value of the vector */
  59569. x: number,
  59570. /** y value of the vector */
  59571. y: number,
  59572. /** z value of the vector */
  59573. z: number,
  59574. /** w value of the vector */
  59575. w: number);
  59576. /**
  59577. * Returns the string with the Vector4 coordinates.
  59578. * @returns a string containing all the vector values
  59579. */
  59580. toString(): string;
  59581. /**
  59582. * Returns the string "Vector4".
  59583. * @returns "Vector4"
  59584. */
  59585. getClassName(): string;
  59586. /**
  59587. * Returns the Vector4 hash code.
  59588. * @returns a unique hash code
  59589. */
  59590. getHashCode(): number;
  59591. /**
  59592. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  59593. * @returns the resulting array
  59594. */
  59595. asArray(): number[];
  59596. /**
  59597. * Populates the given array from the given index with the Vector4 coordinates.
  59598. * @param array array to populate
  59599. * @param index index of the array to start at (default: 0)
  59600. * @returns the Vector4.
  59601. */
  59602. toArray(array: FloatArray, index?: number): Vector4;
  59603. /**
  59604. * Adds the given vector to the current Vector4.
  59605. * @param otherVector the vector to add
  59606. * @returns the updated Vector4.
  59607. */
  59608. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59609. /**
  59610. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  59611. * @param otherVector the vector to add
  59612. * @returns the resulting vector
  59613. */
  59614. add(otherVector: DeepImmutable<Vector4>): Vector4;
  59615. /**
  59616. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  59617. * @param otherVector the vector to add
  59618. * @param result the vector to store the result
  59619. * @returns the current Vector4.
  59620. */
  59621. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59622. /**
  59623. * Subtract in place the given vector from the current Vector4.
  59624. * @param otherVector the vector to subtract
  59625. * @returns the updated Vector4.
  59626. */
  59627. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59628. /**
  59629. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  59630. * @param otherVector the vector to add
  59631. * @returns the new vector with the result
  59632. */
  59633. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  59634. /**
  59635. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  59636. * @param otherVector the vector to subtract
  59637. * @param result the vector to store the result
  59638. * @returns the current Vector4.
  59639. */
  59640. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59641. /**
  59642. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59643. */
  59644. /**
  59645. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59646. * @param x value to subtract
  59647. * @param y value to subtract
  59648. * @param z value to subtract
  59649. * @param w value to subtract
  59650. * @returns new vector containing the result
  59651. */
  59652. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59653. /**
  59654. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59655. * @param x value to subtract
  59656. * @param y value to subtract
  59657. * @param z value to subtract
  59658. * @param w value to subtract
  59659. * @param result the vector to store the result in
  59660. * @returns the current Vector4.
  59661. */
  59662. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  59663. /**
  59664. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  59665. * @returns a new vector with the negated values
  59666. */
  59667. negate(): Vector4;
  59668. /**
  59669. * Multiplies the current Vector4 coordinates by scale (float).
  59670. * @param scale the number to scale with
  59671. * @returns the updated Vector4.
  59672. */
  59673. scaleInPlace(scale: number): Vector4;
  59674. /**
  59675. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  59676. * @param scale the number to scale with
  59677. * @returns a new vector with the result
  59678. */
  59679. scale(scale: number): Vector4;
  59680. /**
  59681. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  59682. * @param scale the number to scale with
  59683. * @param result a vector to store the result in
  59684. * @returns the current Vector4.
  59685. */
  59686. scaleToRef(scale: number, result: Vector4): Vector4;
  59687. /**
  59688. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  59689. * @param scale defines the scale factor
  59690. * @param result defines the Vector4 object where to store the result
  59691. * @returns the unmodified current Vector4
  59692. */
  59693. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  59694. /**
  59695. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  59696. * @param otherVector the vector to compare against
  59697. * @returns true if they are equal
  59698. */
  59699. equals(otherVector: DeepImmutable<Vector4>): boolean;
  59700. /**
  59701. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  59702. * @param otherVector vector to compare against
  59703. * @param epsilon (Default: very small number)
  59704. * @returns true if they are equal
  59705. */
  59706. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  59707. /**
  59708. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  59709. * @param x x value to compare against
  59710. * @param y y value to compare against
  59711. * @param z z value to compare against
  59712. * @param w w value to compare against
  59713. * @returns true if equal
  59714. */
  59715. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  59716. /**
  59717. * Multiplies in place the current Vector4 by the given one.
  59718. * @param otherVector vector to multiple with
  59719. * @returns the updated Vector4.
  59720. */
  59721. multiplyInPlace(otherVector: Vector4): Vector4;
  59722. /**
  59723. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  59724. * @param otherVector vector to multiple with
  59725. * @returns resulting new vector
  59726. */
  59727. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  59728. /**
  59729. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  59730. * @param otherVector vector to multiple with
  59731. * @param result vector to store the result
  59732. * @returns the current Vector4.
  59733. */
  59734. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59735. /**
  59736. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  59737. * @param x x value multiply with
  59738. * @param y y value multiply with
  59739. * @param z z value multiply with
  59740. * @param w w value multiply with
  59741. * @returns resulting new vector
  59742. */
  59743. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  59744. /**
  59745. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  59746. * @param otherVector vector to devide with
  59747. * @returns resulting new vector
  59748. */
  59749. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  59750. /**
  59751. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  59752. * @param otherVector vector to devide with
  59753. * @param result vector to store the result
  59754. * @returns the current Vector4.
  59755. */
  59756. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59757. /**
  59758. * Divides the current Vector3 coordinates by the given ones.
  59759. * @param otherVector vector to devide with
  59760. * @returns the updated Vector3.
  59761. */
  59762. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59763. /**
  59764. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  59765. * @param other defines the second operand
  59766. * @returns the current updated Vector4
  59767. */
  59768. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59769. /**
  59770. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  59771. * @param other defines the second operand
  59772. * @returns the current updated Vector4
  59773. */
  59774. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59775. /**
  59776. * Gets a new Vector4 from current Vector4 floored values
  59777. * @returns a new Vector4
  59778. */
  59779. floor(): Vector4;
  59780. /**
  59781. * Gets a new Vector4 from current Vector3 floored values
  59782. * @returns a new Vector4
  59783. */
  59784. fract(): Vector4;
  59785. /**
  59786. * Returns the Vector4 length (float).
  59787. * @returns the length
  59788. */
  59789. length(): number;
  59790. /**
  59791. * Returns the Vector4 squared length (float).
  59792. * @returns the length squared
  59793. */
  59794. lengthSquared(): number;
  59795. /**
  59796. * Normalizes in place the Vector4.
  59797. * @returns the updated Vector4.
  59798. */
  59799. normalize(): Vector4;
  59800. /**
  59801. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  59802. * @returns this converted to a new vector3
  59803. */
  59804. toVector3(): Vector3;
  59805. /**
  59806. * Returns a new Vector4 copied from the current one.
  59807. * @returns the new cloned vector
  59808. */
  59809. clone(): Vector4;
  59810. /**
  59811. * Updates the current Vector4 with the given one coordinates.
  59812. * @param source the source vector to copy from
  59813. * @returns the updated Vector4.
  59814. */
  59815. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  59816. /**
  59817. * Updates the current Vector4 coordinates with the given floats.
  59818. * @param x float to copy from
  59819. * @param y float to copy from
  59820. * @param z float to copy from
  59821. * @param w float to copy from
  59822. * @returns the updated Vector4.
  59823. */
  59824. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59825. /**
  59826. * Updates the current Vector4 coordinates with the given floats.
  59827. * @param x float to set from
  59828. * @param y float to set from
  59829. * @param z float to set from
  59830. * @param w float to set from
  59831. * @returns the updated Vector4.
  59832. */
  59833. set(x: number, y: number, z: number, w: number): Vector4;
  59834. /**
  59835. * Copies the given float to the current Vector3 coordinates
  59836. * @param v defines the x, y, z and w coordinates of the operand
  59837. * @returns the current updated Vector3
  59838. */
  59839. setAll(v: number): Vector4;
  59840. /**
  59841. * Returns a new Vector4 set from the starting index of the given array.
  59842. * @param array the array to pull values from
  59843. * @param offset the offset into the array to start at
  59844. * @returns the new vector
  59845. */
  59846. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  59847. /**
  59848. * Updates the given vector "result" from the starting index of the given array.
  59849. * @param array the array to pull values from
  59850. * @param offset the offset into the array to start at
  59851. * @param result the vector to store the result in
  59852. */
  59853. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  59854. /**
  59855. * Updates the given vector "result" from the starting index of the given Float32Array.
  59856. * @param array the array to pull values from
  59857. * @param offset the offset into the array to start at
  59858. * @param result the vector to store the result in
  59859. */
  59860. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  59861. /**
  59862. * Updates the given vector "result" coordinates from the given floats.
  59863. * @param x float to set from
  59864. * @param y float to set from
  59865. * @param z float to set from
  59866. * @param w float to set from
  59867. * @param result the vector to the floats in
  59868. */
  59869. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  59870. /**
  59871. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  59872. * @returns the new vector
  59873. */
  59874. static Zero(): Vector4;
  59875. /**
  59876. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  59877. * @returns the new vector
  59878. */
  59879. static One(): Vector4;
  59880. /**
  59881. * Returns a new normalized Vector4 from the given one.
  59882. * @param vector the vector to normalize
  59883. * @returns the vector
  59884. */
  59885. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  59886. /**
  59887. * Updates the given vector "result" from the normalization of the given one.
  59888. * @param vector the vector to normalize
  59889. * @param result the vector to store the result in
  59890. */
  59891. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  59892. /**
  59893. * Returns a vector with the minimum values from the left and right vectors
  59894. * @param left left vector to minimize
  59895. * @param right right vector to minimize
  59896. * @returns a new vector with the minimum of the left and right vector values
  59897. */
  59898. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59899. /**
  59900. * Returns a vector with the maximum values from the left and right vectors
  59901. * @param left left vector to maximize
  59902. * @param right right vector to maximize
  59903. * @returns a new vector with the maximum of the left and right vector values
  59904. */
  59905. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59906. /**
  59907. * Returns the distance (float) between the vectors "value1" and "value2".
  59908. * @param value1 value to calulate the distance between
  59909. * @param value2 value to calulate the distance between
  59910. * @return the distance between the two vectors
  59911. */
  59912. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59913. /**
  59914. * Returns the squared distance (float) between the vectors "value1" and "value2".
  59915. * @param value1 value to calulate the distance between
  59916. * @param value2 value to calulate the distance between
  59917. * @return the distance between the two vectors squared
  59918. */
  59919. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59920. /**
  59921. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  59922. * @param value1 value to calulate the center between
  59923. * @param value2 value to calulate the center between
  59924. * @return the center between the two vectors
  59925. */
  59926. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  59927. /**
  59928. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  59929. * This methods computes transformed normalized direction vectors only.
  59930. * @param vector the vector to transform
  59931. * @param transformation the transformation matrix to apply
  59932. * @returns the new vector
  59933. */
  59934. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  59935. /**
  59936. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  59937. * This methods computes transformed normalized direction vectors only.
  59938. * @param vector the vector to transform
  59939. * @param transformation the transformation matrix to apply
  59940. * @param result the vector to store the result in
  59941. */
  59942. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59943. /**
  59944. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  59945. * This methods computes transformed normalized direction vectors only.
  59946. * @param x value to transform
  59947. * @param y value to transform
  59948. * @param z value to transform
  59949. * @param w value to transform
  59950. * @param transformation the transformation matrix to apply
  59951. * @param result the vector to store the results in
  59952. */
  59953. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59954. /**
  59955. * Creates a new Vector4 from a Vector3
  59956. * @param source defines the source data
  59957. * @param w defines the 4th component (default is 0)
  59958. * @returns a new Vector4
  59959. */
  59960. static FromVector3(source: Vector3, w?: number): Vector4;
  59961. }
  59962. /**
  59963. * Interface for the size containing width and height
  59964. */
  59965. export interface ISize {
  59966. /**
  59967. * Width
  59968. */
  59969. width: number;
  59970. /**
  59971. * Heighht
  59972. */
  59973. height: number;
  59974. }
  59975. /**
  59976. * Size containing widht and height
  59977. */
  59978. export class Size implements ISize {
  59979. /**
  59980. * Width
  59981. */
  59982. width: number;
  59983. /**
  59984. * Height
  59985. */
  59986. height: number;
  59987. /**
  59988. * Creates a Size object from the given width and height (floats).
  59989. * @param width width of the new size
  59990. * @param height height of the new size
  59991. */
  59992. constructor(width: number, height: number);
  59993. /**
  59994. * Returns a string with the Size width and height
  59995. * @returns a string with the Size width and height
  59996. */
  59997. toString(): string;
  59998. /**
  59999. * "Size"
  60000. * @returns the string "Size"
  60001. */
  60002. getClassName(): string;
  60003. /**
  60004. * Returns the Size hash code.
  60005. * @returns a hash code for a unique width and height
  60006. */
  60007. getHashCode(): number;
  60008. /**
  60009. * Updates the current size from the given one.
  60010. * @param src the given size
  60011. */
  60012. copyFrom(src: Size): void;
  60013. /**
  60014. * Updates in place the current Size from the given floats.
  60015. * @param width width of the new size
  60016. * @param height height of the new size
  60017. * @returns the updated Size.
  60018. */
  60019. copyFromFloats(width: number, height: number): Size;
  60020. /**
  60021. * Updates in place the current Size from the given floats.
  60022. * @param width width to set
  60023. * @param height height to set
  60024. * @returns the updated Size.
  60025. */
  60026. set(width: number, height: number): Size;
  60027. /**
  60028. * Multiplies the width and height by numbers
  60029. * @param w factor to multiple the width by
  60030. * @param h factor to multiple the height by
  60031. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  60032. */
  60033. multiplyByFloats(w: number, h: number): Size;
  60034. /**
  60035. * Clones the size
  60036. * @returns a new Size copied from the given one.
  60037. */
  60038. clone(): Size;
  60039. /**
  60040. * True if the current Size and the given one width and height are strictly equal.
  60041. * @param other the other size to compare against
  60042. * @returns True if the current Size and the given one width and height are strictly equal.
  60043. */
  60044. equals(other: Size): boolean;
  60045. /**
  60046. * The surface of the Size : width * height (float).
  60047. */
  60048. readonly surface: number;
  60049. /**
  60050. * Create a new size of zero
  60051. * @returns a new Size set to (0.0, 0.0)
  60052. */
  60053. static Zero(): Size;
  60054. /**
  60055. * Sums the width and height of two sizes
  60056. * @param otherSize size to add to this size
  60057. * @returns a new Size set as the addition result of the current Size and the given one.
  60058. */
  60059. add(otherSize: Size): Size;
  60060. /**
  60061. * Subtracts the width and height of two
  60062. * @param otherSize size to subtract to this size
  60063. * @returns a new Size set as the subtraction result of the given one from the current Size.
  60064. */
  60065. subtract(otherSize: Size): Size;
  60066. /**
  60067. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  60068. * @param start starting size to lerp between
  60069. * @param end end size to lerp between
  60070. * @param amount amount to lerp between the start and end values
  60071. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  60072. */
  60073. static Lerp(start: Size, end: Size, amount: number): Size;
  60074. }
  60075. /**
  60076. * Class used to store quaternion data
  60077. * @see https://en.wikipedia.org/wiki/Quaternion
  60078. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  60079. */
  60080. export class Quaternion {
  60081. /** defines the first component (0 by default) */
  60082. x: number;
  60083. /** defines the second component (0 by default) */
  60084. y: number;
  60085. /** defines the third component (0 by default) */
  60086. z: number;
  60087. /** defines the fourth component (1.0 by default) */
  60088. w: number;
  60089. /**
  60090. * Creates a new Quaternion from the given floats
  60091. * @param x defines the first component (0 by default)
  60092. * @param y defines the second component (0 by default)
  60093. * @param z defines the third component (0 by default)
  60094. * @param w defines the fourth component (1.0 by default)
  60095. */
  60096. constructor(
  60097. /** defines the first component (0 by default) */
  60098. x?: number,
  60099. /** defines the second component (0 by default) */
  60100. y?: number,
  60101. /** defines the third component (0 by default) */
  60102. z?: number,
  60103. /** defines the fourth component (1.0 by default) */
  60104. w?: number);
  60105. /**
  60106. * Gets a string representation for the current quaternion
  60107. * @returns a string with the Quaternion coordinates
  60108. */
  60109. toString(): string;
  60110. /**
  60111. * Gets the class name of the quaternion
  60112. * @returns the string "Quaternion"
  60113. */
  60114. getClassName(): string;
  60115. /**
  60116. * Gets a hash code for this quaternion
  60117. * @returns the quaternion hash code
  60118. */
  60119. getHashCode(): number;
  60120. /**
  60121. * Copy the quaternion to an array
  60122. * @returns a new array populated with 4 elements from the quaternion coordinates
  60123. */
  60124. asArray(): number[];
  60125. /**
  60126. * Check if two quaternions are equals
  60127. * @param otherQuaternion defines the second operand
  60128. * @return true if the current quaternion and the given one coordinates are strictly equals
  60129. */
  60130. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  60131. /**
  60132. * Clone the current quaternion
  60133. * @returns a new quaternion copied from the current one
  60134. */
  60135. clone(): Quaternion;
  60136. /**
  60137. * Copy a quaternion to the current one
  60138. * @param other defines the other quaternion
  60139. * @returns the updated current quaternion
  60140. */
  60141. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  60142. /**
  60143. * Updates the current quaternion with the given float coordinates
  60144. * @param x defines the x coordinate
  60145. * @param y defines the y coordinate
  60146. * @param z defines the z coordinate
  60147. * @param w defines the w coordinate
  60148. * @returns the updated current quaternion
  60149. */
  60150. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  60151. /**
  60152. * Updates the current quaternion from the given float coordinates
  60153. * @param x defines the x coordinate
  60154. * @param y defines the y coordinate
  60155. * @param z defines the z coordinate
  60156. * @param w defines the w coordinate
  60157. * @returns the updated current quaternion
  60158. */
  60159. set(x: number, y: number, z: number, w: number): Quaternion;
  60160. /**
  60161. * Adds two quaternions
  60162. * @param other defines the second operand
  60163. * @returns a new quaternion as the addition result of the given one and the current quaternion
  60164. */
  60165. add(other: DeepImmutable<Quaternion>): Quaternion;
  60166. /**
  60167. * Add a quaternion to the current one
  60168. * @param other defines the quaternion to add
  60169. * @returns the current quaternion
  60170. */
  60171. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  60172. /**
  60173. * Subtract two quaternions
  60174. * @param other defines the second operand
  60175. * @returns a new quaternion as the subtraction result of the given one from the current one
  60176. */
  60177. subtract(other: Quaternion): Quaternion;
  60178. /**
  60179. * Multiplies the current quaternion by a scale factor
  60180. * @param value defines the scale factor
  60181. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  60182. */
  60183. scale(value: number): Quaternion;
  60184. /**
  60185. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  60186. * @param scale defines the scale factor
  60187. * @param result defines the Quaternion object where to store the result
  60188. * @returns the unmodified current quaternion
  60189. */
  60190. scaleToRef(scale: number, result: Quaternion): Quaternion;
  60191. /**
  60192. * Multiplies in place the current quaternion by a scale factor
  60193. * @param value defines the scale factor
  60194. * @returns the current modified quaternion
  60195. */
  60196. scaleInPlace(value: number): Quaternion;
  60197. /**
  60198. * Scale the current quaternion values by a factor and add the result to a given quaternion
  60199. * @param scale defines the scale factor
  60200. * @param result defines the Quaternion object where to store the result
  60201. * @returns the unmodified current quaternion
  60202. */
  60203. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  60204. /**
  60205. * Multiplies two quaternions
  60206. * @param q1 defines the second operand
  60207. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  60208. */
  60209. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  60210. /**
  60211. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  60212. * @param q1 defines the second operand
  60213. * @param result defines the target quaternion
  60214. * @returns the current quaternion
  60215. */
  60216. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  60217. /**
  60218. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  60219. * @param q1 defines the second operand
  60220. * @returns the currentupdated quaternion
  60221. */
  60222. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  60223. /**
  60224. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  60225. * @param ref defines the target quaternion
  60226. * @returns the current quaternion
  60227. */
  60228. conjugateToRef(ref: Quaternion): Quaternion;
  60229. /**
  60230. * Conjugates in place (1-q) the current quaternion
  60231. * @returns the current updated quaternion
  60232. */
  60233. conjugateInPlace(): Quaternion;
  60234. /**
  60235. * Conjugates in place (1-q) the current quaternion
  60236. * @returns a new quaternion
  60237. */
  60238. conjugate(): Quaternion;
  60239. /**
  60240. * Gets length of current quaternion
  60241. * @returns the quaternion length (float)
  60242. */
  60243. length(): number;
  60244. /**
  60245. * Normalize in place the current quaternion
  60246. * @returns the current updated quaternion
  60247. */
  60248. normalize(): Quaternion;
  60249. /**
  60250. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  60251. * @param order is a reserved parameter and is ignore for now
  60252. * @returns a new Vector3 containing the Euler angles
  60253. */
  60254. toEulerAngles(order?: string): Vector3;
  60255. /**
  60256. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  60257. * @param result defines the vector which will be filled with the Euler angles
  60258. * @param order is a reserved parameter and is ignore for now
  60259. * @returns the current unchanged quaternion
  60260. */
  60261. toEulerAnglesToRef(result: Vector3): Quaternion;
  60262. /**
  60263. * Updates the given rotation matrix with the current quaternion values
  60264. * @param result defines the target matrix
  60265. * @returns the current unchanged quaternion
  60266. */
  60267. toRotationMatrix(result: Matrix): Quaternion;
  60268. /**
  60269. * Updates the current quaternion from the given rotation matrix values
  60270. * @param matrix defines the source matrix
  60271. * @returns the current updated quaternion
  60272. */
  60273. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60274. /**
  60275. * Creates a new quaternion from a rotation matrix
  60276. * @param matrix defines the source matrix
  60277. * @returns a new quaternion created from the given rotation matrix values
  60278. */
  60279. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60280. /**
  60281. * Updates the given quaternion with the given rotation matrix values
  60282. * @param matrix defines the source matrix
  60283. * @param result defines the target quaternion
  60284. */
  60285. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  60286. /**
  60287. * Returns the dot product (float) between the quaternions "left" and "right"
  60288. * @param left defines the left operand
  60289. * @param right defines the right operand
  60290. * @returns the dot product
  60291. */
  60292. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  60293. /**
  60294. * Checks if the two quaternions are close to each other
  60295. * @param quat0 defines the first quaternion to check
  60296. * @param quat1 defines the second quaternion to check
  60297. * @returns true if the two quaternions are close to each other
  60298. */
  60299. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  60300. /**
  60301. * Creates an empty quaternion
  60302. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  60303. */
  60304. static Zero(): Quaternion;
  60305. /**
  60306. * Inverse a given quaternion
  60307. * @param q defines the source quaternion
  60308. * @returns a new quaternion as the inverted current quaternion
  60309. */
  60310. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  60311. /**
  60312. * Inverse a given quaternion
  60313. * @param q defines the source quaternion
  60314. * @param result the quaternion the result will be stored in
  60315. * @returns the result quaternion
  60316. */
  60317. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  60318. /**
  60319. * Creates an identity quaternion
  60320. * @returns the identity quaternion
  60321. */
  60322. static Identity(): Quaternion;
  60323. /**
  60324. * Gets a boolean indicating if the given quaternion is identity
  60325. * @param quaternion defines the quaternion to check
  60326. * @returns true if the quaternion is identity
  60327. */
  60328. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  60329. /**
  60330. * Creates a quaternion from a rotation around an axis
  60331. * @param axis defines the axis to use
  60332. * @param angle defines the angle to use
  60333. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  60334. */
  60335. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  60336. /**
  60337. * Creates a rotation around an axis and stores it into the given quaternion
  60338. * @param axis defines the axis to use
  60339. * @param angle defines the angle to use
  60340. * @param result defines the target quaternion
  60341. * @returns the target quaternion
  60342. */
  60343. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  60344. /**
  60345. * Creates a new quaternion from data stored into an array
  60346. * @param array defines the data source
  60347. * @param offset defines the offset in the source array where the data starts
  60348. * @returns a new quaternion
  60349. */
  60350. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  60351. /**
  60352. * Create a quaternion from Euler rotation angles
  60353. * @param x Pitch
  60354. * @param y Yaw
  60355. * @param z Roll
  60356. * @returns the new Quaternion
  60357. */
  60358. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  60359. /**
  60360. * Updates a quaternion from Euler rotation angles
  60361. * @param x Pitch
  60362. * @param y Yaw
  60363. * @param z Roll
  60364. * @param result the quaternion to store the result
  60365. * @returns the updated quaternion
  60366. */
  60367. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  60368. /**
  60369. * Create a quaternion from Euler rotation vector
  60370. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60371. * @returns the new Quaternion
  60372. */
  60373. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  60374. /**
  60375. * Updates a quaternion from Euler rotation vector
  60376. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60377. * @param result the quaternion to store the result
  60378. * @returns the updated quaternion
  60379. */
  60380. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  60381. /**
  60382. * Creates a new quaternion from the given Euler float angles (y, x, z)
  60383. * @param yaw defines the rotation around Y axis
  60384. * @param pitch defines the rotation around X axis
  60385. * @param roll defines the rotation around Z axis
  60386. * @returns the new quaternion
  60387. */
  60388. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  60389. /**
  60390. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  60391. * @param yaw defines the rotation around Y axis
  60392. * @param pitch defines the rotation around X axis
  60393. * @param roll defines the rotation around Z axis
  60394. * @param result defines the target quaternion
  60395. */
  60396. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  60397. /**
  60398. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  60399. * @param alpha defines the rotation around first axis
  60400. * @param beta defines the rotation around second axis
  60401. * @param gamma defines the rotation around third axis
  60402. * @returns the new quaternion
  60403. */
  60404. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  60405. /**
  60406. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  60407. * @param alpha defines the rotation around first axis
  60408. * @param beta defines the rotation around second axis
  60409. * @param gamma defines the rotation around third axis
  60410. * @param result defines the target quaternion
  60411. */
  60412. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  60413. /**
  60414. * 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)
  60415. * @param axis1 defines the first axis
  60416. * @param axis2 defines the second axis
  60417. * @param axis3 defines the third axis
  60418. * @returns the new quaternion
  60419. */
  60420. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  60421. /**
  60422. * 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
  60423. * @param axis1 defines the first axis
  60424. * @param axis2 defines the second axis
  60425. * @param axis3 defines the third axis
  60426. * @param ref defines the target quaternion
  60427. */
  60428. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  60429. /**
  60430. * Interpolates between two quaternions
  60431. * @param left defines first quaternion
  60432. * @param right defines second quaternion
  60433. * @param amount defines the gradient to use
  60434. * @returns the new interpolated quaternion
  60435. */
  60436. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60437. /**
  60438. * Interpolates between two quaternions and stores it into a target quaternion
  60439. * @param left defines first quaternion
  60440. * @param right defines second quaternion
  60441. * @param amount defines the gradient to use
  60442. * @param result defines the target quaternion
  60443. */
  60444. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  60445. /**
  60446. * Interpolate between two quaternions using Hermite interpolation
  60447. * @param value1 defines first quaternion
  60448. * @param tangent1 defines the incoming tangent
  60449. * @param value2 defines second quaternion
  60450. * @param tangent2 defines the outgoing tangent
  60451. * @param amount defines the target quaternion
  60452. * @returns the new interpolated quaternion
  60453. */
  60454. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60455. }
  60456. /**
  60457. * Class used to store matrix data (4x4)
  60458. */
  60459. export class Matrix {
  60460. private static _updateFlagSeed;
  60461. private static _identityReadOnly;
  60462. private _isIdentity;
  60463. private _isIdentityDirty;
  60464. private _isIdentity3x2;
  60465. private _isIdentity3x2Dirty;
  60466. /**
  60467. * Gets the update flag of the matrix which is an unique number for the matrix.
  60468. * It will be incremented every time the matrix data change.
  60469. * You can use it to speed the comparison between two versions of the same matrix.
  60470. */
  60471. updateFlag: number;
  60472. private readonly _m;
  60473. /**
  60474. * Gets the internal data of the matrix
  60475. */
  60476. readonly m: DeepImmutable<Float32Array>;
  60477. /** @hidden */
  60478. _markAsUpdated(): void;
  60479. /** @hidden */
  60480. private _updateIdentityStatus;
  60481. /**
  60482. * Creates an empty matrix (filled with zeros)
  60483. */
  60484. constructor();
  60485. /**
  60486. * Check if the current matrix is identity
  60487. * @returns true is the matrix is the identity matrix
  60488. */
  60489. isIdentity(): boolean;
  60490. /**
  60491. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  60492. * @returns true is the matrix is the identity matrix
  60493. */
  60494. isIdentityAs3x2(): boolean;
  60495. /**
  60496. * Gets the determinant of the matrix
  60497. * @returns the matrix determinant
  60498. */
  60499. determinant(): number;
  60500. /**
  60501. * Returns the matrix as a Float32Array
  60502. * @returns the matrix underlying array
  60503. */
  60504. toArray(): DeepImmutable<Float32Array>;
  60505. /**
  60506. * Returns the matrix as a Float32Array
  60507. * @returns the matrix underlying array.
  60508. */
  60509. asArray(): DeepImmutable<Float32Array>;
  60510. /**
  60511. * Inverts the current matrix in place
  60512. * @returns the current inverted matrix
  60513. */
  60514. invert(): Matrix;
  60515. /**
  60516. * Sets all the matrix elements to zero
  60517. * @returns the current matrix
  60518. */
  60519. reset(): Matrix;
  60520. /**
  60521. * Adds the current matrix with a second one
  60522. * @param other defines the matrix to add
  60523. * @returns a new matrix as the addition of the current matrix and the given one
  60524. */
  60525. add(other: DeepImmutable<Matrix>): Matrix;
  60526. /**
  60527. * Sets the given matrix "result" to the addition of the current matrix and the given one
  60528. * @param other defines the matrix to add
  60529. * @param result defines the target matrix
  60530. * @returns the current matrix
  60531. */
  60532. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60533. /**
  60534. * Adds in place the given matrix to the current matrix
  60535. * @param other defines the second operand
  60536. * @returns the current updated matrix
  60537. */
  60538. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  60539. /**
  60540. * Sets the given matrix to the current inverted Matrix
  60541. * @param other defines the target matrix
  60542. * @returns the unmodified current matrix
  60543. */
  60544. invertToRef(other: Matrix): Matrix;
  60545. /**
  60546. * add a value at the specified position in the current Matrix
  60547. * @param index the index of the value within the matrix. between 0 and 15.
  60548. * @param value the value to be added
  60549. * @returns the current updated matrix
  60550. */
  60551. addAtIndex(index: number, value: number): Matrix;
  60552. /**
  60553. * mutiply the specified position in the current Matrix by a value
  60554. * @param index the index of the value within the matrix. between 0 and 15.
  60555. * @param value the value to be added
  60556. * @returns the current updated matrix
  60557. */
  60558. multiplyAtIndex(index: number, value: number): Matrix;
  60559. /**
  60560. * Inserts the translation vector (using 3 floats) in the current matrix
  60561. * @param x defines the 1st component of the translation
  60562. * @param y defines the 2nd component of the translation
  60563. * @param z defines the 3rd component of the translation
  60564. * @returns the current updated matrix
  60565. */
  60566. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  60567. /**
  60568. * Inserts the translation vector in the current matrix
  60569. * @param vector3 defines the translation to insert
  60570. * @returns the current updated matrix
  60571. */
  60572. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  60573. /**
  60574. * Gets the translation value of the current matrix
  60575. * @returns a new Vector3 as the extracted translation from the matrix
  60576. */
  60577. getTranslation(): Vector3;
  60578. /**
  60579. * Fill a Vector3 with the extracted translation from the matrix
  60580. * @param result defines the Vector3 where to store the translation
  60581. * @returns the current matrix
  60582. */
  60583. getTranslationToRef(result: Vector3): Matrix;
  60584. /**
  60585. * Remove rotation and scaling part from the matrix
  60586. * @returns the updated matrix
  60587. */
  60588. removeRotationAndScaling(): Matrix;
  60589. /**
  60590. * Multiply two matrices
  60591. * @param other defines the second operand
  60592. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  60593. */
  60594. multiply(other: DeepImmutable<Matrix>): Matrix;
  60595. /**
  60596. * Copy the current matrix from the given one
  60597. * @param other defines the source matrix
  60598. * @returns the current updated matrix
  60599. */
  60600. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  60601. /**
  60602. * Populates the given array from the starting index with the current matrix values
  60603. * @param array defines the target array
  60604. * @param offset defines the offset in the target array where to start storing values
  60605. * @returns the current matrix
  60606. */
  60607. copyToArray(array: Float32Array, offset?: number): Matrix;
  60608. /**
  60609. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  60610. * @param other defines the second operand
  60611. * @param result defines the matrix where to store the multiplication
  60612. * @returns the current matrix
  60613. */
  60614. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60615. /**
  60616. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  60617. * @param other defines the second operand
  60618. * @param result defines the array where to store the multiplication
  60619. * @param offset defines the offset in the target array where to start storing values
  60620. * @returns the current matrix
  60621. */
  60622. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  60623. /**
  60624. * Check equality between this matrix and a second one
  60625. * @param value defines the second matrix to compare
  60626. * @returns true is the current matrix and the given one values are strictly equal
  60627. */
  60628. equals(value: DeepImmutable<Matrix>): boolean;
  60629. /**
  60630. * Clone the current matrix
  60631. * @returns a new matrix from the current matrix
  60632. */
  60633. clone(): Matrix;
  60634. /**
  60635. * Returns the name of the current matrix class
  60636. * @returns the string "Matrix"
  60637. */
  60638. getClassName(): string;
  60639. /**
  60640. * Gets the hash code of the current matrix
  60641. * @returns the hash code
  60642. */
  60643. getHashCode(): number;
  60644. /**
  60645. * Decomposes the current Matrix into a translation, rotation and scaling components
  60646. * @param scale defines the scale vector3 given as a reference to update
  60647. * @param rotation defines the rotation quaternion given as a reference to update
  60648. * @param translation defines the translation vector3 given as a reference to update
  60649. * @returns true if operation was successful
  60650. */
  60651. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  60652. /**
  60653. * Gets specific row of the matrix
  60654. * @param index defines the number of the row to get
  60655. * @returns the index-th row of the current matrix as a new Vector4
  60656. */
  60657. getRow(index: number): Nullable<Vector4>;
  60658. /**
  60659. * Sets the index-th row of the current matrix to the vector4 values
  60660. * @param index defines the number of the row to set
  60661. * @param row defines the target vector4
  60662. * @returns the updated current matrix
  60663. */
  60664. setRow(index: number, row: Vector4): Matrix;
  60665. /**
  60666. * Compute the transpose of the matrix
  60667. * @returns the new transposed matrix
  60668. */
  60669. transpose(): Matrix;
  60670. /**
  60671. * Compute the transpose of the matrix and store it in a given matrix
  60672. * @param result defines the target matrix
  60673. * @returns the current matrix
  60674. */
  60675. transposeToRef(result: Matrix): Matrix;
  60676. /**
  60677. * Sets the index-th row of the current matrix with the given 4 x float values
  60678. * @param index defines the row index
  60679. * @param x defines the x component to set
  60680. * @param y defines the y component to set
  60681. * @param z defines the z component to set
  60682. * @param w defines the w component to set
  60683. * @returns the updated current matrix
  60684. */
  60685. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  60686. /**
  60687. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  60688. * @param scale defines the scale factor
  60689. * @returns a new matrix
  60690. */
  60691. scale(scale: number): Matrix;
  60692. /**
  60693. * Scale the current matrix values by a factor to a given result matrix
  60694. * @param scale defines the scale factor
  60695. * @param result defines the matrix to store the result
  60696. * @returns the current matrix
  60697. */
  60698. scaleToRef(scale: number, result: Matrix): Matrix;
  60699. /**
  60700. * Scale the current matrix values by a factor and add the result to a given matrix
  60701. * @param scale defines the scale factor
  60702. * @param result defines the Matrix to store the result
  60703. * @returns the current matrix
  60704. */
  60705. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  60706. /**
  60707. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  60708. * @param ref matrix to store the result
  60709. */
  60710. toNormalMatrix(ref: Matrix): void;
  60711. /**
  60712. * Gets only rotation part of the current matrix
  60713. * @returns a new matrix sets to the extracted rotation matrix from the current one
  60714. */
  60715. getRotationMatrix(): Matrix;
  60716. /**
  60717. * Extracts the rotation matrix from the current one and sets it as the given "result"
  60718. * @param result defines the target matrix to store data to
  60719. * @returns the current matrix
  60720. */
  60721. getRotationMatrixToRef(result: Matrix): Matrix;
  60722. /**
  60723. * Toggles model matrix from being right handed to left handed in place and vice versa
  60724. */
  60725. toggleModelMatrixHandInPlace(): void;
  60726. /**
  60727. * Toggles projection matrix from being right handed to left handed in place and vice versa
  60728. */
  60729. toggleProjectionMatrixHandInPlace(): void;
  60730. /**
  60731. * Creates a matrix from an array
  60732. * @param array defines the source array
  60733. * @param offset defines an offset in the source array
  60734. * @returns a new Matrix set from the starting index of the given array
  60735. */
  60736. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  60737. /**
  60738. * Copy the content of an array into a given matrix
  60739. * @param array defines the source array
  60740. * @param offset defines an offset in the source array
  60741. * @param result defines the target matrix
  60742. */
  60743. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  60744. /**
  60745. * Stores an array into a matrix after having multiplied each component by a given factor
  60746. * @param array defines the source array
  60747. * @param offset defines the offset in the source array
  60748. * @param scale defines the scaling factor
  60749. * @param result defines the target matrix
  60750. */
  60751. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  60752. /**
  60753. * Gets an identity matrix that must not be updated
  60754. */
  60755. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  60756. /**
  60757. * Stores a list of values (16) inside a given matrix
  60758. * @param initialM11 defines 1st value of 1st row
  60759. * @param initialM12 defines 2nd value of 1st row
  60760. * @param initialM13 defines 3rd value of 1st row
  60761. * @param initialM14 defines 4th value of 1st row
  60762. * @param initialM21 defines 1st value of 2nd row
  60763. * @param initialM22 defines 2nd value of 2nd row
  60764. * @param initialM23 defines 3rd value of 2nd row
  60765. * @param initialM24 defines 4th value of 2nd row
  60766. * @param initialM31 defines 1st value of 3rd row
  60767. * @param initialM32 defines 2nd value of 3rd row
  60768. * @param initialM33 defines 3rd value of 3rd row
  60769. * @param initialM34 defines 4th value of 3rd row
  60770. * @param initialM41 defines 1st value of 4th row
  60771. * @param initialM42 defines 2nd value of 4th row
  60772. * @param initialM43 defines 3rd value of 4th row
  60773. * @param initialM44 defines 4th value of 4th row
  60774. * @param result defines the target matrix
  60775. */
  60776. 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;
  60777. /**
  60778. * Creates new matrix from a list of values (16)
  60779. * @param initialM11 defines 1st value of 1st row
  60780. * @param initialM12 defines 2nd value of 1st row
  60781. * @param initialM13 defines 3rd value of 1st row
  60782. * @param initialM14 defines 4th value of 1st row
  60783. * @param initialM21 defines 1st value of 2nd row
  60784. * @param initialM22 defines 2nd value of 2nd row
  60785. * @param initialM23 defines 3rd value of 2nd row
  60786. * @param initialM24 defines 4th value of 2nd row
  60787. * @param initialM31 defines 1st value of 3rd row
  60788. * @param initialM32 defines 2nd value of 3rd row
  60789. * @param initialM33 defines 3rd value of 3rd row
  60790. * @param initialM34 defines 4th value of 3rd row
  60791. * @param initialM41 defines 1st value of 4th row
  60792. * @param initialM42 defines 2nd value of 4th row
  60793. * @param initialM43 defines 3rd value of 4th row
  60794. * @param initialM44 defines 4th value of 4th row
  60795. * @returns the new matrix
  60796. */
  60797. 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;
  60798. /**
  60799. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60800. * @param scale defines the scale vector3
  60801. * @param rotation defines the rotation quaternion
  60802. * @param translation defines the translation vector3
  60803. * @returns a new matrix
  60804. */
  60805. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  60806. /**
  60807. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60808. * @param scale defines the scale vector3
  60809. * @param rotation defines the rotation quaternion
  60810. * @param translation defines the translation vector3
  60811. * @param result defines the target matrix
  60812. */
  60813. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  60814. /**
  60815. * Creates a new identity matrix
  60816. * @returns a new identity matrix
  60817. */
  60818. static Identity(): Matrix;
  60819. /**
  60820. * Creates a new identity matrix and stores the result in a given matrix
  60821. * @param result defines the target matrix
  60822. */
  60823. static IdentityToRef(result: Matrix): void;
  60824. /**
  60825. * Creates a new zero matrix
  60826. * @returns a new zero matrix
  60827. */
  60828. static Zero(): Matrix;
  60829. /**
  60830. * Creates a new rotation matrix for "angle" radians around the X axis
  60831. * @param angle defines the angle (in radians) to use
  60832. * @return the new matrix
  60833. */
  60834. static RotationX(angle: number): Matrix;
  60835. /**
  60836. * Creates a new matrix as the invert of a given matrix
  60837. * @param source defines the source matrix
  60838. * @returns the new matrix
  60839. */
  60840. static Invert(source: DeepImmutable<Matrix>): Matrix;
  60841. /**
  60842. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  60843. * @param angle defines the angle (in radians) to use
  60844. * @param result defines the target matrix
  60845. */
  60846. static RotationXToRef(angle: number, result: Matrix): void;
  60847. /**
  60848. * Creates a new rotation matrix for "angle" radians around the Y axis
  60849. * @param angle defines the angle (in radians) to use
  60850. * @return the new matrix
  60851. */
  60852. static RotationY(angle: number): Matrix;
  60853. /**
  60854. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  60855. * @param angle defines the angle (in radians) to use
  60856. * @param result defines the target matrix
  60857. */
  60858. static RotationYToRef(angle: number, result: Matrix): void;
  60859. /**
  60860. * Creates a new rotation matrix for "angle" radians around the Z axis
  60861. * @param angle defines the angle (in radians) to use
  60862. * @return the new matrix
  60863. */
  60864. static RotationZ(angle: number): Matrix;
  60865. /**
  60866. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  60867. * @param angle defines the angle (in radians) to use
  60868. * @param result defines the target matrix
  60869. */
  60870. static RotationZToRef(angle: number, result: Matrix): void;
  60871. /**
  60872. * Creates a new rotation matrix for "angle" radians around the given axis
  60873. * @param axis defines the axis to use
  60874. * @param angle defines the angle (in radians) to use
  60875. * @return the new matrix
  60876. */
  60877. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  60878. /**
  60879. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  60880. * @param axis defines the axis to use
  60881. * @param angle defines the angle (in radians) to use
  60882. * @param result defines the target matrix
  60883. */
  60884. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  60885. /**
  60886. * Creates a rotation matrix
  60887. * @param yaw defines the yaw angle in radians (Y axis)
  60888. * @param pitch defines the pitch angle in radians (X axis)
  60889. * @param roll defines the roll angle in radians (X axis)
  60890. * @returns the new rotation matrix
  60891. */
  60892. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  60893. /**
  60894. * Creates a rotation matrix and stores it in a given matrix
  60895. * @param yaw defines the yaw angle in radians (Y axis)
  60896. * @param pitch defines the pitch angle in radians (X axis)
  60897. * @param roll defines the roll angle in radians (X axis)
  60898. * @param result defines the target matrix
  60899. */
  60900. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  60901. /**
  60902. * Creates a scaling matrix
  60903. * @param x defines the scale factor on X axis
  60904. * @param y defines the scale factor on Y axis
  60905. * @param z defines the scale factor on Z axis
  60906. * @returns the new matrix
  60907. */
  60908. static Scaling(x: number, y: number, z: number): Matrix;
  60909. /**
  60910. * Creates a scaling matrix and stores it in a given matrix
  60911. * @param x defines the scale factor on X axis
  60912. * @param y defines the scale factor on Y axis
  60913. * @param z defines the scale factor on Z axis
  60914. * @param result defines the target matrix
  60915. */
  60916. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  60917. /**
  60918. * Creates a translation matrix
  60919. * @param x defines the translation on X axis
  60920. * @param y defines the translation on Y axis
  60921. * @param z defines the translationon Z axis
  60922. * @returns the new matrix
  60923. */
  60924. static Translation(x: number, y: number, z: number): Matrix;
  60925. /**
  60926. * Creates a translation matrix and stores it in a given matrix
  60927. * @param x defines the translation on X axis
  60928. * @param y defines the translation on Y axis
  60929. * @param z defines the translationon Z axis
  60930. * @param result defines the target matrix
  60931. */
  60932. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  60933. /**
  60934. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60935. * @param startValue defines the start value
  60936. * @param endValue defines the end value
  60937. * @param gradient defines the gradient factor
  60938. * @returns the new matrix
  60939. */
  60940. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60941. /**
  60942. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60943. * @param startValue defines the start value
  60944. * @param endValue defines the end value
  60945. * @param gradient defines the gradient factor
  60946. * @param result defines the Matrix object where to store data
  60947. */
  60948. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60949. /**
  60950. * Builds a new matrix whose values are computed by:
  60951. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60952. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60953. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60954. * @param startValue defines the first matrix
  60955. * @param endValue defines the second matrix
  60956. * @param gradient defines the gradient between the two matrices
  60957. * @returns the new matrix
  60958. */
  60959. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60960. /**
  60961. * Update a matrix to values which are computed by:
  60962. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60963. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60964. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60965. * @param startValue defines the first matrix
  60966. * @param endValue defines the second matrix
  60967. * @param gradient defines the gradient between the two matrices
  60968. * @param result defines the target matrix
  60969. */
  60970. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60971. /**
  60972. * 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"
  60973. * This function works in left handed mode
  60974. * @param eye defines the final position of the entity
  60975. * @param target defines where the entity should look at
  60976. * @param up defines the up vector for the entity
  60977. * @returns the new matrix
  60978. */
  60979. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  60980. /**
  60981. * 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".
  60982. * This function works in left handed mode
  60983. * @param eye defines the final position of the entity
  60984. * @param target defines where the entity should look at
  60985. * @param up defines the up vector for the entity
  60986. * @param result defines the target matrix
  60987. */
  60988. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  60989. /**
  60990. * 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"
  60991. * This function works in right handed mode
  60992. * @param eye defines the final position of the entity
  60993. * @param target defines where the entity should look at
  60994. * @param up defines the up vector for the entity
  60995. * @returns the new matrix
  60996. */
  60997. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  60998. /**
  60999. * 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".
  61000. * This function works in right handed mode
  61001. * @param eye defines the final position of the entity
  61002. * @param target defines where the entity should look at
  61003. * @param up defines the up vector for the entity
  61004. * @param result defines the target matrix
  61005. */
  61006. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61007. /**
  61008. * Create a left-handed orthographic projection matrix
  61009. * @param width defines the viewport width
  61010. * @param height defines the viewport height
  61011. * @param znear defines the near clip plane
  61012. * @param zfar defines the far clip plane
  61013. * @returns a new matrix as a left-handed orthographic projection matrix
  61014. */
  61015. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61016. /**
  61017. * Store a left-handed orthographic projection to a given matrix
  61018. * @param width defines the viewport width
  61019. * @param height defines the viewport height
  61020. * @param znear defines the near clip plane
  61021. * @param zfar defines the far clip plane
  61022. * @param result defines the target matrix
  61023. */
  61024. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  61025. /**
  61026. * Create a left-handed orthographic projection matrix
  61027. * @param left defines the viewport left coordinate
  61028. * @param right defines the viewport right coordinate
  61029. * @param bottom defines the viewport bottom coordinate
  61030. * @param top defines the viewport top coordinate
  61031. * @param znear defines the near clip plane
  61032. * @param zfar defines the far clip plane
  61033. * @returns a new matrix as a left-handed orthographic projection matrix
  61034. */
  61035. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61036. /**
  61037. * Stores a left-handed orthographic projection into a given matrix
  61038. * @param left defines the viewport left coordinate
  61039. * @param right defines the viewport right coordinate
  61040. * @param bottom defines the viewport bottom coordinate
  61041. * @param top defines the viewport top coordinate
  61042. * @param znear defines the near clip plane
  61043. * @param zfar defines the far clip plane
  61044. * @param result defines the target matrix
  61045. */
  61046. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61047. /**
  61048. * Creates a right-handed orthographic projection matrix
  61049. * @param left defines the viewport left coordinate
  61050. * @param right defines the viewport right coordinate
  61051. * @param bottom defines the viewport bottom coordinate
  61052. * @param top defines the viewport top coordinate
  61053. * @param znear defines the near clip plane
  61054. * @param zfar defines the far clip plane
  61055. * @returns a new matrix as a right-handed orthographic projection matrix
  61056. */
  61057. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61058. /**
  61059. * Stores a right-handed orthographic projection into a given matrix
  61060. * @param left defines the viewport left coordinate
  61061. * @param right defines the viewport right coordinate
  61062. * @param bottom defines the viewport bottom coordinate
  61063. * @param top defines the viewport top coordinate
  61064. * @param znear defines the near clip plane
  61065. * @param zfar defines the far clip plane
  61066. * @param result defines the target matrix
  61067. */
  61068. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61069. /**
  61070. * Creates a left-handed perspective projection matrix
  61071. * @param width defines the viewport width
  61072. * @param height defines the viewport height
  61073. * @param znear defines the near clip plane
  61074. * @param zfar defines the far clip plane
  61075. * @returns a new matrix as a left-handed perspective projection matrix
  61076. */
  61077. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61078. /**
  61079. * Creates a left-handed perspective projection matrix
  61080. * @param fov defines the horizontal field of view
  61081. * @param aspect defines the aspect ratio
  61082. * @param znear defines the near clip plane
  61083. * @param zfar defines the far clip plane
  61084. * @returns a new matrix as a left-handed perspective projection matrix
  61085. */
  61086. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61087. /**
  61088. * Stores a left-handed perspective projection into a given matrix
  61089. * @param fov defines the horizontal field of view
  61090. * @param aspect defines the aspect ratio
  61091. * @param znear defines the near clip plane
  61092. * @param zfar defines the far clip plane
  61093. * @param result defines the target matrix
  61094. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61095. */
  61096. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61097. /**
  61098. * Creates a right-handed perspective projection matrix
  61099. * @param fov defines the horizontal field of view
  61100. * @param aspect defines the aspect ratio
  61101. * @param znear defines the near clip plane
  61102. * @param zfar defines the far clip plane
  61103. * @returns a new matrix as a right-handed perspective projection matrix
  61104. */
  61105. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61106. /**
  61107. * Stores a right-handed perspective projection into a given matrix
  61108. * @param fov defines the horizontal field of view
  61109. * @param aspect defines the aspect ratio
  61110. * @param znear defines the near clip plane
  61111. * @param zfar defines the far clip plane
  61112. * @param result defines the target matrix
  61113. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61114. */
  61115. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61116. /**
  61117. * Stores a perspective projection for WebVR info a given matrix
  61118. * @param fov defines the field of view
  61119. * @param znear defines the near clip plane
  61120. * @param zfar defines the far clip plane
  61121. * @param result defines the target matrix
  61122. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  61123. */
  61124. static PerspectiveFovWebVRToRef(fov: {
  61125. upDegrees: number;
  61126. downDegrees: number;
  61127. leftDegrees: number;
  61128. rightDegrees: number;
  61129. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  61130. /**
  61131. * Computes a complete transformation matrix
  61132. * @param viewport defines the viewport to use
  61133. * @param world defines the world matrix
  61134. * @param view defines the view matrix
  61135. * @param projection defines the projection matrix
  61136. * @param zmin defines the near clip plane
  61137. * @param zmax defines the far clip plane
  61138. * @returns the transformation matrix
  61139. */
  61140. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  61141. /**
  61142. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  61143. * @param matrix defines the matrix to use
  61144. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  61145. */
  61146. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  61147. /**
  61148. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  61149. * @param matrix defines the matrix to use
  61150. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  61151. */
  61152. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  61153. /**
  61154. * Compute the transpose of a given matrix
  61155. * @param matrix defines the matrix to transpose
  61156. * @returns the new matrix
  61157. */
  61158. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  61159. /**
  61160. * Compute the transpose of a matrix and store it in a target matrix
  61161. * @param matrix defines the matrix to transpose
  61162. * @param result defines the target matrix
  61163. */
  61164. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  61165. /**
  61166. * Computes a reflection matrix from a plane
  61167. * @param plane defines the reflection plane
  61168. * @returns a new matrix
  61169. */
  61170. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  61171. /**
  61172. * Computes a reflection matrix from a plane
  61173. * @param plane defines the reflection plane
  61174. * @param result defines the target matrix
  61175. */
  61176. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  61177. /**
  61178. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  61179. * @param xaxis defines the value of the 1st axis
  61180. * @param yaxis defines the value of the 2nd axis
  61181. * @param zaxis defines the value of the 3rd axis
  61182. * @param result defines the target matrix
  61183. */
  61184. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  61185. /**
  61186. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  61187. * @param quat defines the quaternion to use
  61188. * @param result defines the target matrix
  61189. */
  61190. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  61191. }
  61192. /**
  61193. * Represens a plane by the equation ax + by + cz + d = 0
  61194. */
  61195. export class Plane {
  61196. /**
  61197. * Normal of the plane (a,b,c)
  61198. */
  61199. normal: Vector3;
  61200. /**
  61201. * d component of the plane
  61202. */
  61203. d: number;
  61204. /**
  61205. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  61206. * @param a a component of the plane
  61207. * @param b b component of the plane
  61208. * @param c c component of the plane
  61209. * @param d d component of the plane
  61210. */
  61211. constructor(a: number, b: number, c: number, d: number);
  61212. /**
  61213. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  61214. */
  61215. asArray(): number[];
  61216. /**
  61217. * @returns a new plane copied from the current Plane.
  61218. */
  61219. clone(): Plane;
  61220. /**
  61221. * @returns the string "Plane".
  61222. */
  61223. getClassName(): string;
  61224. /**
  61225. * @returns the Plane hash code.
  61226. */
  61227. getHashCode(): number;
  61228. /**
  61229. * Normalize the current Plane in place.
  61230. * @returns the updated Plane.
  61231. */
  61232. normalize(): Plane;
  61233. /**
  61234. * Applies a transformation the plane and returns the result
  61235. * @param transformation the transformation matrix to be applied to the plane
  61236. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  61237. */
  61238. transform(transformation: DeepImmutable<Matrix>): Plane;
  61239. /**
  61240. * Calcualtte the dot product between the point and the plane normal
  61241. * @param point point to calculate the dot product with
  61242. * @returns the dot product (float) of the point coordinates and the plane normal.
  61243. */
  61244. dotCoordinate(point: DeepImmutable<Vector3>): number;
  61245. /**
  61246. * Updates the current Plane from the plane defined by the three given points.
  61247. * @param point1 one of the points used to contruct the plane
  61248. * @param point2 one of the points used to contruct the plane
  61249. * @param point3 one of the points used to contruct the plane
  61250. * @returns the updated Plane.
  61251. */
  61252. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61253. /**
  61254. * Checks if the plane is facing a given direction
  61255. * @param direction the direction to check if the plane is facing
  61256. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  61257. * @returns True is the vector "direction" is the same side than the plane normal.
  61258. */
  61259. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  61260. /**
  61261. * Calculates the distance to a point
  61262. * @param point point to calculate distance to
  61263. * @returns the signed distance (float) from the given point to the Plane.
  61264. */
  61265. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  61266. /**
  61267. * Creates a plane from an array
  61268. * @param array the array to create a plane from
  61269. * @returns a new Plane from the given array.
  61270. */
  61271. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  61272. /**
  61273. * Creates a plane from three points
  61274. * @param point1 point used to create the plane
  61275. * @param point2 point used to create the plane
  61276. * @param point3 point used to create the plane
  61277. * @returns a new Plane defined by the three given points.
  61278. */
  61279. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61280. /**
  61281. * Creates a plane from an origin point and a normal
  61282. * @param origin origin of the plane to be constructed
  61283. * @param normal normal of the plane to be constructed
  61284. * @returns a new Plane the normal vector to this plane at the given origin point.
  61285. * Note : the vector "normal" is updated because normalized.
  61286. */
  61287. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  61288. /**
  61289. * Calculates the distance from a plane and a point
  61290. * @param origin origin of the plane to be constructed
  61291. * @param normal normal of the plane to be constructed
  61292. * @param point point to calculate distance to
  61293. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  61294. */
  61295. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  61296. }
  61297. /**
  61298. * Class used to represent a viewport on screen
  61299. */
  61300. export class Viewport {
  61301. /** viewport left coordinate */
  61302. x: number;
  61303. /** viewport top coordinate */
  61304. y: number;
  61305. /**viewport width */
  61306. width: number;
  61307. /** viewport height */
  61308. height: number;
  61309. /**
  61310. * Creates a Viewport object located at (x, y) and sized (width, height)
  61311. * @param x defines viewport left coordinate
  61312. * @param y defines viewport top coordinate
  61313. * @param width defines the viewport width
  61314. * @param height defines the viewport height
  61315. */
  61316. constructor(
  61317. /** viewport left coordinate */
  61318. x: number,
  61319. /** viewport top coordinate */
  61320. y: number,
  61321. /**viewport width */
  61322. width: number,
  61323. /** viewport height */
  61324. height: number);
  61325. /**
  61326. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  61327. * @param renderWidth defines the rendering width
  61328. * @param renderHeight defines the rendering height
  61329. * @returns a new Viewport
  61330. */
  61331. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  61332. /**
  61333. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  61334. * @param renderWidth defines the rendering width
  61335. * @param renderHeight defines the rendering height
  61336. * @param ref defines the target viewport
  61337. * @returns the current viewport
  61338. */
  61339. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  61340. /**
  61341. * Returns a new Viewport copied from the current one
  61342. * @returns a new Viewport
  61343. */
  61344. clone(): Viewport;
  61345. }
  61346. /**
  61347. * Reprasents a camera frustum
  61348. */
  61349. export class Frustum {
  61350. /**
  61351. * Gets the planes representing the frustum
  61352. * @param transform matrix to be applied to the returned planes
  61353. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  61354. */
  61355. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  61356. /**
  61357. * Gets the near frustum plane transformed by the transform matrix
  61358. * @param transform transformation matrix to be applied to the resulting frustum plane
  61359. * @param frustumPlane the resuling frustum plane
  61360. */
  61361. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61362. /**
  61363. * Gets the far frustum plane transformed by the transform matrix
  61364. * @param transform transformation matrix to be applied to the resulting frustum plane
  61365. * @param frustumPlane the resuling frustum plane
  61366. */
  61367. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61368. /**
  61369. * Gets the left frustum plane transformed by the transform matrix
  61370. * @param transform transformation matrix to be applied to the resulting frustum plane
  61371. * @param frustumPlane the resuling frustum plane
  61372. */
  61373. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61374. /**
  61375. * Gets the right frustum plane transformed by the transform matrix
  61376. * @param transform transformation matrix to be applied to the resulting frustum plane
  61377. * @param frustumPlane the resuling frustum plane
  61378. */
  61379. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61380. /**
  61381. * Gets the top frustum plane transformed by the transform matrix
  61382. * @param transform transformation matrix to be applied to the resulting frustum plane
  61383. * @param frustumPlane the resuling frustum plane
  61384. */
  61385. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61386. /**
  61387. * Gets the bottom frustum plane transformed by the transform matrix
  61388. * @param transform transformation matrix to be applied to the resulting frustum plane
  61389. * @param frustumPlane the resuling frustum plane
  61390. */
  61391. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61392. /**
  61393. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  61394. * @param transform transformation matrix to be applied to the resulting frustum planes
  61395. * @param frustumPlanes the resuling frustum planes
  61396. */
  61397. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  61398. }
  61399. /** Defines supported spaces */
  61400. export enum Space {
  61401. /** Local (object) space */
  61402. LOCAL = 0,
  61403. /** World space */
  61404. WORLD = 1,
  61405. /** Bone space */
  61406. BONE = 2
  61407. }
  61408. /** Defines the 3 main axes */
  61409. export class Axis {
  61410. /** X axis */
  61411. static X: Vector3;
  61412. /** Y axis */
  61413. static Y: Vector3;
  61414. /** Z axis */
  61415. static Z: Vector3;
  61416. }
  61417. /** Class used to represent a Bezier curve */
  61418. export class BezierCurve {
  61419. /**
  61420. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  61421. * @param t defines the time
  61422. * @param x1 defines the left coordinate on X axis
  61423. * @param y1 defines the left coordinate on Y axis
  61424. * @param x2 defines the right coordinate on X axis
  61425. * @param y2 defines the right coordinate on Y axis
  61426. * @returns the interpolated value
  61427. */
  61428. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  61429. }
  61430. /**
  61431. * Defines potential orientation for back face culling
  61432. */
  61433. export enum Orientation {
  61434. /**
  61435. * Clockwise
  61436. */
  61437. CW = 0,
  61438. /** Counter clockwise */
  61439. CCW = 1
  61440. }
  61441. /**
  61442. * Defines angle representation
  61443. */
  61444. export class Angle {
  61445. private _radians;
  61446. /**
  61447. * Creates an Angle object of "radians" radians (float).
  61448. * @param radians the angle in radians
  61449. */
  61450. constructor(radians: number);
  61451. /**
  61452. * Get value in degrees
  61453. * @returns the Angle value in degrees (float)
  61454. */
  61455. degrees(): number;
  61456. /**
  61457. * Get value in radians
  61458. * @returns the Angle value in radians (float)
  61459. */
  61460. radians(): number;
  61461. /**
  61462. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  61463. * @param a defines first vector
  61464. * @param b defines second vector
  61465. * @returns a new Angle
  61466. */
  61467. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  61468. /**
  61469. * Gets a new Angle object from the given float in radians
  61470. * @param radians defines the angle value in radians
  61471. * @returns a new Angle
  61472. */
  61473. static FromRadians(radians: number): Angle;
  61474. /**
  61475. * Gets a new Angle object from the given float in degrees
  61476. * @param degrees defines the angle value in degrees
  61477. * @returns a new Angle
  61478. */
  61479. static FromDegrees(degrees: number): Angle;
  61480. }
  61481. /**
  61482. * This represents an arc in a 2d space.
  61483. */
  61484. export class Arc2 {
  61485. /** Defines the start point of the arc */
  61486. startPoint: Vector2;
  61487. /** Defines the mid point of the arc */
  61488. midPoint: Vector2;
  61489. /** Defines the end point of the arc */
  61490. endPoint: Vector2;
  61491. /**
  61492. * Defines the center point of the arc.
  61493. */
  61494. centerPoint: Vector2;
  61495. /**
  61496. * Defines the radius of the arc.
  61497. */
  61498. radius: number;
  61499. /**
  61500. * Defines the angle of the arc (from mid point to end point).
  61501. */
  61502. angle: Angle;
  61503. /**
  61504. * Defines the start angle of the arc (from start point to middle point).
  61505. */
  61506. startAngle: Angle;
  61507. /**
  61508. * Defines the orientation of the arc (clock wise/counter clock wise).
  61509. */
  61510. orientation: Orientation;
  61511. /**
  61512. * Creates an Arc object from the three given points : start, middle and end.
  61513. * @param startPoint Defines the start point of the arc
  61514. * @param midPoint Defines the midlle point of the arc
  61515. * @param endPoint Defines the end point of the arc
  61516. */
  61517. constructor(
  61518. /** Defines the start point of the arc */
  61519. startPoint: Vector2,
  61520. /** Defines the mid point of the arc */
  61521. midPoint: Vector2,
  61522. /** Defines the end point of the arc */
  61523. endPoint: Vector2);
  61524. }
  61525. /**
  61526. * Represents a 2D path made up of multiple 2D points
  61527. */
  61528. export class Path2 {
  61529. private _points;
  61530. private _length;
  61531. /**
  61532. * If the path start and end point are the same
  61533. */
  61534. closed: boolean;
  61535. /**
  61536. * Creates a Path2 object from the starting 2D coordinates x and y.
  61537. * @param x the starting points x value
  61538. * @param y the starting points y value
  61539. */
  61540. constructor(x: number, y: number);
  61541. /**
  61542. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  61543. * @param x the added points x value
  61544. * @param y the added points y value
  61545. * @returns the updated Path2.
  61546. */
  61547. addLineTo(x: number, y: number): Path2;
  61548. /**
  61549. * 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.
  61550. * @param midX middle point x value
  61551. * @param midY middle point y value
  61552. * @param endX end point x value
  61553. * @param endY end point y value
  61554. * @param numberOfSegments (default: 36)
  61555. * @returns the updated Path2.
  61556. */
  61557. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  61558. /**
  61559. * Closes the Path2.
  61560. * @returns the Path2.
  61561. */
  61562. close(): Path2;
  61563. /**
  61564. * Gets the sum of the distance between each sequential point in the path
  61565. * @returns the Path2 total length (float).
  61566. */
  61567. length(): number;
  61568. /**
  61569. * Gets the points which construct the path
  61570. * @returns the Path2 internal array of points.
  61571. */
  61572. getPoints(): Vector2[];
  61573. /**
  61574. * Retreives the point at the distance aways from the starting point
  61575. * @param normalizedLengthPosition the length along the path to retreive the point from
  61576. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  61577. */
  61578. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  61579. /**
  61580. * Creates a new path starting from an x and y position
  61581. * @param x starting x value
  61582. * @param y starting y value
  61583. * @returns a new Path2 starting at the coordinates (x, y).
  61584. */
  61585. static StartingAt(x: number, y: number): Path2;
  61586. }
  61587. /**
  61588. * Represents a 3D path made up of multiple 3D points
  61589. */
  61590. export class Path3D {
  61591. /**
  61592. * an array of Vector3, the curve axis of the Path3D
  61593. */
  61594. path: Vector3[];
  61595. private _curve;
  61596. private _distances;
  61597. private _tangents;
  61598. private _normals;
  61599. private _binormals;
  61600. private _raw;
  61601. /**
  61602. * new Path3D(path, normal, raw)
  61603. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  61604. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  61605. * @param path an array of Vector3, the curve axis of the Path3D
  61606. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  61607. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  61608. */
  61609. constructor(
  61610. /**
  61611. * an array of Vector3, the curve axis of the Path3D
  61612. */
  61613. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  61614. /**
  61615. * Returns the Path3D array of successive Vector3 designing its curve.
  61616. * @returns the Path3D array of successive Vector3 designing its curve.
  61617. */
  61618. getCurve(): Vector3[];
  61619. /**
  61620. * Returns an array populated with tangent vectors on each Path3D curve point.
  61621. * @returns an array populated with tangent vectors on each Path3D curve point.
  61622. */
  61623. getTangents(): Vector3[];
  61624. /**
  61625. * Returns an array populated with normal vectors on each Path3D curve point.
  61626. * @returns an array populated with normal vectors on each Path3D curve point.
  61627. */
  61628. getNormals(): Vector3[];
  61629. /**
  61630. * Returns an array populated with binormal vectors on each Path3D curve point.
  61631. * @returns an array populated with binormal vectors on each Path3D curve point.
  61632. */
  61633. getBinormals(): Vector3[];
  61634. /**
  61635. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  61636. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  61637. */
  61638. getDistances(): number[];
  61639. /**
  61640. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  61641. * @param path path which all values are copied into the curves points
  61642. * @param firstNormal which should be projected onto the curve
  61643. * @returns the same object updated.
  61644. */
  61645. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  61646. private _compute;
  61647. private _getFirstNonNullVector;
  61648. private _getLastNonNullVector;
  61649. private _normalVector;
  61650. }
  61651. /**
  61652. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61653. * A Curve3 is designed from a series of successive Vector3.
  61654. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  61655. */
  61656. export class Curve3 {
  61657. private _points;
  61658. private _length;
  61659. /**
  61660. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  61661. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  61662. * @param v1 (Vector3) the control point
  61663. * @param v2 (Vector3) the end point of the Quadratic Bezier
  61664. * @param nbPoints (integer) the wanted number of points in the curve
  61665. * @returns the created Curve3
  61666. */
  61667. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61668. /**
  61669. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  61670. * @param v0 (Vector3) the origin point of the Cubic Bezier
  61671. * @param v1 (Vector3) the first control point
  61672. * @param v2 (Vector3) the second control point
  61673. * @param v3 (Vector3) the end point of the Cubic Bezier
  61674. * @param nbPoints (integer) the wanted number of points in the curve
  61675. * @returns the created Curve3
  61676. */
  61677. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61678. /**
  61679. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  61680. * @param p1 (Vector3) the origin point of the Hermite Spline
  61681. * @param t1 (Vector3) the tangent vector at the origin point
  61682. * @param p2 (Vector3) the end point of the Hermite Spline
  61683. * @param t2 (Vector3) the tangent vector at the end point
  61684. * @param nbPoints (integer) the wanted number of points in the curve
  61685. * @returns the created Curve3
  61686. */
  61687. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61688. /**
  61689. * Returns a Curve3 object along a CatmullRom Spline curve :
  61690. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  61691. * @param nbPoints (integer) the wanted number of points between each curve control points
  61692. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  61693. * @returns the created Curve3
  61694. */
  61695. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  61696. /**
  61697. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61698. * A Curve3 is designed from a series of successive Vector3.
  61699. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  61700. * @param points points which make up the curve
  61701. */
  61702. constructor(points: Vector3[]);
  61703. /**
  61704. * @returns the Curve3 stored array of successive Vector3
  61705. */
  61706. getPoints(): Vector3[];
  61707. /**
  61708. * @returns the computed length (float) of the curve.
  61709. */
  61710. length(): number;
  61711. /**
  61712. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  61713. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  61714. * curveA and curveB keep unchanged.
  61715. * @param curve the curve to continue from this curve
  61716. * @returns the newly constructed curve
  61717. */
  61718. continue(curve: DeepImmutable<Curve3>): Curve3;
  61719. private _computeLength;
  61720. }
  61721. /**
  61722. * Contains position and normal vectors for a vertex
  61723. */
  61724. export class PositionNormalVertex {
  61725. /** the position of the vertex (defaut: 0,0,0) */
  61726. position: Vector3;
  61727. /** the normal of the vertex (defaut: 0,1,0) */
  61728. normal: Vector3;
  61729. /**
  61730. * Creates a PositionNormalVertex
  61731. * @param position the position of the vertex (defaut: 0,0,0)
  61732. * @param normal the normal of the vertex (defaut: 0,1,0)
  61733. */
  61734. constructor(
  61735. /** the position of the vertex (defaut: 0,0,0) */
  61736. position?: Vector3,
  61737. /** the normal of the vertex (defaut: 0,1,0) */
  61738. normal?: Vector3);
  61739. /**
  61740. * Clones the PositionNormalVertex
  61741. * @returns the cloned PositionNormalVertex
  61742. */
  61743. clone(): PositionNormalVertex;
  61744. }
  61745. /**
  61746. * Contains position, normal and uv vectors for a vertex
  61747. */
  61748. export class PositionNormalTextureVertex {
  61749. /** the position of the vertex (defaut: 0,0,0) */
  61750. position: Vector3;
  61751. /** the normal of the vertex (defaut: 0,1,0) */
  61752. normal: Vector3;
  61753. /** the uv of the vertex (default: 0,0) */
  61754. uv: Vector2;
  61755. /**
  61756. * Creates a PositionNormalTextureVertex
  61757. * @param position the position of the vertex (defaut: 0,0,0)
  61758. * @param normal the normal of the vertex (defaut: 0,1,0)
  61759. * @param uv the uv of the vertex (default: 0,0)
  61760. */
  61761. constructor(
  61762. /** the position of the vertex (defaut: 0,0,0) */
  61763. position?: Vector3,
  61764. /** the normal of the vertex (defaut: 0,1,0) */
  61765. normal?: Vector3,
  61766. /** the uv of the vertex (default: 0,0) */
  61767. uv?: Vector2);
  61768. /**
  61769. * Clones the PositionNormalTextureVertex
  61770. * @returns the cloned PositionNormalTextureVertex
  61771. */
  61772. clone(): PositionNormalTextureVertex;
  61773. }
  61774. /**
  61775. * @hidden
  61776. */
  61777. export class Tmp {
  61778. static Color3: Color3[];
  61779. static Color4: Color4[];
  61780. static Vector2: Vector2[];
  61781. static Vector3: Vector3[];
  61782. static Vector4: Vector4[];
  61783. static Quaternion: Quaternion[];
  61784. static Matrix: Matrix[];
  61785. }
  61786. }
  61787. declare module BABYLON {
  61788. /**
  61789. * Class used to enable access to offline support
  61790. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61791. */
  61792. export interface IOfflineProvider {
  61793. /**
  61794. * Gets a boolean indicating if scene must be saved in the database
  61795. */
  61796. enableSceneOffline: boolean;
  61797. /**
  61798. * Gets a boolean indicating if textures must be saved in the database
  61799. */
  61800. enableTexturesOffline: boolean;
  61801. /**
  61802. * Open the offline support and make it available
  61803. * @param successCallback defines the callback to call on success
  61804. * @param errorCallback defines the callback to call on error
  61805. */
  61806. open(successCallback: () => void, errorCallback: () => void): void;
  61807. /**
  61808. * Loads an image from the offline support
  61809. * @param url defines the url to load from
  61810. * @param image defines the target DOM image
  61811. */
  61812. loadImage(url: string, image: HTMLImageElement): void;
  61813. /**
  61814. * Loads a file from offline support
  61815. * @param url defines the URL to load from
  61816. * @param sceneLoaded defines a callback to call on success
  61817. * @param progressCallBack defines a callback to call when progress changed
  61818. * @param errorCallback defines a callback to call on error
  61819. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61820. */
  61821. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61822. }
  61823. }
  61824. declare module BABYLON {
  61825. /**
  61826. * A class serves as a medium between the observable and its observers
  61827. */
  61828. export class EventState {
  61829. /**
  61830. * Create a new EventState
  61831. * @param mask defines the mask associated with this state
  61832. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61833. * @param target defines the original target of the state
  61834. * @param currentTarget defines the current target of the state
  61835. */
  61836. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  61837. /**
  61838. * Initialize the current event state
  61839. * @param mask defines the mask associated with this state
  61840. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61841. * @param target defines the original target of the state
  61842. * @param currentTarget defines the current target of the state
  61843. * @returns the current event state
  61844. */
  61845. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  61846. /**
  61847. * An Observer can set this property to true to prevent subsequent observers of being notified
  61848. */
  61849. skipNextObservers: boolean;
  61850. /**
  61851. * Get the mask value that were used to trigger the event corresponding to this EventState object
  61852. */
  61853. mask: number;
  61854. /**
  61855. * The object that originally notified the event
  61856. */
  61857. target?: any;
  61858. /**
  61859. * The current object in the bubbling phase
  61860. */
  61861. currentTarget?: any;
  61862. /**
  61863. * This will be populated with the return value of the last function that was executed.
  61864. * If it is the first function in the callback chain it will be the event data.
  61865. */
  61866. lastReturnValue?: any;
  61867. }
  61868. /**
  61869. * Represent an Observer registered to a given Observable object.
  61870. */
  61871. export class Observer<T> {
  61872. /**
  61873. * Defines the callback to call when the observer is notified
  61874. */
  61875. callback: (eventData: T, eventState: EventState) => void;
  61876. /**
  61877. * Defines the mask of the observer (used to filter notifications)
  61878. */
  61879. mask: number;
  61880. /**
  61881. * Defines the current scope used to restore the JS context
  61882. */
  61883. scope: any;
  61884. /** @hidden */
  61885. _willBeUnregistered: boolean;
  61886. /**
  61887. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  61888. */
  61889. unregisterOnNextCall: boolean;
  61890. /**
  61891. * Creates a new observer
  61892. * @param callback defines the callback to call when the observer is notified
  61893. * @param mask defines the mask of the observer (used to filter notifications)
  61894. * @param scope defines the current scope used to restore the JS context
  61895. */
  61896. constructor(
  61897. /**
  61898. * Defines the callback to call when the observer is notified
  61899. */
  61900. callback: (eventData: T, eventState: EventState) => void,
  61901. /**
  61902. * Defines the mask of the observer (used to filter notifications)
  61903. */
  61904. mask: number,
  61905. /**
  61906. * Defines the current scope used to restore the JS context
  61907. */
  61908. scope?: any);
  61909. }
  61910. /**
  61911. * Represent a list of observers registered to multiple Observables object.
  61912. */
  61913. export class MultiObserver<T> {
  61914. private _observers;
  61915. private _observables;
  61916. /**
  61917. * Release associated resources
  61918. */
  61919. dispose(): void;
  61920. /**
  61921. * Raise a callback when one of the observable will notify
  61922. * @param observables defines a list of observables to watch
  61923. * @param callback defines the callback to call on notification
  61924. * @param mask defines the mask used to filter notifications
  61925. * @param scope defines the current scope used to restore the JS context
  61926. * @returns the new MultiObserver
  61927. */
  61928. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  61929. }
  61930. /**
  61931. * The Observable class is a simple implementation of the Observable pattern.
  61932. *
  61933. * 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.
  61934. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  61935. * 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).
  61936. * 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.
  61937. */
  61938. export class Observable<T> {
  61939. private _observers;
  61940. private _eventState;
  61941. private _onObserverAdded;
  61942. /**
  61943. * Creates a new observable
  61944. * @param onObserverAdded defines a callback to call when a new observer is added
  61945. */
  61946. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  61947. /**
  61948. * Create a new Observer with the specified callback
  61949. * @param callback the callback that will be executed for that Observer
  61950. * @param mask the mask used to filter observers
  61951. * @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.
  61952. * @param scope optional scope for the callback to be called from
  61953. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  61954. * @returns the new observer created for the callback
  61955. */
  61956. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  61957. /**
  61958. * Create a new Observer with the specified callback and unregisters after the next notification
  61959. * @param callback the callback that will be executed for that Observer
  61960. * @returns the new observer created for the callback
  61961. */
  61962. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  61963. /**
  61964. * Remove an Observer from the Observable object
  61965. * @param observer the instance of the Observer to remove
  61966. * @returns false if it doesn't belong to this Observable
  61967. */
  61968. remove(observer: Nullable<Observer<T>>): boolean;
  61969. /**
  61970. * Remove a callback from the Observable object
  61971. * @param callback the callback to remove
  61972. * @param scope optional scope. If used only the callbacks with this scope will be removed
  61973. * @returns false if it doesn't belong to this Observable
  61974. */
  61975. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  61976. private _deferUnregister;
  61977. private _remove;
  61978. /**
  61979. * Notify all Observers by calling their respective callback with the given data
  61980. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  61981. * @param eventData defines the data to send to all observers
  61982. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  61983. * @param target defines the original target of the state
  61984. * @param currentTarget defines the current target of the state
  61985. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  61986. */
  61987. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  61988. /**
  61989. * Calling this will execute each callback, expecting it to be a promise or return a value.
  61990. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  61991. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  61992. * and it is crucial that all callbacks will be executed.
  61993. * The order of the callbacks is kept, callbacks are not executed parallel.
  61994. *
  61995. * @param eventData The data to be sent to each callback
  61996. * @param mask is used to filter observers defaults to -1
  61997. * @param target defines the callback target (see EventState)
  61998. * @param currentTarget defines he current object in the bubbling phase
  61999. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  62000. */
  62001. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  62002. /**
  62003. * Notify a specific observer
  62004. * @param observer defines the observer to notify
  62005. * @param eventData defines the data to be sent to each callback
  62006. * @param mask is used to filter observers defaults to -1
  62007. */
  62008. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  62009. /**
  62010. * Gets a boolean indicating if the observable has at least one observer
  62011. * @returns true is the Observable has at least one Observer registered
  62012. */
  62013. hasObservers(): boolean;
  62014. /**
  62015. * Clear the list of observers
  62016. */
  62017. clear(): void;
  62018. /**
  62019. * Clone the current observable
  62020. * @returns a new observable
  62021. */
  62022. clone(): Observable<T>;
  62023. /**
  62024. * Does this observable handles observer registered with a given mask
  62025. * @param mask defines the mask to be tested
  62026. * @return whether or not one observer registered with the given mask is handeled
  62027. **/
  62028. hasSpecificMask(mask?: number): boolean;
  62029. }
  62030. }
  62031. declare module BABYLON {
  62032. /**
  62033. * Class used to help managing file picking and drag'n'drop
  62034. * File Storage
  62035. */
  62036. export class FilesInputStore {
  62037. /**
  62038. * List of files ready to be loaded
  62039. */
  62040. static FilesToLoad: {
  62041. [key: string]: File;
  62042. };
  62043. }
  62044. }
  62045. declare module BABYLON {
  62046. /** Defines the cross module used constants to avoid circular dependncies */
  62047. export class Constants {
  62048. /** Defines that alpha blending is disabled */
  62049. static readonly ALPHA_DISABLE: number;
  62050. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  62051. static readonly ALPHA_ADD: number;
  62052. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  62053. static readonly ALPHA_COMBINE: number;
  62054. /** Defines that alpha blending to DEST - SRC * DEST */
  62055. static readonly ALPHA_SUBTRACT: number;
  62056. /** Defines that alpha blending to SRC * DEST */
  62057. static readonly ALPHA_MULTIPLY: number;
  62058. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  62059. static readonly ALPHA_MAXIMIZED: number;
  62060. /** Defines that alpha blending to SRC + DEST */
  62061. static readonly ALPHA_ONEONE: number;
  62062. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  62063. static readonly ALPHA_PREMULTIPLIED: number;
  62064. /**
  62065. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  62066. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  62067. */
  62068. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  62069. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  62070. static readonly ALPHA_INTERPOLATE: number;
  62071. /**
  62072. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  62073. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  62074. */
  62075. static readonly ALPHA_SCREENMODE: number;
  62076. /** Defines that the ressource is not delayed*/
  62077. static readonly DELAYLOADSTATE_NONE: number;
  62078. /** Defines that the ressource was successfully delay loaded */
  62079. static readonly DELAYLOADSTATE_LOADED: number;
  62080. /** Defines that the ressource is currently delay loading */
  62081. static readonly DELAYLOADSTATE_LOADING: number;
  62082. /** Defines that the ressource is delayed and has not started loading */
  62083. static readonly DELAYLOADSTATE_NOTLOADED: number;
  62084. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  62085. static readonly NEVER: number;
  62086. /** 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 */
  62087. static readonly ALWAYS: number;
  62088. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  62089. static readonly LESS: number;
  62090. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  62091. static readonly EQUAL: number;
  62092. /** 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 */
  62093. static readonly LEQUAL: number;
  62094. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  62095. static readonly GREATER: number;
  62096. /** 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 */
  62097. static readonly GEQUAL: number;
  62098. /** 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 */
  62099. static readonly NOTEQUAL: number;
  62100. /** Passed to stencilOperation to specify that stencil value must be kept */
  62101. static readonly KEEP: number;
  62102. /** Passed to stencilOperation to specify that stencil value must be replaced */
  62103. static readonly REPLACE: number;
  62104. /** Passed to stencilOperation to specify that stencil value must be incremented */
  62105. static readonly INCR: number;
  62106. /** Passed to stencilOperation to specify that stencil value must be decremented */
  62107. static readonly DECR: number;
  62108. /** Passed to stencilOperation to specify that stencil value must be inverted */
  62109. static readonly INVERT: number;
  62110. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  62111. static readonly INCR_WRAP: number;
  62112. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  62113. static readonly DECR_WRAP: number;
  62114. /** Texture is not repeating outside of 0..1 UVs */
  62115. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  62116. /** Texture is repeating outside of 0..1 UVs */
  62117. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  62118. /** Texture is repeating and mirrored */
  62119. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  62120. /** ALPHA */
  62121. static readonly TEXTUREFORMAT_ALPHA: number;
  62122. /** LUMINANCE */
  62123. static readonly TEXTUREFORMAT_LUMINANCE: number;
  62124. /** LUMINANCE_ALPHA */
  62125. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  62126. /** RGB */
  62127. static readonly TEXTUREFORMAT_RGB: number;
  62128. /** RGBA */
  62129. static readonly TEXTUREFORMAT_RGBA: number;
  62130. /** RED */
  62131. static readonly TEXTUREFORMAT_RED: number;
  62132. /** RED (2nd reference) */
  62133. static readonly TEXTUREFORMAT_R: number;
  62134. /** RG */
  62135. static readonly TEXTUREFORMAT_RG: number;
  62136. /** RED_INTEGER */
  62137. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  62138. /** RED_INTEGER (2nd reference) */
  62139. static readonly TEXTUREFORMAT_R_INTEGER: number;
  62140. /** RG_INTEGER */
  62141. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  62142. /** RGB_INTEGER */
  62143. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  62144. /** RGBA_INTEGER */
  62145. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  62146. /** UNSIGNED_BYTE */
  62147. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  62148. /** UNSIGNED_BYTE (2nd reference) */
  62149. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  62150. /** FLOAT */
  62151. static readonly TEXTURETYPE_FLOAT: number;
  62152. /** HALF_FLOAT */
  62153. static readonly TEXTURETYPE_HALF_FLOAT: number;
  62154. /** BYTE */
  62155. static readonly TEXTURETYPE_BYTE: number;
  62156. /** SHORT */
  62157. static readonly TEXTURETYPE_SHORT: number;
  62158. /** UNSIGNED_SHORT */
  62159. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  62160. /** INT */
  62161. static readonly TEXTURETYPE_INT: number;
  62162. /** UNSIGNED_INT */
  62163. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  62164. /** UNSIGNED_SHORT_4_4_4_4 */
  62165. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  62166. /** UNSIGNED_SHORT_5_5_5_1 */
  62167. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  62168. /** UNSIGNED_SHORT_5_6_5 */
  62169. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  62170. /** UNSIGNED_INT_2_10_10_10_REV */
  62171. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  62172. /** UNSIGNED_INT_24_8 */
  62173. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  62174. /** UNSIGNED_INT_10F_11F_11F_REV */
  62175. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  62176. /** UNSIGNED_INT_5_9_9_9_REV */
  62177. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  62178. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  62179. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62180. /** nearest is mag = nearest and min = nearest and mip = linear */
  62181. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  62182. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62183. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  62184. /** Trilinear is mag = linear and min = linear and mip = linear */
  62185. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  62186. /** nearest is mag = nearest and min = nearest and mip = linear */
  62187. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  62188. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62189. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  62190. /** Trilinear is mag = linear and min = linear and mip = linear */
  62191. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  62192. /** mag = nearest and min = nearest and mip = nearest */
  62193. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  62194. /** mag = nearest and min = linear and mip = nearest */
  62195. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  62196. /** mag = nearest and min = linear and mip = linear */
  62197. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  62198. /** mag = nearest and min = linear and mip = none */
  62199. static readonly TEXTURE_NEAREST_LINEAR: number;
  62200. /** mag = nearest and min = nearest and mip = none */
  62201. static readonly TEXTURE_NEAREST_NEAREST: number;
  62202. /** mag = linear and min = nearest and mip = nearest */
  62203. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  62204. /** mag = linear and min = nearest and mip = linear */
  62205. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  62206. /** mag = linear and min = linear and mip = none */
  62207. static readonly TEXTURE_LINEAR_LINEAR: number;
  62208. /** mag = linear and min = nearest and mip = none */
  62209. static readonly TEXTURE_LINEAR_NEAREST: number;
  62210. /** Explicit coordinates mode */
  62211. static readonly TEXTURE_EXPLICIT_MODE: number;
  62212. /** Spherical coordinates mode */
  62213. static readonly TEXTURE_SPHERICAL_MODE: number;
  62214. /** Planar coordinates mode */
  62215. static readonly TEXTURE_PLANAR_MODE: number;
  62216. /** Cubic coordinates mode */
  62217. static readonly TEXTURE_CUBIC_MODE: number;
  62218. /** Projection coordinates mode */
  62219. static readonly TEXTURE_PROJECTION_MODE: number;
  62220. /** Skybox coordinates mode */
  62221. static readonly TEXTURE_SKYBOX_MODE: number;
  62222. /** Inverse Cubic coordinates mode */
  62223. static readonly TEXTURE_INVCUBIC_MODE: number;
  62224. /** Equirectangular coordinates mode */
  62225. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  62226. /** Equirectangular Fixed coordinates mode */
  62227. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  62228. /** Equirectangular Fixed Mirrored coordinates mode */
  62229. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  62230. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  62231. static readonly SCALEMODE_FLOOR: number;
  62232. /** Defines that texture rescaling will look for the nearest power of 2 size */
  62233. static readonly SCALEMODE_NEAREST: number;
  62234. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  62235. static readonly SCALEMODE_CEILING: number;
  62236. /**
  62237. * The dirty texture flag value
  62238. */
  62239. static readonly MATERIAL_TextureDirtyFlag: number;
  62240. /**
  62241. * The dirty light flag value
  62242. */
  62243. static readonly MATERIAL_LightDirtyFlag: number;
  62244. /**
  62245. * The dirty fresnel flag value
  62246. */
  62247. static readonly MATERIAL_FresnelDirtyFlag: number;
  62248. /**
  62249. * The dirty attribute flag value
  62250. */
  62251. static readonly MATERIAL_AttributesDirtyFlag: number;
  62252. /**
  62253. * The dirty misc flag value
  62254. */
  62255. static readonly MATERIAL_MiscDirtyFlag: number;
  62256. /**
  62257. * The all dirty flag value
  62258. */
  62259. static readonly MATERIAL_AllDirtyFlag: number;
  62260. /**
  62261. * Returns the triangle fill mode
  62262. */
  62263. static readonly MATERIAL_TriangleFillMode: number;
  62264. /**
  62265. * Returns the wireframe mode
  62266. */
  62267. static readonly MATERIAL_WireFrameFillMode: number;
  62268. /**
  62269. * Returns the point fill mode
  62270. */
  62271. static readonly MATERIAL_PointFillMode: number;
  62272. /**
  62273. * Returns the point list draw mode
  62274. */
  62275. static readonly MATERIAL_PointListDrawMode: number;
  62276. /**
  62277. * Returns the line list draw mode
  62278. */
  62279. static readonly MATERIAL_LineListDrawMode: number;
  62280. /**
  62281. * Returns the line loop draw mode
  62282. */
  62283. static readonly MATERIAL_LineLoopDrawMode: number;
  62284. /**
  62285. * Returns the line strip draw mode
  62286. */
  62287. static readonly MATERIAL_LineStripDrawMode: number;
  62288. /**
  62289. * Returns the triangle strip draw mode
  62290. */
  62291. static readonly MATERIAL_TriangleStripDrawMode: number;
  62292. /**
  62293. * Returns the triangle fan draw mode
  62294. */
  62295. static readonly MATERIAL_TriangleFanDrawMode: number;
  62296. /**
  62297. * Stores the clock-wise side orientation
  62298. */
  62299. static readonly MATERIAL_ClockWiseSideOrientation: number;
  62300. /**
  62301. * Stores the counter clock-wise side orientation
  62302. */
  62303. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  62304. /**
  62305. * Nothing
  62306. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62307. */
  62308. static readonly ACTION_NothingTrigger: number;
  62309. /**
  62310. * On pick
  62311. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62312. */
  62313. static readonly ACTION_OnPickTrigger: number;
  62314. /**
  62315. * On left pick
  62316. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62317. */
  62318. static readonly ACTION_OnLeftPickTrigger: number;
  62319. /**
  62320. * On right pick
  62321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62322. */
  62323. static readonly ACTION_OnRightPickTrigger: number;
  62324. /**
  62325. * On center pick
  62326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62327. */
  62328. static readonly ACTION_OnCenterPickTrigger: number;
  62329. /**
  62330. * On pick down
  62331. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62332. */
  62333. static readonly ACTION_OnPickDownTrigger: number;
  62334. /**
  62335. * On double pick
  62336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62337. */
  62338. static readonly ACTION_OnDoublePickTrigger: number;
  62339. /**
  62340. * On pick up
  62341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62342. */
  62343. static readonly ACTION_OnPickUpTrigger: number;
  62344. /**
  62345. * On pick out.
  62346. * This trigger will only be raised if you also declared a OnPickDown
  62347. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62348. */
  62349. static readonly ACTION_OnPickOutTrigger: number;
  62350. /**
  62351. * On long press
  62352. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62353. */
  62354. static readonly ACTION_OnLongPressTrigger: number;
  62355. /**
  62356. * On pointer over
  62357. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62358. */
  62359. static readonly ACTION_OnPointerOverTrigger: number;
  62360. /**
  62361. * On pointer out
  62362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62363. */
  62364. static readonly ACTION_OnPointerOutTrigger: number;
  62365. /**
  62366. * On every frame
  62367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62368. */
  62369. static readonly ACTION_OnEveryFrameTrigger: number;
  62370. /**
  62371. * On intersection enter
  62372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62373. */
  62374. static readonly ACTION_OnIntersectionEnterTrigger: number;
  62375. /**
  62376. * On intersection exit
  62377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62378. */
  62379. static readonly ACTION_OnIntersectionExitTrigger: number;
  62380. /**
  62381. * On key down
  62382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62383. */
  62384. static readonly ACTION_OnKeyDownTrigger: number;
  62385. /**
  62386. * On key up
  62387. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62388. */
  62389. static readonly ACTION_OnKeyUpTrigger: number;
  62390. /**
  62391. * Billboard mode will only apply to Y axis
  62392. */
  62393. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  62394. /**
  62395. * Billboard mode will apply to all axes
  62396. */
  62397. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  62398. /**
  62399. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  62400. */
  62401. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  62402. /**
  62403. * Gets or sets base Assets URL
  62404. */
  62405. static readonly PARTICLES_BaseAssetsUrl: string;
  62406. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  62407. * Test order :
  62408. * Is the bounding sphere outside the frustum ?
  62409. * If not, are the bounding box vertices outside the frustum ?
  62410. * It not, then the cullable object is in the frustum.
  62411. */
  62412. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  62413. /** Culling strategy : Bounding Sphere Only.
  62414. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  62415. * It's also less accurate than the standard because some not visible objects can still be selected.
  62416. * Test : is the bounding sphere outside the frustum ?
  62417. * If not, then the cullable object is in the frustum.
  62418. */
  62419. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  62420. /** Culling strategy : Optimistic Inclusion.
  62421. * This in an inclusion test first, then the standard exclusion test.
  62422. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  62423. * 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.
  62424. * Anyway, it's as accurate as the standard strategy.
  62425. * Test :
  62426. * Is the cullable object bounding sphere center in the frustum ?
  62427. * If not, apply the default culling strategy.
  62428. */
  62429. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  62430. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  62431. * This in an inclusion test first, then the bounding sphere only exclusion test.
  62432. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  62433. * 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.
  62434. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  62435. * Test :
  62436. * Is the cullable object bounding sphere center in the frustum ?
  62437. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  62438. */
  62439. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  62440. /**
  62441. * No logging while loading
  62442. */
  62443. static readonly SCENELOADER_NO_LOGGING: number;
  62444. /**
  62445. * Minimal logging while loading
  62446. */
  62447. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  62448. /**
  62449. * Summary logging while loading
  62450. */
  62451. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  62452. /**
  62453. * Detailled logging while loading
  62454. */
  62455. static readonly SCENELOADER_DETAILED_LOGGING: number;
  62456. }
  62457. }
  62458. declare module BABYLON {
  62459. /**
  62460. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  62461. * Babylon.js
  62462. */
  62463. export class DomManagement {
  62464. /**
  62465. * Checks if the window object exists
  62466. * @returns true if the window object exists
  62467. */
  62468. static IsWindowObjectExist(): boolean;
  62469. /**
  62470. * Extracts text content from a DOM element hierarchy
  62471. * @param element defines the root element
  62472. * @returns a string
  62473. */
  62474. static GetDOMTextContent(element: HTMLElement): string;
  62475. }
  62476. }
  62477. declare module BABYLON {
  62478. /**
  62479. * Logger used througouht the application to allow configuration of
  62480. * the log level required for the messages.
  62481. */
  62482. export class Logger {
  62483. /**
  62484. * No log
  62485. */
  62486. static readonly NoneLogLevel: number;
  62487. /**
  62488. * Only message logs
  62489. */
  62490. static readonly MessageLogLevel: number;
  62491. /**
  62492. * Only warning logs
  62493. */
  62494. static readonly WarningLogLevel: number;
  62495. /**
  62496. * Only error logs
  62497. */
  62498. static readonly ErrorLogLevel: number;
  62499. /**
  62500. * All logs
  62501. */
  62502. static readonly AllLogLevel: number;
  62503. private static _LogCache;
  62504. /**
  62505. * Gets a value indicating the number of loading errors
  62506. * @ignorenaming
  62507. */
  62508. static errorsCount: number;
  62509. /**
  62510. * Callback called when a new log is added
  62511. */
  62512. static OnNewCacheEntry: (entry: string) => void;
  62513. private static _AddLogEntry;
  62514. private static _FormatMessage;
  62515. private static _LogDisabled;
  62516. private static _LogEnabled;
  62517. private static _WarnDisabled;
  62518. private static _WarnEnabled;
  62519. private static _ErrorDisabled;
  62520. private static _ErrorEnabled;
  62521. /**
  62522. * Log a message to the console
  62523. */
  62524. static Log: (message: string) => void;
  62525. /**
  62526. * Write a warning message to the console
  62527. */
  62528. static Warn: (message: string) => void;
  62529. /**
  62530. * Write an error message to the console
  62531. */
  62532. static Error: (message: string) => void;
  62533. /**
  62534. * Gets current log cache (list of logs)
  62535. */
  62536. static readonly LogCache: string;
  62537. /**
  62538. * Clears the log cache
  62539. */
  62540. static ClearLogCache(): void;
  62541. /**
  62542. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  62543. */
  62544. static LogLevels: number;
  62545. }
  62546. }
  62547. declare module BABYLON {
  62548. /** @hidden */
  62549. export class _TypeStore {
  62550. /** @hidden */
  62551. static RegisteredTypes: {
  62552. [key: string]: Object;
  62553. };
  62554. /** @hidden */
  62555. static GetClass(fqdn: string): any;
  62556. }
  62557. }
  62558. declare module BABYLON {
  62559. /**
  62560. * Class containing a set of static utilities functions for deep copy.
  62561. */
  62562. export class DeepCopier {
  62563. /**
  62564. * Tries to copy an object by duplicating every property
  62565. * @param source defines the source object
  62566. * @param destination defines the target object
  62567. * @param doNotCopyList defines a list of properties to avoid
  62568. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  62569. */
  62570. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  62571. }
  62572. }
  62573. declare module BABYLON {
  62574. /**
  62575. * Class containing a set of static utilities functions for precision date
  62576. */
  62577. export class PrecisionDate {
  62578. /**
  62579. * Gets either window.performance.now() if supported or Date.now() else
  62580. */
  62581. static readonly Now: number;
  62582. }
  62583. }
  62584. declare module BABYLON {
  62585. /** @hidden */
  62586. export class _DevTools {
  62587. static WarnImport(name: string): string;
  62588. }
  62589. }
  62590. declare module BABYLON {
  62591. /**
  62592. * Class used to evalaute queries containing `and` and `or` operators
  62593. */
  62594. export class AndOrNotEvaluator {
  62595. /**
  62596. * Evaluate a query
  62597. * @param query defines the query to evaluate
  62598. * @param evaluateCallback defines the callback used to filter result
  62599. * @returns true if the query matches
  62600. */
  62601. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  62602. private static _HandleParenthesisContent;
  62603. private static _SimplifyNegation;
  62604. }
  62605. }
  62606. declare module BABYLON {
  62607. /**
  62608. * Class used to store custom tags
  62609. */
  62610. export class Tags {
  62611. /**
  62612. * Adds support for tags on the given object
  62613. * @param obj defines the object to use
  62614. */
  62615. static EnableFor(obj: any): void;
  62616. /**
  62617. * Removes tags support
  62618. * @param obj defines the object to use
  62619. */
  62620. static DisableFor(obj: any): void;
  62621. /**
  62622. * Gets a boolean indicating if the given object has tags
  62623. * @param obj defines the object to use
  62624. * @returns a boolean
  62625. */
  62626. static HasTags(obj: any): boolean;
  62627. /**
  62628. * Gets the tags available on a given object
  62629. * @param obj defines the object to use
  62630. * @param asString defines if the tags must be returned as a string instead of an array of strings
  62631. * @returns the tags
  62632. */
  62633. static GetTags(obj: any, asString?: boolean): any;
  62634. /**
  62635. * Adds tags to an object
  62636. * @param obj defines the object to use
  62637. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  62638. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  62639. */
  62640. static AddTagsTo(obj: any, tagsString: string): void;
  62641. /**
  62642. * @hidden
  62643. */
  62644. static _AddTagTo(obj: any, tag: string): void;
  62645. /**
  62646. * Removes specific tags from a specific object
  62647. * @param obj defines the object to use
  62648. * @param tagsString defines the tags to remove
  62649. */
  62650. static RemoveTagsFrom(obj: any, tagsString: string): void;
  62651. /**
  62652. * @hidden
  62653. */
  62654. static _RemoveTagFrom(obj: any, tag: string): void;
  62655. /**
  62656. * Defines if tags hosted on an object match a given query
  62657. * @param obj defines the object to use
  62658. * @param tagsQuery defines the tag query
  62659. * @returns a boolean
  62660. */
  62661. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  62662. }
  62663. }
  62664. declare module BABYLON {
  62665. /**
  62666. * Manages the defines for the Material
  62667. */
  62668. export class MaterialDefines {
  62669. private _keys;
  62670. private _isDirty;
  62671. /** @hidden */
  62672. _renderId: number;
  62673. /** @hidden */
  62674. _areLightsDirty: boolean;
  62675. /** @hidden */
  62676. _areAttributesDirty: boolean;
  62677. /** @hidden */
  62678. _areTexturesDirty: boolean;
  62679. /** @hidden */
  62680. _areFresnelDirty: boolean;
  62681. /** @hidden */
  62682. _areMiscDirty: boolean;
  62683. /** @hidden */
  62684. _areImageProcessingDirty: boolean;
  62685. /** @hidden */
  62686. _normals: boolean;
  62687. /** @hidden */
  62688. _uvs: boolean;
  62689. /** @hidden */
  62690. _needNormals: boolean;
  62691. /** @hidden */
  62692. _needUVs: boolean;
  62693. /**
  62694. * Specifies if the material needs to be re-calculated
  62695. */
  62696. readonly isDirty: boolean;
  62697. /**
  62698. * Marks the material to indicate that it has been re-calculated
  62699. */
  62700. markAsProcessed(): void;
  62701. /**
  62702. * Marks the material to indicate that it needs to be re-calculated
  62703. */
  62704. markAsUnprocessed(): void;
  62705. /**
  62706. * Marks the material to indicate all of its defines need to be re-calculated
  62707. */
  62708. markAllAsDirty(): void;
  62709. /**
  62710. * Marks the material to indicate that image processing needs to be re-calculated
  62711. */
  62712. markAsImageProcessingDirty(): void;
  62713. /**
  62714. * Marks the material to indicate the lights need to be re-calculated
  62715. */
  62716. markAsLightDirty(): void;
  62717. /**
  62718. * Marks the attribute state as changed
  62719. */
  62720. markAsAttributesDirty(): void;
  62721. /**
  62722. * Marks the texture state as changed
  62723. */
  62724. markAsTexturesDirty(): void;
  62725. /**
  62726. * Marks the fresnel state as changed
  62727. */
  62728. markAsFresnelDirty(): void;
  62729. /**
  62730. * Marks the misc state as changed
  62731. */
  62732. markAsMiscDirty(): void;
  62733. /**
  62734. * Rebuilds the material defines
  62735. */
  62736. rebuild(): void;
  62737. /**
  62738. * Specifies if two material defines are equal
  62739. * @param other - A material define instance to compare to
  62740. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  62741. */
  62742. isEqual(other: MaterialDefines): boolean;
  62743. /**
  62744. * Clones this instance's defines to another instance
  62745. * @param other - material defines to clone values to
  62746. */
  62747. cloneTo(other: MaterialDefines): void;
  62748. /**
  62749. * Resets the material define values
  62750. */
  62751. reset(): void;
  62752. /**
  62753. * Converts the material define values to a string
  62754. * @returns - String of material define information
  62755. */
  62756. toString(): string;
  62757. }
  62758. }
  62759. declare module BABYLON {
  62760. /**
  62761. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  62762. */
  62763. export class PerformanceMonitor {
  62764. private _enabled;
  62765. private _rollingFrameTime;
  62766. private _lastFrameTimeMs;
  62767. /**
  62768. * constructor
  62769. * @param frameSampleSize The number of samples required to saturate the sliding window
  62770. */
  62771. constructor(frameSampleSize?: number);
  62772. /**
  62773. * Samples current frame
  62774. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  62775. */
  62776. sampleFrame(timeMs?: number): void;
  62777. /**
  62778. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62779. */
  62780. readonly averageFrameTime: number;
  62781. /**
  62782. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62783. */
  62784. readonly averageFrameTimeVariance: number;
  62785. /**
  62786. * Returns the frame time of the most recent frame
  62787. */
  62788. readonly instantaneousFrameTime: number;
  62789. /**
  62790. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  62791. */
  62792. readonly averageFPS: number;
  62793. /**
  62794. * Returns the average framerate in frames per second using the most recent frame time
  62795. */
  62796. readonly instantaneousFPS: number;
  62797. /**
  62798. * Returns true if enough samples have been taken to completely fill the sliding window
  62799. */
  62800. readonly isSaturated: boolean;
  62801. /**
  62802. * Enables contributions to the sliding window sample set
  62803. */
  62804. enable(): void;
  62805. /**
  62806. * Disables contributions to the sliding window sample set
  62807. * Samples will not be interpolated over the disabled period
  62808. */
  62809. disable(): void;
  62810. /**
  62811. * Returns true if sampling is enabled
  62812. */
  62813. readonly isEnabled: boolean;
  62814. /**
  62815. * Resets performance monitor
  62816. */
  62817. reset(): void;
  62818. }
  62819. /**
  62820. * RollingAverage
  62821. *
  62822. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  62823. */
  62824. export class RollingAverage {
  62825. /**
  62826. * Current average
  62827. */
  62828. average: number;
  62829. /**
  62830. * Current variance
  62831. */
  62832. variance: number;
  62833. protected _samples: Array<number>;
  62834. protected _sampleCount: number;
  62835. protected _pos: number;
  62836. protected _m2: number;
  62837. /**
  62838. * constructor
  62839. * @param length The number of samples required to saturate the sliding window
  62840. */
  62841. constructor(length: number);
  62842. /**
  62843. * Adds a sample to the sample set
  62844. * @param v The sample value
  62845. */
  62846. add(v: number): void;
  62847. /**
  62848. * Returns previously added values or null if outside of history or outside the sliding window domain
  62849. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  62850. * @return Value previously recorded with add() or null if outside of range
  62851. */
  62852. history(i: number): number;
  62853. /**
  62854. * Returns true if enough samples have been taken to completely fill the sliding window
  62855. * @return true if sample-set saturated
  62856. */
  62857. isSaturated(): boolean;
  62858. /**
  62859. * Resets the rolling average (equivalent to 0 samples taken so far)
  62860. */
  62861. reset(): void;
  62862. /**
  62863. * Wraps a value around the sample range boundaries
  62864. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  62865. * @return Wrapped position in sample range
  62866. */
  62867. protected _wrapPosition(i: number): number;
  62868. }
  62869. }
  62870. declare module BABYLON {
  62871. /**
  62872. * This class implement a typical dictionary using a string as key and the generic type T as value.
  62873. * The underlying implementation relies on an associative array to ensure the best performances.
  62874. * The value can be anything including 'null' but except 'undefined'
  62875. */
  62876. export class StringDictionary<T> {
  62877. /**
  62878. * This will clear this dictionary and copy the content from the 'source' one.
  62879. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  62880. * @param source the dictionary to take the content from and copy to this dictionary
  62881. */
  62882. copyFrom(source: StringDictionary<T>): void;
  62883. /**
  62884. * Get a value based from its key
  62885. * @param key the given key to get the matching value from
  62886. * @return the value if found, otherwise undefined is returned
  62887. */
  62888. get(key: string): T | undefined;
  62889. /**
  62890. * Get a value from its key or add it if it doesn't exist.
  62891. * This method will ensure you that a given key/data will be present in the dictionary.
  62892. * @param key the given key to get the matching value from
  62893. * @param factory the factory that will create the value if the key is not present in the dictionary.
  62894. * The factory will only be invoked if there's no data for the given key.
  62895. * @return the value corresponding to the key.
  62896. */
  62897. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  62898. /**
  62899. * Get a value from its key if present in the dictionary otherwise add it
  62900. * @param key the key to get the value from
  62901. * @param val if there's no such key/value pair in the dictionary add it with this value
  62902. * @return the value corresponding to the key
  62903. */
  62904. getOrAdd(key: string, val: T): T;
  62905. /**
  62906. * Check if there's a given key in the dictionary
  62907. * @param key the key to check for
  62908. * @return true if the key is present, false otherwise
  62909. */
  62910. contains(key: string): boolean;
  62911. /**
  62912. * Add a new key and its corresponding value
  62913. * @param key the key to add
  62914. * @param value the value corresponding to the key
  62915. * @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
  62916. */
  62917. add(key: string, value: T): boolean;
  62918. /**
  62919. * Update a specific value associated to a key
  62920. * @param key defines the key to use
  62921. * @param value defines the value to store
  62922. * @returns true if the value was updated (or false if the key was not found)
  62923. */
  62924. set(key: string, value: T): boolean;
  62925. /**
  62926. * Get the element of the given key and remove it from the dictionary
  62927. * @param key defines the key to search
  62928. * @returns the value associated with the key or null if not found
  62929. */
  62930. getAndRemove(key: string): Nullable<T>;
  62931. /**
  62932. * Remove a key/value from the dictionary.
  62933. * @param key the key to remove
  62934. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  62935. */
  62936. remove(key: string): boolean;
  62937. /**
  62938. * Clear the whole content of the dictionary
  62939. */
  62940. clear(): void;
  62941. /**
  62942. * Gets the current count
  62943. */
  62944. readonly count: number;
  62945. /**
  62946. * Execute a callback on each key/val of the dictionary.
  62947. * Note that you can remove any element in this dictionary in the callback implementation
  62948. * @param callback the callback to execute on a given key/value pair
  62949. */
  62950. forEach(callback: (key: string, val: T) => void): void;
  62951. /**
  62952. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  62953. * If the callback returns null or undefined the method will iterate to the next key/value pair
  62954. * Note that you can remove any element in this dictionary in the callback implementation
  62955. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  62956. * @returns the first item
  62957. */
  62958. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  62959. private _count;
  62960. private _data;
  62961. }
  62962. }
  62963. declare module BABYLON {
  62964. /**
  62965. * Helper class that provides a small promise polyfill
  62966. */
  62967. export class PromisePolyfill {
  62968. /**
  62969. * Static function used to check if the polyfill is required
  62970. * If this is the case then the function will inject the polyfill to window.Promise
  62971. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  62972. */
  62973. static Apply(force?: boolean): void;
  62974. }
  62975. }
  62976. declare module BABYLON {
  62977. /**
  62978. * Class used to store data that will be store in GPU memory
  62979. */
  62980. export class Buffer {
  62981. private _engine;
  62982. private _buffer;
  62983. /** @hidden */
  62984. _data: Nullable<DataArray>;
  62985. private _updatable;
  62986. private _instanced;
  62987. /**
  62988. * Gets the byte stride.
  62989. */
  62990. readonly byteStride: number;
  62991. /**
  62992. * Constructor
  62993. * @param engine the engine
  62994. * @param data the data to use for this buffer
  62995. * @param updatable whether the data is updatable
  62996. * @param stride the stride (optional)
  62997. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  62998. * @param instanced whether the buffer is instanced (optional)
  62999. * @param useBytes set to true if the stride in in bytes (optional)
  63000. */
  63001. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  63002. /**
  63003. * Create a new VertexBuffer based on the current buffer
  63004. * @param kind defines the vertex buffer kind (position, normal, etc.)
  63005. * @param offset defines offset in the buffer (0 by default)
  63006. * @param size defines the size in floats of attributes (position is 3 for instance)
  63007. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  63008. * @param instanced defines if the vertex buffer contains indexed data
  63009. * @param useBytes defines if the offset and stride are in bytes
  63010. * @returns the new vertex buffer
  63011. */
  63012. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  63013. /**
  63014. * Gets a boolean indicating if the Buffer is updatable?
  63015. * @returns true if the buffer is updatable
  63016. */
  63017. isUpdatable(): boolean;
  63018. /**
  63019. * Gets current buffer's data
  63020. * @returns a DataArray or null
  63021. */
  63022. getData(): Nullable<DataArray>;
  63023. /**
  63024. * Gets underlying native buffer
  63025. * @returns underlying native buffer
  63026. */
  63027. getBuffer(): Nullable<WebGLBuffer>;
  63028. /**
  63029. * Gets the stride in float32 units (i.e. byte stride / 4).
  63030. * May not be an integer if the byte stride is not divisible by 4.
  63031. * DEPRECATED. Use byteStride instead.
  63032. * @returns the stride in float32 units
  63033. */
  63034. getStrideSize(): number;
  63035. /**
  63036. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63037. * @param data defines the data to store
  63038. */
  63039. create(data?: Nullable<DataArray>): void;
  63040. /** @hidden */
  63041. _rebuild(): void;
  63042. /**
  63043. * Update current buffer data
  63044. * @param data defines the data to store
  63045. */
  63046. update(data: DataArray): void;
  63047. /**
  63048. * Updates the data directly.
  63049. * @param data the new data
  63050. * @param offset the new offset
  63051. * @param vertexCount the vertex count (optional)
  63052. * @param useBytes set to true if the offset is in bytes
  63053. */
  63054. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  63055. /**
  63056. * Release all resources
  63057. */
  63058. dispose(): void;
  63059. }
  63060. /**
  63061. * Specialized buffer used to store vertex data
  63062. */
  63063. export class VertexBuffer {
  63064. /** @hidden */
  63065. _buffer: Buffer;
  63066. private _kind;
  63067. private _size;
  63068. private _ownsBuffer;
  63069. private _instanced;
  63070. private _instanceDivisor;
  63071. /**
  63072. * The byte type.
  63073. */
  63074. static readonly BYTE: number;
  63075. /**
  63076. * The unsigned byte type.
  63077. */
  63078. static readonly UNSIGNED_BYTE: number;
  63079. /**
  63080. * The short type.
  63081. */
  63082. static readonly SHORT: number;
  63083. /**
  63084. * The unsigned short type.
  63085. */
  63086. static readonly UNSIGNED_SHORT: number;
  63087. /**
  63088. * The integer type.
  63089. */
  63090. static readonly INT: number;
  63091. /**
  63092. * The unsigned integer type.
  63093. */
  63094. static readonly UNSIGNED_INT: number;
  63095. /**
  63096. * The float type.
  63097. */
  63098. static readonly FLOAT: number;
  63099. /**
  63100. * Gets or sets the instance divisor when in instanced mode
  63101. */
  63102. instanceDivisor: number;
  63103. /**
  63104. * Gets the byte stride.
  63105. */
  63106. readonly byteStride: number;
  63107. /**
  63108. * Gets the byte offset.
  63109. */
  63110. readonly byteOffset: number;
  63111. /**
  63112. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  63113. */
  63114. readonly normalized: boolean;
  63115. /**
  63116. * Gets the data type of each component in the array.
  63117. */
  63118. readonly type: number;
  63119. /**
  63120. * Constructor
  63121. * @param engine the engine
  63122. * @param data the data to use for this vertex buffer
  63123. * @param kind the vertex buffer kind
  63124. * @param updatable whether the data is updatable
  63125. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63126. * @param stride the stride (optional)
  63127. * @param instanced whether the buffer is instanced (optional)
  63128. * @param offset the offset of the data (optional)
  63129. * @param size the number of components (optional)
  63130. * @param type the type of the component (optional)
  63131. * @param normalized whether the data contains normalized data (optional)
  63132. * @param useBytes set to true if stride and offset are in bytes (optional)
  63133. */
  63134. 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);
  63135. /** @hidden */
  63136. _rebuild(): void;
  63137. /**
  63138. * Returns the kind of the VertexBuffer (string)
  63139. * @returns a string
  63140. */
  63141. getKind(): string;
  63142. /**
  63143. * Gets a boolean indicating if the VertexBuffer is updatable?
  63144. * @returns true if the buffer is updatable
  63145. */
  63146. isUpdatable(): boolean;
  63147. /**
  63148. * Gets current buffer's data
  63149. * @returns a DataArray or null
  63150. */
  63151. getData(): Nullable<DataArray>;
  63152. /**
  63153. * Gets underlying native buffer
  63154. * @returns underlying native buffer
  63155. */
  63156. getBuffer(): Nullable<WebGLBuffer>;
  63157. /**
  63158. * Gets the stride in float32 units (i.e. byte stride / 4).
  63159. * May not be an integer if the byte stride is not divisible by 4.
  63160. * DEPRECATED. Use byteStride instead.
  63161. * @returns the stride in float32 units
  63162. */
  63163. getStrideSize(): number;
  63164. /**
  63165. * Returns the offset as a multiple of the type byte length.
  63166. * DEPRECATED. Use byteOffset instead.
  63167. * @returns the offset in bytes
  63168. */
  63169. getOffset(): number;
  63170. /**
  63171. * Returns the number of components per vertex attribute (integer)
  63172. * @returns the size in float
  63173. */
  63174. getSize(): number;
  63175. /**
  63176. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  63177. * @returns true if this buffer is instanced
  63178. */
  63179. getIsInstanced(): boolean;
  63180. /**
  63181. * Returns the instancing divisor, zero for non-instanced (integer).
  63182. * @returns a number
  63183. */
  63184. getInstanceDivisor(): number;
  63185. /**
  63186. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63187. * @param data defines the data to store
  63188. */
  63189. create(data?: DataArray): void;
  63190. /**
  63191. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  63192. * This function will create a new buffer if the current one is not updatable
  63193. * @param data defines the data to store
  63194. */
  63195. update(data: DataArray): void;
  63196. /**
  63197. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  63198. * Returns the directly updated WebGLBuffer.
  63199. * @param data the new data
  63200. * @param offset the new offset
  63201. * @param useBytes set to true if the offset is in bytes
  63202. */
  63203. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  63204. /**
  63205. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  63206. */
  63207. dispose(): void;
  63208. /**
  63209. * Enumerates each value of this vertex buffer as numbers.
  63210. * @param count the number of values to enumerate
  63211. * @param callback the callback function called for each value
  63212. */
  63213. forEach(count: number, callback: (value: number, index: number) => void): void;
  63214. /**
  63215. * Positions
  63216. */
  63217. static readonly PositionKind: string;
  63218. /**
  63219. * Normals
  63220. */
  63221. static readonly NormalKind: string;
  63222. /**
  63223. * Tangents
  63224. */
  63225. static readonly TangentKind: string;
  63226. /**
  63227. * Texture coordinates
  63228. */
  63229. static readonly UVKind: string;
  63230. /**
  63231. * Texture coordinates 2
  63232. */
  63233. static readonly UV2Kind: string;
  63234. /**
  63235. * Texture coordinates 3
  63236. */
  63237. static readonly UV3Kind: string;
  63238. /**
  63239. * Texture coordinates 4
  63240. */
  63241. static readonly UV4Kind: string;
  63242. /**
  63243. * Texture coordinates 5
  63244. */
  63245. static readonly UV5Kind: string;
  63246. /**
  63247. * Texture coordinates 6
  63248. */
  63249. static readonly UV6Kind: string;
  63250. /**
  63251. * Colors
  63252. */
  63253. static readonly ColorKind: string;
  63254. /**
  63255. * Matrix indices (for bones)
  63256. */
  63257. static readonly MatricesIndicesKind: string;
  63258. /**
  63259. * Matrix weights (for bones)
  63260. */
  63261. static readonly MatricesWeightsKind: string;
  63262. /**
  63263. * Additional matrix indices (for bones)
  63264. */
  63265. static readonly MatricesIndicesExtraKind: string;
  63266. /**
  63267. * Additional matrix weights (for bones)
  63268. */
  63269. static readonly MatricesWeightsExtraKind: string;
  63270. /**
  63271. * Deduces the stride given a kind.
  63272. * @param kind The kind string to deduce
  63273. * @returns The deduced stride
  63274. */
  63275. static DeduceStride(kind: string): number;
  63276. /**
  63277. * Gets the byte length of the given type.
  63278. * @param type the type
  63279. * @returns the number of bytes
  63280. */
  63281. static GetTypeByteLength(type: number): number;
  63282. /**
  63283. * Enumerates each value of the given parameters as numbers.
  63284. * @param data the data to enumerate
  63285. * @param byteOffset the byte offset of the data
  63286. * @param byteStride the byte stride of the data
  63287. * @param componentCount the number of components per element
  63288. * @param componentType the type of the component
  63289. * @param count the total number of components
  63290. * @param normalized whether the data is normalized
  63291. * @param callback the callback function called for each value
  63292. */
  63293. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  63294. private static _GetFloatValue;
  63295. }
  63296. }
  63297. declare module BABYLON {
  63298. /**
  63299. * Class representing spherical polynomial coefficients to the 3rd degree
  63300. */
  63301. export class SphericalPolynomial {
  63302. /**
  63303. * The x coefficients of the spherical polynomial
  63304. */
  63305. x: Vector3;
  63306. /**
  63307. * The y coefficients of the spherical polynomial
  63308. */
  63309. y: Vector3;
  63310. /**
  63311. * The z coefficients of the spherical polynomial
  63312. */
  63313. z: Vector3;
  63314. /**
  63315. * The xx coefficients of the spherical polynomial
  63316. */
  63317. xx: Vector3;
  63318. /**
  63319. * The yy coefficients of the spherical polynomial
  63320. */
  63321. yy: Vector3;
  63322. /**
  63323. * The zz coefficients of the spherical polynomial
  63324. */
  63325. zz: Vector3;
  63326. /**
  63327. * The xy coefficients of the spherical polynomial
  63328. */
  63329. xy: Vector3;
  63330. /**
  63331. * The yz coefficients of the spherical polynomial
  63332. */
  63333. yz: Vector3;
  63334. /**
  63335. * The zx coefficients of the spherical polynomial
  63336. */
  63337. zx: Vector3;
  63338. /**
  63339. * Adds an ambient color to the spherical polynomial
  63340. * @param color the color to add
  63341. */
  63342. addAmbient(color: Color3): void;
  63343. /**
  63344. * Scales the spherical polynomial by the given amount
  63345. * @param scale the amount to scale
  63346. */
  63347. scale(scale: number): void;
  63348. /**
  63349. * Gets the spherical polynomial from harmonics
  63350. * @param harmonics the spherical harmonics
  63351. * @returns the spherical polynomial
  63352. */
  63353. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  63354. /**
  63355. * Constructs a spherical polynomial from an array.
  63356. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  63357. * @returns the spherical polynomial
  63358. */
  63359. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  63360. }
  63361. /**
  63362. * Class representing spherical harmonics coefficients to the 3rd degree
  63363. */
  63364. export class SphericalHarmonics {
  63365. /**
  63366. * The l0,0 coefficients of the spherical harmonics
  63367. */
  63368. l00: Vector3;
  63369. /**
  63370. * The l1,-1 coefficients of the spherical harmonics
  63371. */
  63372. l1_1: Vector3;
  63373. /**
  63374. * The l1,0 coefficients of the spherical harmonics
  63375. */
  63376. l10: Vector3;
  63377. /**
  63378. * The l1,1 coefficients of the spherical harmonics
  63379. */
  63380. l11: Vector3;
  63381. /**
  63382. * The l2,-2 coefficients of the spherical harmonics
  63383. */
  63384. l2_2: Vector3;
  63385. /**
  63386. * The l2,-1 coefficients of the spherical harmonics
  63387. */
  63388. l2_1: Vector3;
  63389. /**
  63390. * The l2,0 coefficients of the spherical harmonics
  63391. */
  63392. l20: Vector3;
  63393. /**
  63394. * The l2,1 coefficients of the spherical harmonics
  63395. */
  63396. l21: Vector3;
  63397. /**
  63398. * The l2,2 coefficients of the spherical harmonics
  63399. */
  63400. lL22: Vector3;
  63401. /**
  63402. * Adds a light to the spherical harmonics
  63403. * @param direction the direction of the light
  63404. * @param color the color of the light
  63405. * @param deltaSolidAngle the delta solid angle of the light
  63406. */
  63407. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  63408. /**
  63409. * Scales the spherical harmonics by the given amount
  63410. * @param scale the amount to scale
  63411. */
  63412. scale(scale: number): void;
  63413. /**
  63414. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  63415. *
  63416. * ```
  63417. * E_lm = A_l * L_lm
  63418. * ```
  63419. *
  63420. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  63421. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  63422. * the scaling factors are given in equation 9.
  63423. */
  63424. convertIncidentRadianceToIrradiance(): void;
  63425. /**
  63426. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  63427. *
  63428. * ```
  63429. * L = (1/pi) * E * rho
  63430. * ```
  63431. *
  63432. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  63433. */
  63434. convertIrradianceToLambertianRadiance(): void;
  63435. /**
  63436. * Gets the spherical harmonics from polynomial
  63437. * @param polynomial the spherical polynomial
  63438. * @returns the spherical harmonics
  63439. */
  63440. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  63441. /**
  63442. * Constructs a spherical harmonics from an array.
  63443. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  63444. * @returns the spherical harmonics
  63445. */
  63446. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  63447. }
  63448. }
  63449. declare module BABYLON {
  63450. /**
  63451. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  63452. */
  63453. export interface CubeMapInfo {
  63454. /**
  63455. * The pixel array for the front face.
  63456. * This is stored in format, left to right, up to down format.
  63457. */
  63458. front: Nullable<ArrayBufferView>;
  63459. /**
  63460. * The pixel array for the back face.
  63461. * This is stored in format, left to right, up to down format.
  63462. */
  63463. back: Nullable<ArrayBufferView>;
  63464. /**
  63465. * The pixel array for the left face.
  63466. * This is stored in format, left to right, up to down format.
  63467. */
  63468. left: Nullable<ArrayBufferView>;
  63469. /**
  63470. * The pixel array for the right face.
  63471. * This is stored in format, left to right, up to down format.
  63472. */
  63473. right: Nullable<ArrayBufferView>;
  63474. /**
  63475. * The pixel array for the up face.
  63476. * This is stored in format, left to right, up to down format.
  63477. */
  63478. up: Nullable<ArrayBufferView>;
  63479. /**
  63480. * The pixel array for the down face.
  63481. * This is stored in format, left to right, up to down format.
  63482. */
  63483. down: Nullable<ArrayBufferView>;
  63484. /**
  63485. * The size of the cubemap stored.
  63486. *
  63487. * Each faces will be size * size pixels.
  63488. */
  63489. size: number;
  63490. /**
  63491. * The format of the texture.
  63492. *
  63493. * RGBA, RGB.
  63494. */
  63495. format: number;
  63496. /**
  63497. * The type of the texture data.
  63498. *
  63499. * UNSIGNED_INT, FLOAT.
  63500. */
  63501. type: number;
  63502. /**
  63503. * Specifies whether the texture is in gamma space.
  63504. */
  63505. gammaSpace: boolean;
  63506. }
  63507. /**
  63508. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  63509. */
  63510. export class PanoramaToCubeMapTools {
  63511. private static FACE_FRONT;
  63512. private static FACE_BACK;
  63513. private static FACE_RIGHT;
  63514. private static FACE_LEFT;
  63515. private static FACE_DOWN;
  63516. private static FACE_UP;
  63517. /**
  63518. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  63519. *
  63520. * @param float32Array The source data.
  63521. * @param inputWidth The width of the input panorama.
  63522. * @param inputHeight The height of the input panorama.
  63523. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  63524. * @return The cubemap data
  63525. */
  63526. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  63527. private static CreateCubemapTexture;
  63528. private static CalcProjectionSpherical;
  63529. }
  63530. }
  63531. declare module BABYLON {
  63532. /**
  63533. * Helper class dealing with the extraction of spherical polynomial dataArray
  63534. * from a cube map.
  63535. */
  63536. export class CubeMapToSphericalPolynomialTools {
  63537. private static FileFaces;
  63538. /**
  63539. * Converts a texture to the according Spherical Polynomial data.
  63540. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63541. *
  63542. * @param texture The texture to extract the information from.
  63543. * @return The Spherical Polynomial data.
  63544. */
  63545. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  63546. /**
  63547. * Converts a cubemap to the according Spherical Polynomial data.
  63548. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63549. *
  63550. * @param cubeInfo The Cube map to extract the information from.
  63551. * @return The Spherical Polynomial data.
  63552. */
  63553. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  63554. }
  63555. }
  63556. declare module BABYLON {
  63557. /**
  63558. * The engine store class is responsible to hold all the instances of Engine and Scene created
  63559. * during the life time of the application.
  63560. */
  63561. export class EngineStore {
  63562. /** Gets the list of created engines */
  63563. static Instances: Engine[];
  63564. /**
  63565. * Gets the latest created engine
  63566. */
  63567. static readonly LastCreatedEngine: Nullable<Engine>;
  63568. /**
  63569. * Gets the latest created scene
  63570. */
  63571. static readonly LastCreatedScene: Nullable<Scene>;
  63572. }
  63573. }
  63574. declare module BABYLON {
  63575. /**
  63576. * Define options used to create a render target texture
  63577. */
  63578. export class RenderTargetCreationOptions {
  63579. /**
  63580. * Specifies is mipmaps must be generated
  63581. */
  63582. generateMipMaps?: boolean;
  63583. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  63584. generateDepthBuffer?: boolean;
  63585. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  63586. generateStencilBuffer?: boolean;
  63587. /** Defines texture type (int by default) */
  63588. type?: number;
  63589. /** Defines sampling mode (trilinear by default) */
  63590. samplingMode?: number;
  63591. /** Defines format (RGBA by default) */
  63592. format?: number;
  63593. }
  63594. }
  63595. declare module BABYLON {
  63596. /**
  63597. * @hidden
  63598. **/
  63599. export class _AlphaState {
  63600. private _isAlphaBlendDirty;
  63601. private _isBlendFunctionParametersDirty;
  63602. private _isBlendEquationParametersDirty;
  63603. private _isBlendConstantsDirty;
  63604. private _alphaBlend;
  63605. private _blendFunctionParameters;
  63606. private _blendEquationParameters;
  63607. private _blendConstants;
  63608. /**
  63609. * Initializes the state.
  63610. */
  63611. constructor();
  63612. readonly isDirty: boolean;
  63613. alphaBlend: boolean;
  63614. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  63615. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  63616. setAlphaEquationParameters(rgb: number, alpha: number): void;
  63617. reset(): void;
  63618. apply(gl: WebGLRenderingContext): void;
  63619. }
  63620. }
  63621. declare module BABYLON {
  63622. /**
  63623. * @hidden
  63624. **/
  63625. export class _DepthCullingState {
  63626. private _isDepthTestDirty;
  63627. private _isDepthMaskDirty;
  63628. private _isDepthFuncDirty;
  63629. private _isCullFaceDirty;
  63630. private _isCullDirty;
  63631. private _isZOffsetDirty;
  63632. private _isFrontFaceDirty;
  63633. private _depthTest;
  63634. private _depthMask;
  63635. private _depthFunc;
  63636. private _cull;
  63637. private _cullFace;
  63638. private _zOffset;
  63639. private _frontFace;
  63640. /**
  63641. * Initializes the state.
  63642. */
  63643. constructor();
  63644. readonly isDirty: boolean;
  63645. zOffset: number;
  63646. cullFace: Nullable<number>;
  63647. cull: Nullable<boolean>;
  63648. depthFunc: Nullable<number>;
  63649. depthMask: boolean;
  63650. depthTest: boolean;
  63651. frontFace: Nullable<number>;
  63652. reset(): void;
  63653. apply(gl: WebGLRenderingContext): void;
  63654. }
  63655. }
  63656. declare module BABYLON {
  63657. /**
  63658. * @hidden
  63659. **/
  63660. export class _StencilState {
  63661. /** 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 */
  63662. static readonly ALWAYS: number;
  63663. /** Passed to stencilOperation to specify that stencil value must be kept */
  63664. static readonly KEEP: number;
  63665. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63666. static readonly REPLACE: number;
  63667. private _isStencilTestDirty;
  63668. private _isStencilMaskDirty;
  63669. private _isStencilFuncDirty;
  63670. private _isStencilOpDirty;
  63671. private _stencilTest;
  63672. private _stencilMask;
  63673. private _stencilFunc;
  63674. private _stencilFuncRef;
  63675. private _stencilFuncMask;
  63676. private _stencilOpStencilFail;
  63677. private _stencilOpDepthFail;
  63678. private _stencilOpStencilDepthPass;
  63679. readonly isDirty: boolean;
  63680. stencilFunc: number;
  63681. stencilFuncRef: number;
  63682. stencilFuncMask: number;
  63683. stencilOpStencilFail: number;
  63684. stencilOpDepthFail: number;
  63685. stencilOpStencilDepthPass: number;
  63686. stencilMask: number;
  63687. stencilTest: boolean;
  63688. constructor();
  63689. reset(): void;
  63690. apply(gl: WebGLRenderingContext): void;
  63691. }
  63692. }
  63693. declare module BABYLON {
  63694. /**
  63695. * @hidden
  63696. **/
  63697. export class _TimeToken {
  63698. _startTimeQuery: Nullable<WebGLQuery>;
  63699. _endTimeQuery: Nullable<WebGLQuery>;
  63700. _timeElapsedQuery: Nullable<WebGLQuery>;
  63701. _timeElapsedQueryEnded: boolean;
  63702. }
  63703. }
  63704. declare module BABYLON {
  63705. /**
  63706. * Internal interface used to track InternalTexture already bound to the GL context
  63707. */
  63708. export interface IInternalTextureTracker {
  63709. /**
  63710. * Gets or set the previous tracker in the list
  63711. */
  63712. previous: Nullable<IInternalTextureTracker>;
  63713. /**
  63714. * Gets or set the next tracker in the list
  63715. */
  63716. next: Nullable<IInternalTextureTracker>;
  63717. }
  63718. /**
  63719. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  63720. */
  63721. export class DummyInternalTextureTracker {
  63722. /**
  63723. * Gets or set the previous tracker in the list
  63724. */
  63725. previous: Nullable<IInternalTextureTracker>;
  63726. /**
  63727. * Gets or set the next tracker in the list
  63728. */
  63729. next: Nullable<IInternalTextureTracker>;
  63730. }
  63731. }
  63732. declare module BABYLON {
  63733. /**
  63734. * Class used to store data associated with WebGL texture data for the engine
  63735. * This class should not be used directly
  63736. */
  63737. export class InternalTexture implements IInternalTextureTracker {
  63738. /** hidden */
  63739. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  63740. /**
  63741. * The source of the texture data is unknown
  63742. */
  63743. static DATASOURCE_UNKNOWN: number;
  63744. /**
  63745. * Texture data comes from an URL
  63746. */
  63747. static DATASOURCE_URL: number;
  63748. /**
  63749. * Texture data is only used for temporary storage
  63750. */
  63751. static DATASOURCE_TEMP: number;
  63752. /**
  63753. * Texture data comes from raw data (ArrayBuffer)
  63754. */
  63755. static DATASOURCE_RAW: number;
  63756. /**
  63757. * Texture content is dynamic (video or dynamic texture)
  63758. */
  63759. static DATASOURCE_DYNAMIC: number;
  63760. /**
  63761. * Texture content is generated by rendering to it
  63762. */
  63763. static DATASOURCE_RENDERTARGET: number;
  63764. /**
  63765. * Texture content is part of a multi render target process
  63766. */
  63767. static DATASOURCE_MULTIRENDERTARGET: number;
  63768. /**
  63769. * Texture data comes from a cube data file
  63770. */
  63771. static DATASOURCE_CUBE: number;
  63772. /**
  63773. * Texture data comes from a raw cube data
  63774. */
  63775. static DATASOURCE_CUBERAW: number;
  63776. /**
  63777. * Texture data come from a prefiltered cube data file
  63778. */
  63779. static DATASOURCE_CUBEPREFILTERED: number;
  63780. /**
  63781. * Texture content is raw 3D data
  63782. */
  63783. static DATASOURCE_RAW3D: number;
  63784. /**
  63785. * Texture content is a depth texture
  63786. */
  63787. static DATASOURCE_DEPTHTEXTURE: number;
  63788. /**
  63789. * Texture data comes from a raw cube data encoded with RGBD
  63790. */
  63791. static DATASOURCE_CUBERAW_RGBD: number;
  63792. /**
  63793. * Defines if the texture is ready
  63794. */
  63795. isReady: boolean;
  63796. /**
  63797. * Defines if the texture is a cube texture
  63798. */
  63799. isCube: boolean;
  63800. /**
  63801. * Defines if the texture contains 3D data
  63802. */
  63803. is3D: boolean;
  63804. /**
  63805. * Gets the URL used to load this texture
  63806. */
  63807. url: string;
  63808. /**
  63809. * Gets the sampling mode of the texture
  63810. */
  63811. samplingMode: number;
  63812. /**
  63813. * Gets a boolean indicating if the texture needs mipmaps generation
  63814. */
  63815. generateMipMaps: boolean;
  63816. /**
  63817. * Gets the number of samples used by the texture (WebGL2+ only)
  63818. */
  63819. samples: number;
  63820. /**
  63821. * Gets the type of the texture (int, float...)
  63822. */
  63823. type: number;
  63824. /**
  63825. * Gets the format of the texture (RGB, RGBA...)
  63826. */
  63827. format: number;
  63828. /**
  63829. * Observable called when the texture is loaded
  63830. */
  63831. onLoadedObservable: Observable<InternalTexture>;
  63832. /**
  63833. * Gets the width of the texture
  63834. */
  63835. width: number;
  63836. /**
  63837. * Gets the height of the texture
  63838. */
  63839. height: number;
  63840. /**
  63841. * Gets the depth of the texture
  63842. */
  63843. depth: number;
  63844. /**
  63845. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  63846. */
  63847. baseWidth: number;
  63848. /**
  63849. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  63850. */
  63851. baseHeight: number;
  63852. /**
  63853. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  63854. */
  63855. baseDepth: number;
  63856. /**
  63857. * Gets a boolean indicating if the texture is inverted on Y axis
  63858. */
  63859. invertY: boolean;
  63860. /**
  63861. * Gets or set the previous tracker in the list
  63862. */
  63863. previous: Nullable<IInternalTextureTracker>;
  63864. /**
  63865. * Gets or set the next tracker in the list
  63866. */
  63867. next: Nullable<IInternalTextureTracker>;
  63868. /** @hidden */
  63869. _invertVScale: boolean;
  63870. /** @hidden */
  63871. _initialSlot: number;
  63872. /** @hidden */
  63873. _designatedSlot: number;
  63874. /** @hidden */
  63875. _dataSource: number;
  63876. /** @hidden */
  63877. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  63878. /** @hidden */
  63879. _bufferView: Nullable<ArrayBufferView>;
  63880. /** @hidden */
  63881. _bufferViewArray: Nullable<ArrayBufferView[]>;
  63882. /** @hidden */
  63883. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  63884. /** @hidden */
  63885. _size: number;
  63886. /** @hidden */
  63887. _extension: string;
  63888. /** @hidden */
  63889. _files: Nullable<string[]>;
  63890. /** @hidden */
  63891. _workingCanvas: HTMLCanvasElement;
  63892. /** @hidden */
  63893. _workingContext: CanvasRenderingContext2D;
  63894. /** @hidden */
  63895. _framebuffer: Nullable<WebGLFramebuffer>;
  63896. /** @hidden */
  63897. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  63898. /** @hidden */
  63899. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  63900. /** @hidden */
  63901. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  63902. /** @hidden */
  63903. _attachments: Nullable<number[]>;
  63904. /** @hidden */
  63905. _cachedCoordinatesMode: Nullable<number>;
  63906. /** @hidden */
  63907. _cachedWrapU: Nullable<number>;
  63908. /** @hidden */
  63909. _cachedWrapV: Nullable<number>;
  63910. /** @hidden */
  63911. _cachedWrapR: Nullable<number>;
  63912. /** @hidden */
  63913. _cachedAnisotropicFilteringLevel: Nullable<number>;
  63914. /** @hidden */
  63915. _isDisabled: boolean;
  63916. /** @hidden */
  63917. _compression: Nullable<string>;
  63918. /** @hidden */
  63919. _generateStencilBuffer: boolean;
  63920. /** @hidden */
  63921. _generateDepthBuffer: boolean;
  63922. /** @hidden */
  63923. _comparisonFunction: number;
  63924. /** @hidden */
  63925. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  63926. /** @hidden */
  63927. _lodGenerationScale: number;
  63928. /** @hidden */
  63929. _lodGenerationOffset: number;
  63930. /** @hidden */
  63931. _lodTextureHigh: BaseTexture;
  63932. /** @hidden */
  63933. _lodTextureMid: BaseTexture;
  63934. /** @hidden */
  63935. _lodTextureLow: BaseTexture;
  63936. /** @hidden */
  63937. _isRGBD: boolean;
  63938. /** @hidden */
  63939. _webGLTexture: Nullable<WebGLTexture>;
  63940. /** @hidden */
  63941. _references: number;
  63942. private _engine;
  63943. /**
  63944. * Gets the Engine the texture belongs to.
  63945. * @returns The babylon engine
  63946. */
  63947. getEngine(): Engine;
  63948. /**
  63949. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  63950. */
  63951. readonly dataSource: number;
  63952. /**
  63953. * Creates a new InternalTexture
  63954. * @param engine defines the engine to use
  63955. * @param dataSource defines the type of data that will be used
  63956. * @param delayAllocation if the texture allocation should be delayed (default: false)
  63957. */
  63958. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  63959. /**
  63960. * Increments the number of references (ie. the number of Texture that point to it)
  63961. */
  63962. incrementReferences(): void;
  63963. /**
  63964. * Change the size of the texture (not the size of the content)
  63965. * @param width defines the new width
  63966. * @param height defines the new height
  63967. * @param depth defines the new depth (1 by default)
  63968. */
  63969. updateSize(width: int, height: int, depth?: int): void;
  63970. /** @hidden */
  63971. _rebuild(): void;
  63972. /** @hidden */
  63973. _swapAndDie(target: InternalTexture): void;
  63974. /**
  63975. * Dispose the current allocated resources
  63976. */
  63977. dispose(): void;
  63978. }
  63979. }
  63980. declare module BABYLON {
  63981. /**
  63982. * This represents the main contract an easing function should follow.
  63983. * Easing functions are used throughout the animation system.
  63984. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63985. */
  63986. export interface IEasingFunction {
  63987. /**
  63988. * Given an input gradient between 0 and 1, this returns the corrseponding value
  63989. * of the easing function.
  63990. * The link below provides some of the most common examples of easing functions.
  63991. * @see https://easings.net/
  63992. * @param gradient Defines the value between 0 and 1 we want the easing value for
  63993. * @returns the corresponding value on the curve defined by the easing function
  63994. */
  63995. ease(gradient: number): number;
  63996. }
  63997. /**
  63998. * Base class used for every default easing function.
  63999. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64000. */
  64001. export class EasingFunction implements IEasingFunction {
  64002. /**
  64003. * Interpolation follows the mathematical formula associated with the easing function.
  64004. */
  64005. static readonly EASINGMODE_EASEIN: number;
  64006. /**
  64007. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  64008. */
  64009. static readonly EASINGMODE_EASEOUT: number;
  64010. /**
  64011. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  64012. */
  64013. static readonly EASINGMODE_EASEINOUT: number;
  64014. private _easingMode;
  64015. /**
  64016. * Sets the easing mode of the current function.
  64017. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  64018. */
  64019. setEasingMode(easingMode: number): void;
  64020. /**
  64021. * Gets the current easing mode.
  64022. * @returns the easing mode
  64023. */
  64024. getEasingMode(): number;
  64025. /**
  64026. * @hidden
  64027. */
  64028. easeInCore(gradient: number): number;
  64029. /**
  64030. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64031. * of the easing function.
  64032. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64033. * @returns the corresponding value on the curve defined by the easing function
  64034. */
  64035. ease(gradient: number): number;
  64036. }
  64037. /**
  64038. * Easing function with a circle shape (see link below).
  64039. * @see https://easings.net/#easeInCirc
  64040. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64041. */
  64042. export class CircleEase extends EasingFunction implements IEasingFunction {
  64043. /** @hidden */
  64044. easeInCore(gradient: number): number;
  64045. }
  64046. /**
  64047. * Easing function with a ease back shape (see link below).
  64048. * @see https://easings.net/#easeInBack
  64049. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64050. */
  64051. export class BackEase extends EasingFunction implements IEasingFunction {
  64052. /** Defines the amplitude of the function */
  64053. amplitude: number;
  64054. /**
  64055. * Instantiates a back ease easing
  64056. * @see https://easings.net/#easeInBack
  64057. * @param amplitude Defines the amplitude of the function
  64058. */
  64059. constructor(
  64060. /** Defines the amplitude of the function */
  64061. amplitude?: number);
  64062. /** @hidden */
  64063. easeInCore(gradient: number): number;
  64064. }
  64065. /**
  64066. * Easing function with a bouncing shape (see link below).
  64067. * @see https://easings.net/#easeInBounce
  64068. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64069. */
  64070. export class BounceEase extends EasingFunction implements IEasingFunction {
  64071. /** Defines the number of bounces */
  64072. bounces: number;
  64073. /** Defines the amplitude of the bounce */
  64074. bounciness: number;
  64075. /**
  64076. * Instantiates a bounce easing
  64077. * @see https://easings.net/#easeInBounce
  64078. * @param bounces Defines the number of bounces
  64079. * @param bounciness Defines the amplitude of the bounce
  64080. */
  64081. constructor(
  64082. /** Defines the number of bounces */
  64083. bounces?: number,
  64084. /** Defines the amplitude of the bounce */
  64085. bounciness?: number);
  64086. /** @hidden */
  64087. easeInCore(gradient: number): number;
  64088. }
  64089. /**
  64090. * Easing function with a power of 3 shape (see link below).
  64091. * @see https://easings.net/#easeInCubic
  64092. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64093. */
  64094. export class CubicEase extends EasingFunction implements IEasingFunction {
  64095. /** @hidden */
  64096. easeInCore(gradient: number): number;
  64097. }
  64098. /**
  64099. * Easing function with an elastic shape (see link below).
  64100. * @see https://easings.net/#easeInElastic
  64101. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64102. */
  64103. export class ElasticEase extends EasingFunction implements IEasingFunction {
  64104. /** Defines the number of oscillations*/
  64105. oscillations: number;
  64106. /** Defines the amplitude of the oscillations*/
  64107. springiness: number;
  64108. /**
  64109. * Instantiates an elastic easing function
  64110. * @see https://easings.net/#easeInElastic
  64111. * @param oscillations Defines the number of oscillations
  64112. * @param springiness Defines the amplitude of the oscillations
  64113. */
  64114. constructor(
  64115. /** Defines the number of oscillations*/
  64116. oscillations?: number,
  64117. /** Defines the amplitude of the oscillations*/
  64118. springiness?: number);
  64119. /** @hidden */
  64120. easeInCore(gradient: number): number;
  64121. }
  64122. /**
  64123. * Easing function with an exponential shape (see link below).
  64124. * @see https://easings.net/#easeInExpo
  64125. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64126. */
  64127. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  64128. /** Defines the exponent of the function */
  64129. exponent: number;
  64130. /**
  64131. * Instantiates an exponential easing function
  64132. * @see https://easings.net/#easeInExpo
  64133. * @param exponent Defines the exponent of the function
  64134. */
  64135. constructor(
  64136. /** Defines the exponent of the function */
  64137. exponent?: number);
  64138. /** @hidden */
  64139. easeInCore(gradient: number): number;
  64140. }
  64141. /**
  64142. * Easing function with a power shape (see link below).
  64143. * @see https://easings.net/#easeInQuad
  64144. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64145. */
  64146. export class PowerEase extends EasingFunction implements IEasingFunction {
  64147. /** Defines the power of the function */
  64148. power: number;
  64149. /**
  64150. * Instantiates an power base easing function
  64151. * @see https://easings.net/#easeInQuad
  64152. * @param power Defines the power of the function
  64153. */
  64154. constructor(
  64155. /** Defines the power of the function */
  64156. power?: number);
  64157. /** @hidden */
  64158. easeInCore(gradient: number): number;
  64159. }
  64160. /**
  64161. * Easing function with a power of 2 shape (see link below).
  64162. * @see https://easings.net/#easeInQuad
  64163. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64164. */
  64165. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  64166. /** @hidden */
  64167. easeInCore(gradient: number): number;
  64168. }
  64169. /**
  64170. * Easing function with a power of 4 shape (see link below).
  64171. * @see https://easings.net/#easeInQuart
  64172. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64173. */
  64174. export class QuarticEase extends EasingFunction implements IEasingFunction {
  64175. /** @hidden */
  64176. easeInCore(gradient: number): number;
  64177. }
  64178. /**
  64179. * Easing function with a power of 5 shape (see link below).
  64180. * @see https://easings.net/#easeInQuint
  64181. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64182. */
  64183. export class QuinticEase extends EasingFunction implements IEasingFunction {
  64184. /** @hidden */
  64185. easeInCore(gradient: number): number;
  64186. }
  64187. /**
  64188. * Easing function with a sin shape (see link below).
  64189. * @see https://easings.net/#easeInSine
  64190. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64191. */
  64192. export class SineEase extends EasingFunction implements IEasingFunction {
  64193. /** @hidden */
  64194. easeInCore(gradient: number): number;
  64195. }
  64196. /**
  64197. * Easing function with a bezier shape (see link below).
  64198. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  64199. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64200. */
  64201. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  64202. /** Defines the x component of the start tangent in the bezier curve */
  64203. x1: number;
  64204. /** Defines the y component of the start tangent in the bezier curve */
  64205. y1: number;
  64206. /** Defines the x component of the end tangent in the bezier curve */
  64207. x2: number;
  64208. /** Defines the y component of the end tangent in the bezier curve */
  64209. y2: number;
  64210. /**
  64211. * Instantiates a bezier function
  64212. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  64213. * @param x1 Defines the x component of the start tangent in the bezier curve
  64214. * @param y1 Defines the y component of the start tangent in the bezier curve
  64215. * @param x2 Defines the x component of the end tangent in the bezier curve
  64216. * @param y2 Defines the y component of the end tangent in the bezier curve
  64217. */
  64218. constructor(
  64219. /** Defines the x component of the start tangent in the bezier curve */
  64220. x1?: number,
  64221. /** Defines the y component of the start tangent in the bezier curve */
  64222. y1?: number,
  64223. /** Defines the x component of the end tangent in the bezier curve */
  64224. x2?: number,
  64225. /** Defines the y component of the end tangent in the bezier curve */
  64226. y2?: number);
  64227. /** @hidden */
  64228. easeInCore(gradient: number): number;
  64229. }
  64230. }
  64231. declare module BABYLON {
  64232. /**
  64233. * Defines an interface which represents an animation key frame
  64234. */
  64235. export interface IAnimationKey {
  64236. /**
  64237. * Frame of the key frame
  64238. */
  64239. frame: number;
  64240. /**
  64241. * Value at the specifies key frame
  64242. */
  64243. value: any;
  64244. /**
  64245. * The input tangent for the cubic hermite spline
  64246. */
  64247. inTangent?: any;
  64248. /**
  64249. * The output tangent for the cubic hermite spline
  64250. */
  64251. outTangent?: any;
  64252. /**
  64253. * The animation interpolation type
  64254. */
  64255. interpolation?: AnimationKeyInterpolation;
  64256. }
  64257. /**
  64258. * Enum for the animation key frame interpolation type
  64259. */
  64260. export enum AnimationKeyInterpolation {
  64261. /**
  64262. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  64263. */
  64264. STEP = 1
  64265. }
  64266. }
  64267. declare module BABYLON {
  64268. /**
  64269. * Represents the range of an animation
  64270. */
  64271. export class AnimationRange {
  64272. /**The name of the animation range**/
  64273. name: string;
  64274. /**The starting frame of the animation */
  64275. from: number;
  64276. /**The ending frame of the animation*/
  64277. to: number;
  64278. /**
  64279. * Initializes the range of an animation
  64280. * @param name The name of the animation range
  64281. * @param from The starting frame of the animation
  64282. * @param to The ending frame of the animation
  64283. */
  64284. constructor(
  64285. /**The name of the animation range**/
  64286. name: string,
  64287. /**The starting frame of the animation */
  64288. from: number,
  64289. /**The ending frame of the animation*/
  64290. to: number);
  64291. /**
  64292. * Makes a copy of the animation range
  64293. * @returns A copy of the animation range
  64294. */
  64295. clone(): AnimationRange;
  64296. }
  64297. }
  64298. declare module BABYLON {
  64299. /**
  64300. * Composed of a frame, and an action function
  64301. */
  64302. export class AnimationEvent {
  64303. /** The frame for which the event is triggered **/
  64304. frame: number;
  64305. /** The event to perform when triggered **/
  64306. action: (currentFrame: number) => void;
  64307. /** Specifies if the event should be triggered only once**/
  64308. onlyOnce?: boolean | undefined;
  64309. /**
  64310. * Specifies if the animation event is done
  64311. */
  64312. isDone: boolean;
  64313. /**
  64314. * Initializes the animation event
  64315. * @param frame The frame for which the event is triggered
  64316. * @param action The event to perform when triggered
  64317. * @param onlyOnce Specifies if the event should be triggered only once
  64318. */
  64319. constructor(
  64320. /** The frame for which the event is triggered **/
  64321. frame: number,
  64322. /** The event to perform when triggered **/
  64323. action: (currentFrame: number) => void,
  64324. /** Specifies if the event should be triggered only once**/
  64325. onlyOnce?: boolean | undefined);
  64326. /** @hidden */
  64327. _clone(): AnimationEvent;
  64328. }
  64329. }
  64330. declare module BABYLON {
  64331. /**
  64332. * Interface used to define a behavior
  64333. */
  64334. export interface Behavior<T> {
  64335. /** gets or sets behavior's name */
  64336. name: string;
  64337. /**
  64338. * Function called when the behavior needs to be initialized (after attaching it to a target)
  64339. */
  64340. init(): void;
  64341. /**
  64342. * Called when the behavior is attached to a target
  64343. * @param target defines the target where the behavior is attached to
  64344. */
  64345. attach(target: T): void;
  64346. /**
  64347. * Called when the behavior is detached from its target
  64348. */
  64349. detach(): void;
  64350. }
  64351. /**
  64352. * Interface implemented by classes supporting behaviors
  64353. */
  64354. export interface IBehaviorAware<T> {
  64355. /**
  64356. * Attach a behavior
  64357. * @param behavior defines the behavior to attach
  64358. * @returns the current host
  64359. */
  64360. addBehavior(behavior: Behavior<T>): T;
  64361. /**
  64362. * Remove a behavior from the current object
  64363. * @param behavior defines the behavior to detach
  64364. * @returns the current host
  64365. */
  64366. removeBehavior(behavior: Behavior<T>): T;
  64367. /**
  64368. * Gets a behavior using its name to search
  64369. * @param name defines the name to search
  64370. * @returns the behavior or null if not found
  64371. */
  64372. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  64373. }
  64374. }
  64375. declare module BABYLON {
  64376. /**
  64377. * @hidden
  64378. */
  64379. export class IntersectionInfo {
  64380. bu: Nullable<number>;
  64381. bv: Nullable<number>;
  64382. distance: number;
  64383. faceId: number;
  64384. subMeshId: number;
  64385. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  64386. }
  64387. }
  64388. declare module BABYLON {
  64389. /**
  64390. * Class used to store bounding sphere information
  64391. */
  64392. export class BoundingSphere {
  64393. /**
  64394. * Gets the center of the bounding sphere in local space
  64395. */
  64396. readonly center: Vector3;
  64397. /**
  64398. * Radius of the bounding sphere in local space
  64399. */
  64400. radius: number;
  64401. /**
  64402. * Gets the center of the bounding sphere in world space
  64403. */
  64404. readonly centerWorld: Vector3;
  64405. /**
  64406. * Radius of the bounding sphere in world space
  64407. */
  64408. radiusWorld: number;
  64409. /**
  64410. * Gets the minimum vector in local space
  64411. */
  64412. readonly minimum: Vector3;
  64413. /**
  64414. * Gets the maximum vector in local space
  64415. */
  64416. readonly maximum: Vector3;
  64417. private _worldMatrix;
  64418. private static readonly TmpVector3;
  64419. /**
  64420. * Creates a new bounding sphere
  64421. * @param min defines the minimum vector (in local space)
  64422. * @param max defines the maximum vector (in local space)
  64423. * @param worldMatrix defines the new world matrix
  64424. */
  64425. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64426. /**
  64427. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  64428. * @param min defines the new minimum vector (in local space)
  64429. * @param max defines the new maximum vector (in local space)
  64430. * @param worldMatrix defines the new world matrix
  64431. */
  64432. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64433. /**
  64434. * Scale the current bounding sphere by applying a scale factor
  64435. * @param factor defines the scale factor to apply
  64436. * @returns the current bounding box
  64437. */
  64438. scale(factor: number): BoundingSphere;
  64439. /**
  64440. * Gets the world matrix of the bounding box
  64441. * @returns a matrix
  64442. */
  64443. getWorldMatrix(): DeepImmutable<Matrix>;
  64444. /** @hidden */
  64445. _update(worldMatrix: DeepImmutable<Matrix>): void;
  64446. /**
  64447. * Tests if the bounding sphere is intersecting the frustum planes
  64448. * @param frustumPlanes defines the frustum planes to test
  64449. * @returns true if there is an intersection
  64450. */
  64451. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64452. /**
  64453. * Tests if the bounding sphere center is in between the frustum planes.
  64454. * Used for optimistic fast inclusion.
  64455. * @param frustumPlanes defines the frustum planes to test
  64456. * @returns true if the sphere center is in between the frustum planes
  64457. */
  64458. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64459. /**
  64460. * Tests if a point is inside the bounding sphere
  64461. * @param point defines the point to test
  64462. * @returns true if the point is inside the bounding sphere
  64463. */
  64464. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64465. /**
  64466. * Checks if two sphere intersct
  64467. * @param sphere0 sphere 0
  64468. * @param sphere1 sphere 1
  64469. * @returns true if the speres intersect
  64470. */
  64471. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  64472. }
  64473. }
  64474. declare module BABYLON {
  64475. /**
  64476. * Class used to store bounding box information
  64477. */
  64478. export class BoundingBox implements ICullable {
  64479. /**
  64480. * Gets the 8 vectors representing the bounding box in local space
  64481. */
  64482. readonly vectors: Vector3[];
  64483. /**
  64484. * Gets the center of the bounding box in local space
  64485. */
  64486. readonly center: Vector3;
  64487. /**
  64488. * Gets the center of the bounding box in world space
  64489. */
  64490. readonly centerWorld: Vector3;
  64491. /**
  64492. * Gets the extend size in local space
  64493. */
  64494. readonly extendSize: Vector3;
  64495. /**
  64496. * Gets the extend size in world space
  64497. */
  64498. readonly extendSizeWorld: Vector3;
  64499. /**
  64500. * Gets the OBB (object bounding box) directions
  64501. */
  64502. readonly directions: Vector3[];
  64503. /**
  64504. * Gets the 8 vectors representing the bounding box in world space
  64505. */
  64506. readonly vectorsWorld: Vector3[];
  64507. /**
  64508. * Gets the minimum vector in world space
  64509. */
  64510. readonly minimumWorld: Vector3;
  64511. /**
  64512. * Gets the maximum vector in world space
  64513. */
  64514. readonly maximumWorld: Vector3;
  64515. /**
  64516. * Gets the minimum vector in local space
  64517. */
  64518. readonly minimum: Vector3;
  64519. /**
  64520. * Gets the maximum vector in local space
  64521. */
  64522. readonly maximum: Vector3;
  64523. private _worldMatrix;
  64524. private static readonly TmpVector3;
  64525. /**
  64526. * @hidden
  64527. */
  64528. _tag: number;
  64529. /**
  64530. * Creates a new bounding box
  64531. * @param min defines the minimum vector (in local space)
  64532. * @param max defines the maximum vector (in local space)
  64533. * @param worldMatrix defines the new world matrix
  64534. */
  64535. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64536. /**
  64537. * Recreates the entire bounding box from scratch as if we call the constructor in place
  64538. * @param min defines the new minimum vector (in local space)
  64539. * @param max defines the new maximum vector (in local space)
  64540. * @param worldMatrix defines the new world matrix
  64541. */
  64542. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64543. /**
  64544. * Scale the current bounding box by applying a scale factor
  64545. * @param factor defines the scale factor to apply
  64546. * @returns the current bounding box
  64547. */
  64548. scale(factor: number): BoundingBox;
  64549. /**
  64550. * Gets the world matrix of the bounding box
  64551. * @returns a matrix
  64552. */
  64553. getWorldMatrix(): DeepImmutable<Matrix>;
  64554. /** @hidden */
  64555. _update(world: DeepImmutable<Matrix>): void;
  64556. /**
  64557. * Tests if the bounding box is intersecting the frustum planes
  64558. * @param frustumPlanes defines the frustum planes to test
  64559. * @returns true if there is an intersection
  64560. */
  64561. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64562. /**
  64563. * Tests if the bounding box is entirely inside the frustum planes
  64564. * @param frustumPlanes defines the frustum planes to test
  64565. * @returns true if there is an inclusion
  64566. */
  64567. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64568. /**
  64569. * Tests if a point is inside the bounding box
  64570. * @param point defines the point to test
  64571. * @returns true if the point is inside the bounding box
  64572. */
  64573. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64574. /**
  64575. * Tests if the bounding box intersects with a bounding sphere
  64576. * @param sphere defines the sphere to test
  64577. * @returns true if there is an intersection
  64578. */
  64579. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  64580. /**
  64581. * Tests if the bounding box intersects with a box defined by a min and max vectors
  64582. * @param min defines the min vector to use
  64583. * @param max defines the max vector to use
  64584. * @returns true if there is an intersection
  64585. */
  64586. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  64587. /**
  64588. * Tests if two bounding boxes are intersections
  64589. * @param box0 defines the first box to test
  64590. * @param box1 defines the second box to test
  64591. * @returns true if there is an intersection
  64592. */
  64593. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  64594. /**
  64595. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  64596. * @param minPoint defines the minimum vector of the bounding box
  64597. * @param maxPoint defines the maximum vector of the bounding box
  64598. * @param sphereCenter defines the sphere center
  64599. * @param sphereRadius defines the sphere radius
  64600. * @returns true if there is an intersection
  64601. */
  64602. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  64603. /**
  64604. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  64605. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64606. * @param frustumPlanes defines the frustum planes to test
  64607. * @return true if there is an inclusion
  64608. */
  64609. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64610. /**
  64611. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  64612. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64613. * @param frustumPlanes defines the frustum planes to test
  64614. * @return true if there is an intersection
  64615. */
  64616. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64617. }
  64618. }
  64619. declare module BABYLON {
  64620. /** @hidden */
  64621. export class Collider {
  64622. /** Define if a collision was found */
  64623. collisionFound: boolean;
  64624. /**
  64625. * Define last intersection point in local space
  64626. */
  64627. intersectionPoint: Vector3;
  64628. /**
  64629. * Define last collided mesh
  64630. */
  64631. collidedMesh: Nullable<AbstractMesh>;
  64632. private _collisionPoint;
  64633. private _planeIntersectionPoint;
  64634. private _tempVector;
  64635. private _tempVector2;
  64636. private _tempVector3;
  64637. private _tempVector4;
  64638. private _edge;
  64639. private _baseToVertex;
  64640. private _destinationPoint;
  64641. private _slidePlaneNormal;
  64642. private _displacementVector;
  64643. /** @hidden */
  64644. _radius: Vector3;
  64645. /** @hidden */
  64646. _retry: number;
  64647. private _velocity;
  64648. private _basePoint;
  64649. private _epsilon;
  64650. /** @hidden */
  64651. _velocityWorldLength: number;
  64652. /** @hidden */
  64653. _basePointWorld: Vector3;
  64654. private _velocityWorld;
  64655. private _normalizedVelocity;
  64656. /** @hidden */
  64657. _initialVelocity: Vector3;
  64658. /** @hidden */
  64659. _initialPosition: Vector3;
  64660. private _nearestDistance;
  64661. private _collisionMask;
  64662. collisionMask: number;
  64663. /**
  64664. * Gets the plane normal used to compute the sliding response (in local space)
  64665. */
  64666. readonly slidePlaneNormal: Vector3;
  64667. /** @hidden */
  64668. _initialize(source: Vector3, dir: Vector3, e: number): void;
  64669. /** @hidden */
  64670. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  64671. /** @hidden */
  64672. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  64673. /** @hidden */
  64674. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  64675. /** @hidden */
  64676. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  64677. /** @hidden */
  64678. _getResponse(pos: Vector3, vel: Vector3): void;
  64679. }
  64680. }
  64681. declare module BABYLON {
  64682. /**
  64683. * Interface for cullable objects
  64684. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  64685. */
  64686. export interface ICullable {
  64687. /**
  64688. * Checks if the object or part of the object is in the frustum
  64689. * @param frustumPlanes Camera near/planes
  64690. * @returns true if the object is in frustum otherwise false
  64691. */
  64692. isInFrustum(frustumPlanes: Plane[]): boolean;
  64693. /**
  64694. * Checks if a cullable object (mesh...) is in the camera frustum
  64695. * Unlike isInFrustum this cheks the full bounding box
  64696. * @param frustumPlanes Camera near/planes
  64697. * @returns true if the object is in frustum otherwise false
  64698. */
  64699. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  64700. }
  64701. /**
  64702. * Info for a bounding data of a mesh
  64703. */
  64704. export class BoundingInfo implements ICullable {
  64705. /**
  64706. * Bounding box for the mesh
  64707. */
  64708. readonly boundingBox: BoundingBox;
  64709. /**
  64710. * Bounding sphere for the mesh
  64711. */
  64712. readonly boundingSphere: BoundingSphere;
  64713. private _isLocked;
  64714. private static readonly TmpVector3;
  64715. /**
  64716. * Constructs bounding info
  64717. * @param minimum min vector of the bounding box/sphere
  64718. * @param maximum max vector of the bounding box/sphere
  64719. * @param worldMatrix defines the new world matrix
  64720. */
  64721. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64722. /**
  64723. * Recreates the entire bounding info from scratch as if we call the constructor in place
  64724. * @param min defines the new minimum vector (in local space)
  64725. * @param max defines the new maximum vector (in local space)
  64726. * @param worldMatrix defines the new world matrix
  64727. */
  64728. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64729. /**
  64730. * min vector of the bounding box/sphere
  64731. */
  64732. readonly minimum: Vector3;
  64733. /**
  64734. * max vector of the bounding box/sphere
  64735. */
  64736. readonly maximum: Vector3;
  64737. /**
  64738. * If the info is locked and won't be updated to avoid perf overhead
  64739. */
  64740. isLocked: boolean;
  64741. /**
  64742. * Updates the bounding sphere and box
  64743. * @param world world matrix to be used to update
  64744. */
  64745. update(world: DeepImmutable<Matrix>): void;
  64746. /**
  64747. * Recreate the bounding info to be centered around a specific point given a specific extend.
  64748. * @param center New center of the bounding info
  64749. * @param extend New extend of the bounding info
  64750. * @returns the current bounding info
  64751. */
  64752. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  64753. /**
  64754. * Scale the current bounding info by applying a scale factor
  64755. * @param factor defines the scale factor to apply
  64756. * @returns the current bounding info
  64757. */
  64758. scale(factor: number): BoundingInfo;
  64759. /**
  64760. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  64761. * @param frustumPlanes defines the frustum to test
  64762. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  64763. * @returns true if the bounding info is in the frustum planes
  64764. */
  64765. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  64766. /**
  64767. * Gets the world distance between the min and max points of the bounding box
  64768. */
  64769. readonly diagonalLength: number;
  64770. /**
  64771. * Checks if a cullable object (mesh...) is in the camera frustum
  64772. * Unlike isInFrustum this cheks the full bounding box
  64773. * @param frustumPlanes Camera near/planes
  64774. * @returns true if the object is in frustum otherwise false
  64775. */
  64776. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64777. /** @hidden */
  64778. _checkCollision(collider: Collider): boolean;
  64779. /**
  64780. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  64781. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64782. * @param point the point to check intersection with
  64783. * @returns if the point intersects
  64784. */
  64785. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64786. /**
  64787. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  64788. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64789. * @param boundingInfo the bounding info to check intersection with
  64790. * @param precise if the intersection should be done using OBB
  64791. * @returns if the bounding info intersects
  64792. */
  64793. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  64794. }
  64795. }
  64796. declare module BABYLON {
  64797. /**
  64798. * Defines an array and its length.
  64799. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  64800. */
  64801. export interface ISmartArrayLike<T> {
  64802. /**
  64803. * The data of the array.
  64804. */
  64805. data: Array<T>;
  64806. /**
  64807. * The active length of the array.
  64808. */
  64809. length: number;
  64810. }
  64811. /**
  64812. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64813. */
  64814. export class SmartArray<T> implements ISmartArrayLike<T> {
  64815. /**
  64816. * The full set of data from the array.
  64817. */
  64818. data: Array<T>;
  64819. /**
  64820. * The active length of the array.
  64821. */
  64822. length: number;
  64823. protected _id: number;
  64824. /**
  64825. * Instantiates a Smart Array.
  64826. * @param capacity defines the default capacity of the array.
  64827. */
  64828. constructor(capacity: number);
  64829. /**
  64830. * Pushes a value at the end of the active data.
  64831. * @param value defines the object to push in the array.
  64832. */
  64833. push(value: T): void;
  64834. /**
  64835. * Iterates over the active data and apply the lambda to them.
  64836. * @param func defines the action to apply on each value.
  64837. */
  64838. forEach(func: (content: T) => void): void;
  64839. /**
  64840. * Sorts the full sets of data.
  64841. * @param compareFn defines the comparison function to apply.
  64842. */
  64843. sort(compareFn: (a: T, b: T) => number): void;
  64844. /**
  64845. * Resets the active data to an empty array.
  64846. */
  64847. reset(): void;
  64848. /**
  64849. * Releases all the data from the array as well as the array.
  64850. */
  64851. dispose(): void;
  64852. /**
  64853. * Concats the active data with a given array.
  64854. * @param array defines the data to concatenate with.
  64855. */
  64856. concat(array: any): void;
  64857. /**
  64858. * Returns the position of a value in the active data.
  64859. * @param value defines the value to find the index for
  64860. * @returns the index if found in the active data otherwise -1
  64861. */
  64862. indexOf(value: T): number;
  64863. /**
  64864. * Returns whether an element is part of the active data.
  64865. * @param value defines the value to look for
  64866. * @returns true if found in the active data otherwise false
  64867. */
  64868. contains(value: T): boolean;
  64869. private static _GlobalId;
  64870. }
  64871. /**
  64872. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64873. * The data in this array can only be present once
  64874. */
  64875. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  64876. private _duplicateId;
  64877. /**
  64878. * Pushes a value at the end of the active data.
  64879. * THIS DOES NOT PREVENT DUPPLICATE DATA
  64880. * @param value defines the object to push in the array.
  64881. */
  64882. push(value: T): void;
  64883. /**
  64884. * Pushes a value at the end of the active data.
  64885. * If the data is already present, it won t be added again
  64886. * @param value defines the object to push in the array.
  64887. * @returns true if added false if it was already present
  64888. */
  64889. pushNoDuplicate(value: T): boolean;
  64890. /**
  64891. * Resets the active data to an empty array.
  64892. */
  64893. reset(): void;
  64894. /**
  64895. * Concats the active data with a given array.
  64896. * This ensures no dupplicate will be present in the result.
  64897. * @param array defines the data to concatenate with.
  64898. */
  64899. concatWithNoDuplicate(array: any): void;
  64900. }
  64901. }
  64902. declare module BABYLON {
  64903. /**
  64904. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64905. * separate meshes. This can be use to improve performances.
  64906. * @see http://doc.babylonjs.com/how_to/multi_materials
  64907. */
  64908. export class MultiMaterial extends Material {
  64909. private _subMaterials;
  64910. /**
  64911. * Gets or Sets the list of Materials used within the multi material.
  64912. * They need to be ordered according to the submeshes order in the associated mesh
  64913. */
  64914. subMaterials: Nullable<Material>[];
  64915. /**
  64916. * Function used to align with Node.getChildren()
  64917. * @returns the list of Materials used within the multi material
  64918. */
  64919. getChildren(): Nullable<Material>[];
  64920. /**
  64921. * Instantiates a new Multi Material
  64922. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64923. * separate meshes. This can be use to improve performances.
  64924. * @see http://doc.babylonjs.com/how_to/multi_materials
  64925. * @param name Define the name in the scene
  64926. * @param scene Define the scene the material belongs to
  64927. */
  64928. constructor(name: string, scene: Scene);
  64929. private _hookArray;
  64930. /**
  64931. * Get one of the submaterial by its index in the submaterials array
  64932. * @param index The index to look the sub material at
  64933. * @returns The Material if the index has been defined
  64934. */
  64935. getSubMaterial(index: number): Nullable<Material>;
  64936. /**
  64937. * Get the list of active textures for the whole sub materials list.
  64938. * @returns All the textures that will be used during the rendering
  64939. */
  64940. getActiveTextures(): BaseTexture[];
  64941. /**
  64942. * Gets the current class name of the material e.g. "MultiMaterial"
  64943. * Mainly use in serialization.
  64944. * @returns the class name
  64945. */
  64946. getClassName(): string;
  64947. /**
  64948. * Checks if the material is ready to render the requested sub mesh
  64949. * @param mesh Define the mesh the submesh belongs to
  64950. * @param subMesh Define the sub mesh to look readyness for
  64951. * @param useInstances Define whether or not the material is used with instances
  64952. * @returns true if ready, otherwise false
  64953. */
  64954. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  64955. /**
  64956. * Clones the current material and its related sub materials
  64957. * @param name Define the name of the newly cloned material
  64958. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  64959. * @returns the cloned material
  64960. */
  64961. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  64962. /**
  64963. * Serializes the materials into a JSON representation.
  64964. * @returns the JSON representation
  64965. */
  64966. serialize(): any;
  64967. /**
  64968. * Dispose the material and release its associated resources
  64969. * @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)
  64970. * @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)
  64971. * @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)
  64972. */
  64973. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  64974. /**
  64975. * Creates a MultiMaterial from parsed MultiMaterial data.
  64976. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  64977. * @param scene defines the hosting scene
  64978. * @returns a new MultiMaterial
  64979. */
  64980. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  64981. }
  64982. }
  64983. declare module BABYLON {
  64984. /**
  64985. * Class used to represent data loading progression
  64986. */
  64987. export class SceneLoaderFlags {
  64988. private static _ForceFullSceneLoadingForIncremental;
  64989. private static _ShowLoadingScreen;
  64990. private static _CleanBoneMatrixWeights;
  64991. private static _loggingLevel;
  64992. /**
  64993. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  64994. */
  64995. static ForceFullSceneLoadingForIncremental: boolean;
  64996. /**
  64997. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  64998. */
  64999. static ShowLoadingScreen: boolean;
  65000. /**
  65001. * Defines the current logging level (while loading the scene)
  65002. * @ignorenaming
  65003. */
  65004. static loggingLevel: number;
  65005. /**
  65006. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  65007. */
  65008. static CleanBoneMatrixWeights: boolean;
  65009. }
  65010. }
  65011. declare module BABYLON {
  65012. /**
  65013. * 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.
  65014. * @see https://doc.babylonjs.com/how_to/transformnode
  65015. */
  65016. export class TransformNode extends Node {
  65017. /**
  65018. * Object will not rotate to face the camera
  65019. */
  65020. static BILLBOARDMODE_NONE: number;
  65021. /**
  65022. * Object will rotate to face the camera but only on the x axis
  65023. */
  65024. static BILLBOARDMODE_X: number;
  65025. /**
  65026. * Object will rotate to face the camera but only on the y axis
  65027. */
  65028. static BILLBOARDMODE_Y: number;
  65029. /**
  65030. * Object will rotate to face the camera but only on the z axis
  65031. */
  65032. static BILLBOARDMODE_Z: number;
  65033. /**
  65034. * Object will rotate to face the camera
  65035. */
  65036. static BILLBOARDMODE_ALL: number;
  65037. private _forward;
  65038. private _forwardInverted;
  65039. private _up;
  65040. private _right;
  65041. private _rightInverted;
  65042. private _position;
  65043. private _rotation;
  65044. private _rotationQuaternion;
  65045. protected _scaling: Vector3;
  65046. protected _isDirty: boolean;
  65047. private _transformToBoneReferal;
  65048. /**
  65049. * Set the billboard mode. Default is 0.
  65050. *
  65051. * | Value | Type | Description |
  65052. * | --- | --- | --- |
  65053. * | 0 | BILLBOARDMODE_NONE | |
  65054. * | 1 | BILLBOARDMODE_X | |
  65055. * | 2 | BILLBOARDMODE_Y | |
  65056. * | 4 | BILLBOARDMODE_Z | |
  65057. * | 7 | BILLBOARDMODE_ALL | |
  65058. *
  65059. */
  65060. billboardMode: number;
  65061. /**
  65062. * 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
  65063. */
  65064. scalingDeterminant: number;
  65065. /**
  65066. * Sets the distance of the object to max, often used by skybox
  65067. */
  65068. infiniteDistance: boolean;
  65069. /**
  65070. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  65071. * By default the system will update normals to compensate
  65072. */
  65073. ignoreNonUniformScaling: boolean;
  65074. /** @hidden */
  65075. _poseMatrix: Matrix;
  65076. /** @hidden */
  65077. _localMatrix: Matrix;
  65078. private _absolutePosition;
  65079. private _pivotMatrix;
  65080. private _pivotMatrixInverse;
  65081. protected _postMultiplyPivotMatrix: boolean;
  65082. private _tempMatrix;
  65083. protected _isWorldMatrixFrozen: boolean;
  65084. /** @hidden */
  65085. _indexInSceneTransformNodesArray: number;
  65086. /**
  65087. * An event triggered after the world matrix is updated
  65088. */
  65089. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  65090. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  65091. /**
  65092. * Gets a string identifying the name of the class
  65093. * @returns "TransformNode" string
  65094. */
  65095. getClassName(): string;
  65096. /**
  65097. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  65098. */
  65099. position: Vector3;
  65100. /**
  65101. * 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)).
  65102. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  65103. */
  65104. rotation: Vector3;
  65105. /**
  65106. * 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)).
  65107. */
  65108. scaling: Vector3;
  65109. /**
  65110. * 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).
  65111. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  65112. */
  65113. rotationQuaternion: Nullable<Quaternion>;
  65114. /**
  65115. * The forward direction of that transform in world space.
  65116. */
  65117. readonly forward: Vector3;
  65118. /**
  65119. * The up direction of that transform in world space.
  65120. */
  65121. readonly up: Vector3;
  65122. /**
  65123. * The right direction of that transform in world space.
  65124. */
  65125. readonly right: Vector3;
  65126. /**
  65127. * Copies the parameter passed Matrix into the mesh Pose matrix.
  65128. * @param matrix the matrix to copy the pose from
  65129. * @returns this TransformNode.
  65130. */
  65131. updatePoseMatrix(matrix: Matrix): TransformNode;
  65132. /**
  65133. * Returns the mesh Pose matrix.
  65134. * @returns the pose matrix
  65135. */
  65136. getPoseMatrix(): Matrix;
  65137. /** @hidden */
  65138. _isSynchronized(): boolean;
  65139. /** @hidden */
  65140. _initCache(): void;
  65141. /**
  65142. * Flag the transform node as dirty (Forcing it to update everything)
  65143. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  65144. * @returns this transform node
  65145. */
  65146. markAsDirty(property: string): TransformNode;
  65147. /**
  65148. * Returns the current mesh absolute position.
  65149. * Returns a Vector3.
  65150. */
  65151. readonly absolutePosition: Vector3;
  65152. /**
  65153. * Sets a new matrix to apply before all other transformation
  65154. * @param matrix defines the transform matrix
  65155. * @returns the current TransformNode
  65156. */
  65157. setPreTransformMatrix(matrix: Matrix): TransformNode;
  65158. /**
  65159. * Sets a new pivot matrix to the current node
  65160. * @param matrix defines the new pivot matrix to use
  65161. * @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
  65162. * @returns the current TransformNode
  65163. */
  65164. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  65165. /**
  65166. * Returns the mesh pivot matrix.
  65167. * Default : Identity.
  65168. * @returns the matrix
  65169. */
  65170. getPivotMatrix(): Matrix;
  65171. /**
  65172. * Prevents the World matrix to be computed any longer.
  65173. * @returns the TransformNode.
  65174. */
  65175. freezeWorldMatrix(): TransformNode;
  65176. /**
  65177. * Allows back the World matrix computation.
  65178. * @returns the TransformNode.
  65179. */
  65180. unfreezeWorldMatrix(): this;
  65181. /**
  65182. * True if the World matrix has been frozen.
  65183. */
  65184. readonly isWorldMatrixFrozen: boolean;
  65185. /**
  65186. * Retuns the mesh absolute position in the World.
  65187. * @returns a Vector3.
  65188. */
  65189. getAbsolutePosition(): Vector3;
  65190. /**
  65191. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  65192. * @param absolutePosition the absolute position to set
  65193. * @returns the TransformNode.
  65194. */
  65195. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  65196. /**
  65197. * Sets the mesh position in its local space.
  65198. * @param vector3 the position to set in localspace
  65199. * @returns the TransformNode.
  65200. */
  65201. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  65202. /**
  65203. * Returns the mesh position in the local space from the current World matrix values.
  65204. * @returns a new Vector3.
  65205. */
  65206. getPositionExpressedInLocalSpace(): Vector3;
  65207. /**
  65208. * Translates the mesh along the passed Vector3 in its local space.
  65209. * @param vector3 the distance to translate in localspace
  65210. * @returns the TransformNode.
  65211. */
  65212. locallyTranslate(vector3: Vector3): TransformNode;
  65213. private static _lookAtVectorCache;
  65214. /**
  65215. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  65216. * @param targetPoint the position (must be in same space as current mesh) to look at
  65217. * @param yawCor optional yaw (y-axis) correction in radians
  65218. * @param pitchCor optional pitch (x-axis) correction in radians
  65219. * @param rollCor optional roll (z-axis) correction in radians
  65220. * @param space the choosen space of the target
  65221. * @returns the TransformNode.
  65222. */
  65223. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  65224. /**
  65225. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65226. * This Vector3 is expressed in the World space.
  65227. * @param localAxis axis to rotate
  65228. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65229. */
  65230. getDirection(localAxis: Vector3): Vector3;
  65231. /**
  65232. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  65233. * localAxis is expressed in the mesh local space.
  65234. * result is computed in the Wordl space from the mesh World matrix.
  65235. * @param localAxis axis to rotate
  65236. * @param result the resulting transformnode
  65237. * @returns this TransformNode.
  65238. */
  65239. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  65240. /**
  65241. * Sets this transform node rotation to the given local axis.
  65242. * @param localAxis the axis in local space
  65243. * @param yawCor optional yaw (y-axis) correction in radians
  65244. * @param pitchCor optional pitch (x-axis) correction in radians
  65245. * @param rollCor optional roll (z-axis) correction in radians
  65246. * @returns this TransformNode
  65247. */
  65248. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  65249. /**
  65250. * Sets a new pivot point to the current node
  65251. * @param point defines the new pivot point to use
  65252. * @param space defines if the point is in world or local space (local by default)
  65253. * @returns the current TransformNode
  65254. */
  65255. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  65256. /**
  65257. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  65258. * @returns the pivot point
  65259. */
  65260. getPivotPoint(): Vector3;
  65261. /**
  65262. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  65263. * @param result the vector3 to store the result
  65264. * @returns this TransformNode.
  65265. */
  65266. getPivotPointToRef(result: Vector3): TransformNode;
  65267. /**
  65268. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  65269. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  65270. */
  65271. getAbsolutePivotPoint(): Vector3;
  65272. /**
  65273. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  65274. * @param result vector3 to store the result
  65275. * @returns this TransformNode.
  65276. */
  65277. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  65278. /**
  65279. * Defines the passed node as the parent of the current node.
  65280. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  65281. * @param node the node ot set as the parent
  65282. * @returns this TransformNode.
  65283. */
  65284. setParent(node: Nullable<Node>): TransformNode;
  65285. private _nonUniformScaling;
  65286. /**
  65287. * True if the scaling property of this object is non uniform eg. (1,2,1)
  65288. */
  65289. readonly nonUniformScaling: boolean;
  65290. /** @hidden */
  65291. _updateNonUniformScalingState(value: boolean): boolean;
  65292. /**
  65293. * Attach the current TransformNode to another TransformNode associated with a bone
  65294. * @param bone Bone affecting the TransformNode
  65295. * @param affectedTransformNode TransformNode associated with the bone
  65296. * @returns this object
  65297. */
  65298. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  65299. /**
  65300. * Detach the transform node if its associated with a bone
  65301. * @returns this object
  65302. */
  65303. detachFromBone(): TransformNode;
  65304. private static _rotationAxisCache;
  65305. /**
  65306. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  65307. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65308. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65309. * The passed axis is also normalized.
  65310. * @param axis the axis to rotate around
  65311. * @param amount the amount to rotate in radians
  65312. * @param space Space to rotate in (Default: local)
  65313. * @returns the TransformNode.
  65314. */
  65315. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  65316. /**
  65317. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  65318. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65319. * The passed axis is also normalized. .
  65320. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  65321. * @param point the point to rotate around
  65322. * @param axis the axis to rotate around
  65323. * @param amount the amount to rotate in radians
  65324. * @returns the TransformNode
  65325. */
  65326. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  65327. /**
  65328. * Translates the mesh along the axis vector for the passed distance in the given space.
  65329. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65330. * @param axis the axis to translate in
  65331. * @param distance the distance to translate
  65332. * @param space Space to rotate in (Default: local)
  65333. * @returns the TransformNode.
  65334. */
  65335. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  65336. /**
  65337. * Adds a rotation step to the mesh current rotation.
  65338. * x, y, z are Euler angles expressed in radians.
  65339. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  65340. * This means this rotation is made in the mesh local space only.
  65341. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  65342. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  65343. * ```javascript
  65344. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  65345. * ```
  65346. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  65347. * 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.
  65348. * @param x Rotation to add
  65349. * @param y Rotation to add
  65350. * @param z Rotation to add
  65351. * @returns the TransformNode.
  65352. */
  65353. addRotation(x: number, y: number, z: number): TransformNode;
  65354. /**
  65355. * Computes the world matrix of the node
  65356. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  65357. * @returns the world matrix
  65358. */
  65359. computeWorldMatrix(force?: boolean): Matrix;
  65360. protected _afterComputeWorldMatrix(): void;
  65361. /**
  65362. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  65363. * @param func callback function to add
  65364. *
  65365. * @returns the TransformNode.
  65366. */
  65367. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65368. /**
  65369. * Removes a registered callback function.
  65370. * @param func callback function to remove
  65371. * @returns the TransformNode.
  65372. */
  65373. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65374. /**
  65375. * Gets the position of the current mesh in camera space
  65376. * @param camera defines the camera to use
  65377. * @returns a position
  65378. */
  65379. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  65380. /**
  65381. * Returns the distance from the mesh to the active camera
  65382. * @param camera defines the camera to use
  65383. * @returns the distance
  65384. */
  65385. getDistanceToCamera(camera?: Nullable<Camera>): number;
  65386. /**
  65387. * Clone the current transform node
  65388. * @param name Name of the new clone
  65389. * @param newParent New parent for the clone
  65390. * @param doNotCloneChildren Do not clone children hierarchy
  65391. * @returns the new transform node
  65392. */
  65393. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  65394. /**
  65395. * Serializes the objects information.
  65396. * @param currentSerializationObject defines the object to serialize in
  65397. * @returns the serialized object
  65398. */
  65399. serialize(currentSerializationObject?: any): any;
  65400. /**
  65401. * Returns a new TransformNode object parsed from the source provided.
  65402. * @param parsedTransformNode is the source.
  65403. * @param scene the scne the object belongs to
  65404. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  65405. * @returns a new TransformNode object parsed from the source provided.
  65406. */
  65407. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  65408. /**
  65409. * Get all child-transformNodes of this node
  65410. * @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
  65411. * @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
  65412. * @returns an array of TransformNode
  65413. */
  65414. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  65415. /**
  65416. * Releases resources associated with this transform node.
  65417. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  65418. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  65419. */
  65420. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  65421. }
  65422. }
  65423. declare module BABYLON {
  65424. /**
  65425. * Class used to override all child animations of a given target
  65426. */
  65427. export class AnimationPropertiesOverride {
  65428. /**
  65429. * Gets or sets a value indicating if animation blending must be used
  65430. */
  65431. enableBlending: boolean;
  65432. /**
  65433. * Gets or sets the blending speed to use when enableBlending is true
  65434. */
  65435. blendingSpeed: number;
  65436. /**
  65437. * Gets or sets the default loop mode to use
  65438. */
  65439. loopMode: number;
  65440. }
  65441. }
  65442. declare module BABYLON {
  65443. /**
  65444. * Class used to store bone information
  65445. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  65446. */
  65447. export class Bone extends Node {
  65448. /**
  65449. * defines the bone name
  65450. */
  65451. name: string;
  65452. private static _tmpVecs;
  65453. private static _tmpQuat;
  65454. private static _tmpMats;
  65455. /**
  65456. * Gets the list of child bones
  65457. */
  65458. children: Bone[];
  65459. /** Gets the animations associated with this bone */
  65460. animations: Animation[];
  65461. /**
  65462. * Gets or sets bone length
  65463. */
  65464. length: number;
  65465. /**
  65466. * @hidden Internal only
  65467. * Set this value to map this bone to a different index in the transform matrices
  65468. * Set this value to -1 to exclude the bone from the transform matrices
  65469. */
  65470. _index: Nullable<number>;
  65471. private _skeleton;
  65472. private _localMatrix;
  65473. private _restPose;
  65474. private _baseMatrix;
  65475. private _absoluteTransform;
  65476. private _invertedAbsoluteTransform;
  65477. private _parent;
  65478. private _scalingDeterminant;
  65479. private _worldTransform;
  65480. private _localScaling;
  65481. private _localRotation;
  65482. private _localPosition;
  65483. private _needToDecompose;
  65484. private _needToCompose;
  65485. /** @hidden */
  65486. _linkedTransformNode: Nullable<TransformNode>;
  65487. /** @hidden */
  65488. /** @hidden */
  65489. _matrix: Matrix;
  65490. /**
  65491. * Create a new bone
  65492. * @param name defines the bone name
  65493. * @param skeleton defines the parent skeleton
  65494. * @param parentBone defines the parent (can be null if the bone is the root)
  65495. * @param localMatrix defines the local matrix
  65496. * @param restPose defines the rest pose matrix
  65497. * @param baseMatrix defines the base matrix
  65498. * @param index defines index of the bone in the hiearchy
  65499. */
  65500. constructor(
  65501. /**
  65502. * defines the bone name
  65503. */
  65504. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  65505. /**
  65506. * Gets the current object class name.
  65507. * @return the class name
  65508. */
  65509. getClassName(): string;
  65510. /**
  65511. * Gets the parent skeleton
  65512. * @returns a skeleton
  65513. */
  65514. getSkeleton(): Skeleton;
  65515. /**
  65516. * Gets parent bone
  65517. * @returns a bone or null if the bone is the root of the bone hierarchy
  65518. */
  65519. getParent(): Nullable<Bone>;
  65520. /**
  65521. * Returns an array containing the root bones
  65522. * @returns an array containing the root bones
  65523. */
  65524. getChildren(): Array<Bone>;
  65525. /**
  65526. * Sets the parent bone
  65527. * @param parent defines the parent (can be null if the bone is the root)
  65528. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65529. */
  65530. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  65531. /**
  65532. * Gets the local matrix
  65533. * @returns a matrix
  65534. */
  65535. getLocalMatrix(): Matrix;
  65536. /**
  65537. * Gets the base matrix (initial matrix which remains unchanged)
  65538. * @returns a matrix
  65539. */
  65540. getBaseMatrix(): Matrix;
  65541. /**
  65542. * Gets the rest pose matrix
  65543. * @returns a matrix
  65544. */
  65545. getRestPose(): Matrix;
  65546. /**
  65547. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  65548. */
  65549. getWorldMatrix(): Matrix;
  65550. /**
  65551. * Sets the local matrix to rest pose matrix
  65552. */
  65553. returnToRest(): void;
  65554. /**
  65555. * Gets the inverse of the absolute transform matrix.
  65556. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  65557. * @returns a matrix
  65558. */
  65559. getInvertedAbsoluteTransform(): Matrix;
  65560. /**
  65561. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  65562. * @returns a matrix
  65563. */
  65564. getAbsoluteTransform(): Matrix;
  65565. /**
  65566. * Links with the given transform node.
  65567. * The local matrix of this bone is copied from the transform node every frame.
  65568. * @param transformNode defines the transform node to link to
  65569. */
  65570. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  65571. /** Gets or sets current position (in local space) */
  65572. position: Vector3;
  65573. /** Gets or sets current rotation (in local space) */
  65574. rotation: Vector3;
  65575. /** Gets or sets current rotation quaternion (in local space) */
  65576. rotationQuaternion: Quaternion;
  65577. /** Gets or sets current scaling (in local space) */
  65578. scaling: Vector3;
  65579. /**
  65580. * Gets the animation properties override
  65581. */
  65582. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  65583. private _decompose;
  65584. private _compose;
  65585. /**
  65586. * Update the base and local matrices
  65587. * @param matrix defines the new base or local matrix
  65588. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65589. * @param updateLocalMatrix defines if the local matrix should be updated
  65590. */
  65591. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  65592. /** @hidden */
  65593. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  65594. /**
  65595. * Flag the bone as dirty (Forcing it to update everything)
  65596. */
  65597. markAsDirty(): void;
  65598. private _markAsDirtyAndCompose;
  65599. private _markAsDirtyAndDecompose;
  65600. /**
  65601. * Translate the bone in local or world space
  65602. * @param vec The amount to translate the bone
  65603. * @param space The space that the translation is in
  65604. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65605. */
  65606. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65607. /**
  65608. * Set the postion of the bone in local or world space
  65609. * @param position The position to set the bone
  65610. * @param space The space that the position is in
  65611. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65612. */
  65613. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65614. /**
  65615. * Set the absolute position of the bone (world space)
  65616. * @param position The position to set the bone
  65617. * @param mesh The mesh that this bone is attached to
  65618. */
  65619. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  65620. /**
  65621. * Scale the bone on the x, y and z axes (in local space)
  65622. * @param x The amount to scale the bone on the x axis
  65623. * @param y The amount to scale the bone on the y axis
  65624. * @param z The amount to scale the bone on the z axis
  65625. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  65626. */
  65627. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  65628. /**
  65629. * Set the bone scaling in local space
  65630. * @param scale defines the scaling vector
  65631. */
  65632. setScale(scale: Vector3): void;
  65633. /**
  65634. * Gets the current scaling in local space
  65635. * @returns the current scaling vector
  65636. */
  65637. getScale(): Vector3;
  65638. /**
  65639. * Gets the current scaling in local space and stores it in a target vector
  65640. * @param result defines the target vector
  65641. */
  65642. getScaleToRef(result: Vector3): void;
  65643. /**
  65644. * Set the yaw, pitch, and roll of the bone in local or world space
  65645. * @param yaw The rotation of the bone on the y axis
  65646. * @param pitch The rotation of the bone on the x axis
  65647. * @param roll The rotation of the bone on the z axis
  65648. * @param space The space that the axes of rotation are in
  65649. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65650. */
  65651. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  65652. /**
  65653. * Add a rotation to the bone on an axis in local or world space
  65654. * @param axis The axis to rotate the bone on
  65655. * @param amount The amount to rotate the bone
  65656. * @param space The space that the axis is in
  65657. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65658. */
  65659. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  65660. /**
  65661. * Set the rotation of the bone to a particular axis angle in local or world space
  65662. * @param axis The axis to rotate the bone on
  65663. * @param angle The angle that the bone should be rotated to
  65664. * @param space The space that the axis is in
  65665. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65666. */
  65667. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  65668. /**
  65669. * Set the euler rotation of the bone in local of world space
  65670. * @param rotation The euler rotation that the bone should be set to
  65671. * @param space The space that the rotation is in
  65672. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65673. */
  65674. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65675. /**
  65676. * Set the quaternion rotation of the bone in local of world space
  65677. * @param quat The quaternion rotation that the bone should be set to
  65678. * @param space The space that the rotation is in
  65679. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65680. */
  65681. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  65682. /**
  65683. * Set the rotation matrix of the bone in local of world space
  65684. * @param rotMat The rotation matrix that the bone should be set to
  65685. * @param space The space that the rotation is in
  65686. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65687. */
  65688. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  65689. private _rotateWithMatrix;
  65690. private _getNegativeRotationToRef;
  65691. /**
  65692. * Get the position of the bone in local or world space
  65693. * @param space The space that the returned position is in
  65694. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65695. * @returns The position of the bone
  65696. */
  65697. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65698. /**
  65699. * Copy the position of the bone to a vector3 in local or world space
  65700. * @param space The space that the returned position is in
  65701. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65702. * @param result The vector3 to copy the position to
  65703. */
  65704. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  65705. /**
  65706. * Get the absolute position of the bone (world space)
  65707. * @param mesh The mesh that this bone is attached to
  65708. * @returns The absolute position of the bone
  65709. */
  65710. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  65711. /**
  65712. * Copy the absolute position of the bone (world space) to the result param
  65713. * @param mesh The mesh that this bone is attached to
  65714. * @param result The vector3 to copy the absolute position to
  65715. */
  65716. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  65717. /**
  65718. * Compute the absolute transforms of this bone and its children
  65719. */
  65720. computeAbsoluteTransforms(): void;
  65721. /**
  65722. * Get the world direction from an axis that is in the local space of the bone
  65723. * @param localAxis The local direction that is used to compute the world direction
  65724. * @param mesh The mesh that this bone is attached to
  65725. * @returns The world direction
  65726. */
  65727. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65728. /**
  65729. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  65730. * @param localAxis The local direction that is used to compute the world direction
  65731. * @param mesh The mesh that this bone is attached to
  65732. * @param result The vector3 that the world direction will be copied to
  65733. */
  65734. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65735. /**
  65736. * Get the euler rotation of the bone in local or world space
  65737. * @param space The space that the rotation should be in
  65738. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65739. * @returns The euler rotation
  65740. */
  65741. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65742. /**
  65743. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  65744. * @param space The space that the rotation should be in
  65745. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65746. * @param result The vector3 that the rotation should be copied to
  65747. */
  65748. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65749. /**
  65750. * Get the quaternion rotation of the bone in either local or world space
  65751. * @param space The space that the rotation should be in
  65752. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65753. * @returns The quaternion rotation
  65754. */
  65755. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  65756. /**
  65757. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  65758. * @param space The space that the rotation should be in
  65759. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65760. * @param result The quaternion that the rotation should be copied to
  65761. */
  65762. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  65763. /**
  65764. * Get the rotation matrix of the bone in local or world space
  65765. * @param space The space that the rotation should be in
  65766. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65767. * @returns The rotation matrix
  65768. */
  65769. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  65770. /**
  65771. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  65772. * @param space The space that the rotation should be in
  65773. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65774. * @param result The quaternion that the rotation should be copied to
  65775. */
  65776. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  65777. /**
  65778. * Get the world position of a point that is in the local space of the bone
  65779. * @param position The local position
  65780. * @param mesh The mesh that this bone is attached to
  65781. * @returns The world position
  65782. */
  65783. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65784. /**
  65785. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  65786. * @param position The local position
  65787. * @param mesh The mesh that this bone is attached to
  65788. * @param result The vector3 that the world position should be copied to
  65789. */
  65790. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65791. /**
  65792. * Get the local position of a point that is in world space
  65793. * @param position The world position
  65794. * @param mesh The mesh that this bone is attached to
  65795. * @returns The local position
  65796. */
  65797. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65798. /**
  65799. * Get the local position of a point that is in world space and copy it to the result param
  65800. * @param position The world position
  65801. * @param mesh The mesh that this bone is attached to
  65802. * @param result The vector3 that the local position should be copied to
  65803. */
  65804. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65805. }
  65806. }
  65807. declare module BABYLON {
  65808. /**
  65809. * Class for creating a cube texture
  65810. */
  65811. export class CubeTexture extends BaseTexture {
  65812. private _delayedOnLoad;
  65813. /**
  65814. * The url of the texture
  65815. */
  65816. url: string;
  65817. /**
  65818. * Gets or sets the center of the bounding box associated with the cube texture.
  65819. * It must define where the camera used to render the texture was set
  65820. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  65821. */
  65822. boundingBoxPosition: Vector3;
  65823. private _boundingBoxSize;
  65824. /**
  65825. * Gets or sets the size of the bounding box associated with the cube texture
  65826. * When defined, the cubemap will switch to local mode
  65827. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  65828. * @example https://www.babylonjs-playground.com/#RNASML
  65829. */
  65830. /**
  65831. * Returns the bounding box size
  65832. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  65833. */
  65834. boundingBoxSize: Vector3;
  65835. protected _rotationY: number;
  65836. /**
  65837. * Sets texture matrix rotation angle around Y axis in radians.
  65838. */
  65839. /**
  65840. * Gets texture matrix rotation angle around Y axis radians.
  65841. */
  65842. rotationY: number;
  65843. /**
  65844. * Are mip maps generated for this texture or not.
  65845. */
  65846. readonly noMipmap: boolean;
  65847. private _noMipmap;
  65848. private _files;
  65849. private _extensions;
  65850. private _textureMatrix;
  65851. private _format;
  65852. private _createPolynomials;
  65853. /** @hidden */
  65854. _prefiltered: boolean;
  65855. /**
  65856. * Creates a cube texture from an array of image urls
  65857. * @param files defines an array of image urls
  65858. * @param scene defines the hosting scene
  65859. * @param noMipmap specifies if mip maps are not used
  65860. * @returns a cube texture
  65861. */
  65862. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  65863. /**
  65864. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  65865. * @param url defines the url of the prefiltered texture
  65866. * @param scene defines the scene the texture is attached to
  65867. * @param forcedExtension defines the extension of the file if different from the url
  65868. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65869. * @return the prefiltered texture
  65870. */
  65871. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  65872. /**
  65873. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  65874. * as prefiltered data.
  65875. * @param rootUrl defines the url of the texture or the root name of the six images
  65876. * @param scene defines the scene the texture is attached to
  65877. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  65878. * @param noMipmap defines if mipmaps should be created or not
  65879. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  65880. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  65881. * @param onError defines a callback triggered in case of error during load
  65882. * @param format defines the internal format to use for the texture once loaded
  65883. * @param prefiltered defines whether or not the texture is created from prefiltered data
  65884. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  65885. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65886. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65887. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65888. * @return the cube texture
  65889. */
  65890. 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);
  65891. /**
  65892. * Get the current class name of the texture useful for serialization or dynamic coding.
  65893. * @returns "CubeTexture"
  65894. */
  65895. getClassName(): string;
  65896. /**
  65897. * Update the url (and optional buffer) of this texture if url was null during construction.
  65898. * @param url the url of the texture
  65899. * @param forcedExtension defines the extension to use
  65900. * @param onLoad callback called when the texture is loaded (defaults to null)
  65901. */
  65902. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  65903. /**
  65904. * Delays loading of the cube texture
  65905. * @param forcedExtension defines the extension to use
  65906. */
  65907. delayLoad(forcedExtension?: string): void;
  65908. /**
  65909. * Returns the reflection texture matrix
  65910. * @returns the reflection texture matrix
  65911. */
  65912. getReflectionTextureMatrix(): Matrix;
  65913. /**
  65914. * Sets the reflection texture matrix
  65915. * @param value Reflection texture matrix
  65916. */
  65917. setReflectionTextureMatrix(value: Matrix): void;
  65918. /**
  65919. * Parses text to create a cube texture
  65920. * @param parsedTexture define the serialized text to read from
  65921. * @param scene defines the hosting scene
  65922. * @param rootUrl defines the root url of the cube texture
  65923. * @returns a cube texture
  65924. */
  65925. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  65926. /**
  65927. * Makes a clone, or deep copy, of the cube texture
  65928. * @returns a new cube texture
  65929. */
  65930. clone(): CubeTexture;
  65931. }
  65932. }
  65933. declare module BABYLON {
  65934. /** @hidden */
  65935. export var postprocessVertexShader: {
  65936. name: string;
  65937. shader: string;
  65938. };
  65939. }
  65940. declare module BABYLON {
  65941. /**
  65942. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  65943. * This is the base of the follow, arc rotate cameras and Free camera
  65944. * @see http://doc.babylonjs.com/features/cameras
  65945. */
  65946. export class TargetCamera extends Camera {
  65947. private static _RigCamTransformMatrix;
  65948. private static _TargetTransformMatrix;
  65949. private static _TargetFocalPoint;
  65950. /**
  65951. * Define the current direction the camera is moving to
  65952. */
  65953. cameraDirection: Vector3;
  65954. /**
  65955. * Define the current rotation the camera is rotating to
  65956. */
  65957. cameraRotation: Vector2;
  65958. /**
  65959. * When set, the up vector of the camera will be updated by the rotation of the camera
  65960. */
  65961. updateUpVectorFromRotation: boolean;
  65962. private _tmpQuaternion;
  65963. /**
  65964. * Define the current rotation of the camera
  65965. */
  65966. rotation: Vector3;
  65967. /**
  65968. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  65969. */
  65970. rotationQuaternion: Quaternion;
  65971. /**
  65972. * Define the current speed of the camera
  65973. */
  65974. speed: number;
  65975. /**
  65976. * Add cconstraint to the camera to prevent it to move freely in all directions and
  65977. * around all axis.
  65978. */
  65979. noRotationConstraint: boolean;
  65980. /**
  65981. * Define the current target of the camera as an object or a position.
  65982. */
  65983. lockedTarget: any;
  65984. /** @hidden */
  65985. _currentTarget: Vector3;
  65986. /** @hidden */
  65987. _initialFocalDistance: number;
  65988. /** @hidden */
  65989. _viewMatrix: Matrix;
  65990. /** @hidden */
  65991. _camMatrix: Matrix;
  65992. /** @hidden */
  65993. _cameraTransformMatrix: Matrix;
  65994. /** @hidden */
  65995. _cameraRotationMatrix: Matrix;
  65996. /** @hidden */
  65997. _referencePoint: Vector3;
  65998. /** @hidden */
  65999. _transformedReferencePoint: Vector3;
  66000. protected _globalCurrentTarget: Vector3;
  66001. protected _globalCurrentUpVector: Vector3;
  66002. /** @hidden */
  66003. _reset: () => void;
  66004. private _defaultUp;
  66005. /**
  66006. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  66007. * This is the base of the follow, arc rotate cameras and Free camera
  66008. * @see http://doc.babylonjs.com/features/cameras
  66009. * @param name Defines the name of the camera in the scene
  66010. * @param position Defines the start position of the camera in the scene
  66011. * @param scene Defines the scene the camera belongs to
  66012. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  66013. */
  66014. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  66015. /**
  66016. * Gets the position in front of the camera at a given distance.
  66017. * @param distance The distance from the camera we want the position to be
  66018. * @returns the position
  66019. */
  66020. getFrontPosition(distance: number): Vector3;
  66021. /** @hidden */
  66022. _getLockedTargetPosition(): Nullable<Vector3>;
  66023. private _storedPosition;
  66024. private _storedRotation;
  66025. private _storedRotationQuaternion;
  66026. /**
  66027. * Store current camera state of the camera (fov, position, rotation, etc..)
  66028. * @returns the camera
  66029. */
  66030. storeState(): Camera;
  66031. /**
  66032. * Restored camera state. You must call storeState() first
  66033. * @returns whether it was successful or not
  66034. * @hidden
  66035. */
  66036. _restoreStateValues(): boolean;
  66037. /** @hidden */
  66038. _initCache(): void;
  66039. /** @hidden */
  66040. _updateCache(ignoreParentClass?: boolean): void;
  66041. /** @hidden */
  66042. _isSynchronizedViewMatrix(): boolean;
  66043. /** @hidden */
  66044. _computeLocalCameraSpeed(): number;
  66045. /**
  66046. * Defines the target the camera should look at.
  66047. * This will automatically adapt alpha beta and radius to fit within the new target.
  66048. * @param target Defines the new target as a Vector or a mesh
  66049. */
  66050. setTarget(target: Vector3): void;
  66051. /**
  66052. * Return the current target position of the camera. This value is expressed in local space.
  66053. * @returns the target position
  66054. */
  66055. getTarget(): Vector3;
  66056. /** @hidden */
  66057. _decideIfNeedsToMove(): boolean;
  66058. /** @hidden */
  66059. _updatePosition(): void;
  66060. /** @hidden */
  66061. _checkInputs(): void;
  66062. protected _updateCameraRotationMatrix(): void;
  66063. /**
  66064. * 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)
  66065. * @returns the current camera
  66066. */
  66067. private _rotateUpVectorWithCameraRotationMatrix;
  66068. private _cachedRotationZ;
  66069. private _cachedQuaternionRotationZ;
  66070. /** @hidden */
  66071. _getViewMatrix(): Matrix;
  66072. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  66073. /**
  66074. * @hidden
  66075. */
  66076. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  66077. /**
  66078. * @hidden
  66079. */
  66080. _updateRigCameras(): void;
  66081. private _getRigCamPositionAndTarget;
  66082. /**
  66083. * Gets the current object class name.
  66084. * @return the class name
  66085. */
  66086. getClassName(): string;
  66087. }
  66088. }
  66089. declare module BABYLON {
  66090. /**
  66091. * @ignore
  66092. * This is a list of all the different input types that are available in the application.
  66093. * Fo instance: ArcRotateCameraGamepadInput...
  66094. */
  66095. export var CameraInputTypes: {};
  66096. /**
  66097. * This is the contract to implement in order to create a new input class.
  66098. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  66099. */
  66100. export interface ICameraInput<TCamera extends Camera> {
  66101. /**
  66102. * Defines the camera the input is attached to.
  66103. */
  66104. camera: Nullable<TCamera>;
  66105. /**
  66106. * Gets the class name of the current intput.
  66107. * @returns the class name
  66108. */
  66109. getClassName(): string;
  66110. /**
  66111. * Get the friendly name associated with the input class.
  66112. * @returns the input friendly name
  66113. */
  66114. getSimpleName(): string;
  66115. /**
  66116. * Attach the input controls to a specific dom element to get the input from.
  66117. * @param element Defines the element the controls should be listened from
  66118. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66119. */
  66120. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66121. /**
  66122. * Detach the current controls from the specified dom element.
  66123. * @param element Defines the element to stop listening the inputs from
  66124. */
  66125. detachControl(element: Nullable<HTMLElement>): void;
  66126. /**
  66127. * Update the current camera state depending on the inputs that have been used this frame.
  66128. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66129. */
  66130. checkInputs?: () => void;
  66131. }
  66132. /**
  66133. * Represents a map of input types to input instance or input index to input instance.
  66134. */
  66135. export interface CameraInputsMap<TCamera extends Camera> {
  66136. /**
  66137. * Accessor to the input by input type.
  66138. */
  66139. [name: string]: ICameraInput<TCamera>;
  66140. /**
  66141. * Accessor to the input by input index.
  66142. */
  66143. [idx: number]: ICameraInput<TCamera>;
  66144. }
  66145. /**
  66146. * This represents the input manager used within a camera.
  66147. * It helps dealing with all the different kind of input attached to a camera.
  66148. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66149. */
  66150. export class CameraInputsManager<TCamera extends Camera> {
  66151. /**
  66152. * Defines the list of inputs attahed to the camera.
  66153. */
  66154. attached: CameraInputsMap<TCamera>;
  66155. /**
  66156. * Defines the dom element the camera is collecting inputs from.
  66157. * This is null if the controls have not been attached.
  66158. */
  66159. attachedElement: Nullable<HTMLElement>;
  66160. /**
  66161. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66162. */
  66163. noPreventDefault: boolean;
  66164. /**
  66165. * Defined the camera the input manager belongs to.
  66166. */
  66167. camera: TCamera;
  66168. /**
  66169. * Update the current camera state depending on the inputs that have been used this frame.
  66170. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66171. */
  66172. checkInputs: () => void;
  66173. /**
  66174. * Instantiate a new Camera Input Manager.
  66175. * @param camera Defines the camera the input manager blongs to
  66176. */
  66177. constructor(camera: TCamera);
  66178. /**
  66179. * Add an input method to a camera
  66180. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66181. * @param input camera input method
  66182. */
  66183. add(input: ICameraInput<TCamera>): void;
  66184. /**
  66185. * Remove a specific input method from a camera
  66186. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  66187. * @param inputToRemove camera input method
  66188. */
  66189. remove(inputToRemove: ICameraInput<TCamera>): void;
  66190. /**
  66191. * Remove a specific input type from a camera
  66192. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  66193. * @param inputType the type of the input to remove
  66194. */
  66195. removeByType(inputType: string): void;
  66196. private _addCheckInputs;
  66197. /**
  66198. * Attach the input controls to the currently attached dom element to listen the events from.
  66199. * @param input Defines the input to attach
  66200. */
  66201. attachInput(input: ICameraInput<TCamera>): void;
  66202. /**
  66203. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  66204. * @param element Defines the dom element to collect the events from
  66205. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66206. */
  66207. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  66208. /**
  66209. * Detach the current manager inputs controls from a specific dom element.
  66210. * @param element Defines the dom element to collect the events from
  66211. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  66212. */
  66213. detachElement(element: HTMLElement, disconnect?: boolean): void;
  66214. /**
  66215. * Rebuild the dynamic inputCheck function from the current list of
  66216. * defined inputs in the manager.
  66217. */
  66218. rebuildInputCheck(): void;
  66219. /**
  66220. * Remove all attached input methods from a camera
  66221. */
  66222. clear(): void;
  66223. /**
  66224. * Serialize the current input manager attached to a camera.
  66225. * This ensures than once parsed,
  66226. * the input associated to the camera will be identical to the current ones
  66227. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  66228. */
  66229. serialize(serializedCamera: any): void;
  66230. /**
  66231. * Parses an input manager serialized JSON to restore the previous list of inputs
  66232. * and states associated to a camera.
  66233. * @param parsedCamera Defines the JSON to parse
  66234. */
  66235. parse(parsedCamera: any): void;
  66236. }
  66237. }
  66238. declare module BABYLON {
  66239. /**
  66240. * Gather the list of keyboard event types as constants.
  66241. */
  66242. export class KeyboardEventTypes {
  66243. /**
  66244. * The keydown event is fired when a key becomes active (pressed).
  66245. */
  66246. static readonly KEYDOWN: number;
  66247. /**
  66248. * The keyup event is fired when a key has been released.
  66249. */
  66250. static readonly KEYUP: number;
  66251. }
  66252. /**
  66253. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66254. */
  66255. export class KeyboardInfo {
  66256. /**
  66257. * Defines the type of event (KeyboardEventTypes)
  66258. */
  66259. type: number;
  66260. /**
  66261. * Defines the related dom event
  66262. */
  66263. event: KeyboardEvent;
  66264. /**
  66265. * Instantiates a new keyboard info.
  66266. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66267. * @param type Defines the type of event (KeyboardEventTypes)
  66268. * @param event Defines the related dom event
  66269. */
  66270. constructor(
  66271. /**
  66272. * Defines the type of event (KeyboardEventTypes)
  66273. */
  66274. type: number,
  66275. /**
  66276. * Defines the related dom event
  66277. */
  66278. event: KeyboardEvent);
  66279. }
  66280. /**
  66281. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66282. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  66283. */
  66284. export class KeyboardInfoPre extends KeyboardInfo {
  66285. /**
  66286. * Defines the type of event (KeyboardEventTypes)
  66287. */
  66288. type: number;
  66289. /**
  66290. * Defines the related dom event
  66291. */
  66292. event: KeyboardEvent;
  66293. /**
  66294. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  66295. */
  66296. skipOnPointerObservable: boolean;
  66297. /**
  66298. * Instantiates a new keyboard pre info.
  66299. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66300. * @param type Defines the type of event (KeyboardEventTypes)
  66301. * @param event Defines the related dom event
  66302. */
  66303. constructor(
  66304. /**
  66305. * Defines the type of event (KeyboardEventTypes)
  66306. */
  66307. type: number,
  66308. /**
  66309. * Defines the related dom event
  66310. */
  66311. event: KeyboardEvent);
  66312. }
  66313. }
  66314. declare module BABYLON {
  66315. /**
  66316. * Manage the keyboard inputs to control the movement of a free camera.
  66317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66318. */
  66319. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  66320. /**
  66321. * Defines the camera the input is attached to.
  66322. */
  66323. camera: FreeCamera;
  66324. /**
  66325. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  66326. */
  66327. keysUp: number[];
  66328. /**
  66329. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  66330. */
  66331. keysDown: number[];
  66332. /**
  66333. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  66334. */
  66335. keysLeft: number[];
  66336. /**
  66337. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  66338. */
  66339. keysRight: number[];
  66340. private _keys;
  66341. private _onCanvasBlurObserver;
  66342. private _onKeyboardObserver;
  66343. private _engine;
  66344. private _scene;
  66345. /**
  66346. * Attach the input controls to a specific dom element to get the input from.
  66347. * @param element Defines the element the controls should be listened from
  66348. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66349. */
  66350. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66351. /**
  66352. * Detach the current controls from the specified dom element.
  66353. * @param element Defines the element to stop listening the inputs from
  66354. */
  66355. detachControl(element: Nullable<HTMLElement>): void;
  66356. /**
  66357. * Update the current camera state depending on the inputs that have been used this frame.
  66358. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66359. */
  66360. checkInputs(): void;
  66361. /**
  66362. * Gets the class name of the current intput.
  66363. * @returns the class name
  66364. */
  66365. getClassName(): string;
  66366. /** @hidden */
  66367. _onLostFocus(): void;
  66368. /**
  66369. * Get the friendly name associated with the input class.
  66370. * @returns the input friendly name
  66371. */
  66372. getSimpleName(): string;
  66373. }
  66374. }
  66375. declare module BABYLON {
  66376. /**
  66377. * Interface describing all the common properties and methods a shadow light needs to implement.
  66378. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  66379. * as well as binding the different shadow properties to the effects.
  66380. */
  66381. export interface IShadowLight extends Light {
  66382. /**
  66383. * The light id in the scene (used in scene.findLighById for instance)
  66384. */
  66385. id: string;
  66386. /**
  66387. * The position the shdow will be casted from.
  66388. */
  66389. position: Vector3;
  66390. /**
  66391. * In 2d mode (needCube being false), the direction used to cast the shadow.
  66392. */
  66393. direction: Vector3;
  66394. /**
  66395. * The transformed position. Position of the light in world space taking parenting in account.
  66396. */
  66397. transformedPosition: Vector3;
  66398. /**
  66399. * The transformed direction. Direction of the light in world space taking parenting in account.
  66400. */
  66401. transformedDirection: Vector3;
  66402. /**
  66403. * The friendly name of the light in the scene.
  66404. */
  66405. name: string;
  66406. /**
  66407. * Defines the shadow projection clipping minimum z value.
  66408. */
  66409. shadowMinZ: number;
  66410. /**
  66411. * Defines the shadow projection clipping maximum z value.
  66412. */
  66413. shadowMaxZ: number;
  66414. /**
  66415. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66416. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66417. */
  66418. computeTransformedInformation(): boolean;
  66419. /**
  66420. * Gets the scene the light belongs to.
  66421. * @returns The scene
  66422. */
  66423. getScene(): Scene;
  66424. /**
  66425. * Callback defining a custom Projection Matrix Builder.
  66426. * This can be used to override the default projection matrix computation.
  66427. */
  66428. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66429. /**
  66430. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66431. * @param matrix The materix to updated with the projection information
  66432. * @param viewMatrix The transform matrix of the light
  66433. * @param renderList The list of mesh to render in the map
  66434. * @returns The current light
  66435. */
  66436. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66437. /**
  66438. * Gets the current depth scale used in ESM.
  66439. * @returns The scale
  66440. */
  66441. getDepthScale(): number;
  66442. /**
  66443. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66444. * @returns true if a cube texture needs to be use
  66445. */
  66446. needCube(): boolean;
  66447. /**
  66448. * Detects if the projection matrix requires to be recomputed this frame.
  66449. * @returns true if it requires to be recomputed otherwise, false.
  66450. */
  66451. needProjectionMatrixCompute(): boolean;
  66452. /**
  66453. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66454. */
  66455. forceProjectionMatrixCompute(): void;
  66456. /**
  66457. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66458. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66459. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66460. */
  66461. getShadowDirection(faceIndex?: number): Vector3;
  66462. /**
  66463. * Gets the minZ used for shadow according to both the scene and the light.
  66464. * @param activeCamera The camera we are returning the min for
  66465. * @returns the depth min z
  66466. */
  66467. getDepthMinZ(activeCamera: Camera): number;
  66468. /**
  66469. * Gets the maxZ used for shadow according to both the scene and the light.
  66470. * @param activeCamera The camera we are returning the max for
  66471. * @returns the depth max z
  66472. */
  66473. getDepthMaxZ(activeCamera: Camera): number;
  66474. }
  66475. /**
  66476. * Base implementation IShadowLight
  66477. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  66478. */
  66479. export abstract class ShadowLight extends Light implements IShadowLight {
  66480. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  66481. protected _position: Vector3;
  66482. protected _setPosition(value: Vector3): void;
  66483. /**
  66484. * Sets the position the shadow will be casted from. Also use as the light position for both
  66485. * point and spot lights.
  66486. */
  66487. /**
  66488. * Sets the position the shadow will be casted from. Also use as the light position for both
  66489. * point and spot lights.
  66490. */
  66491. position: Vector3;
  66492. protected _direction: Vector3;
  66493. protected _setDirection(value: Vector3): void;
  66494. /**
  66495. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  66496. * Also use as the light direction on spot and directional lights.
  66497. */
  66498. /**
  66499. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  66500. * Also use as the light direction on spot and directional lights.
  66501. */
  66502. direction: Vector3;
  66503. private _shadowMinZ;
  66504. /**
  66505. * Gets the shadow projection clipping minimum z value.
  66506. */
  66507. /**
  66508. * Sets the shadow projection clipping minimum z value.
  66509. */
  66510. shadowMinZ: number;
  66511. private _shadowMaxZ;
  66512. /**
  66513. * Sets the shadow projection clipping maximum z value.
  66514. */
  66515. /**
  66516. * Gets the shadow projection clipping maximum z value.
  66517. */
  66518. shadowMaxZ: number;
  66519. /**
  66520. * Callback defining a custom Projection Matrix Builder.
  66521. * This can be used to override the default projection matrix computation.
  66522. */
  66523. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66524. /**
  66525. * The transformed position. Position of the light in world space taking parenting in account.
  66526. */
  66527. transformedPosition: Vector3;
  66528. /**
  66529. * The transformed direction. Direction of the light in world space taking parenting in account.
  66530. */
  66531. transformedDirection: Vector3;
  66532. private _needProjectionMatrixCompute;
  66533. /**
  66534. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66535. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66536. */
  66537. computeTransformedInformation(): boolean;
  66538. /**
  66539. * Return the depth scale used for the shadow map.
  66540. * @returns the depth scale.
  66541. */
  66542. getDepthScale(): number;
  66543. /**
  66544. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66545. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66546. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66547. */
  66548. getShadowDirection(faceIndex?: number): Vector3;
  66549. /**
  66550. * Returns the ShadowLight absolute position in the World.
  66551. * @returns the position vector in world space
  66552. */
  66553. getAbsolutePosition(): Vector3;
  66554. /**
  66555. * Sets the ShadowLight direction toward the passed target.
  66556. * @param target The point to target in local space
  66557. * @returns the updated ShadowLight direction
  66558. */
  66559. setDirectionToTarget(target: Vector3): Vector3;
  66560. /**
  66561. * Returns the light rotation in euler definition.
  66562. * @returns the x y z rotation in local space.
  66563. */
  66564. getRotation(): Vector3;
  66565. /**
  66566. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66567. * @returns true if a cube texture needs to be use
  66568. */
  66569. needCube(): boolean;
  66570. /**
  66571. * Detects if the projection matrix requires to be recomputed this frame.
  66572. * @returns true if it requires to be recomputed otherwise, false.
  66573. */
  66574. needProjectionMatrixCompute(): boolean;
  66575. /**
  66576. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66577. */
  66578. forceProjectionMatrixCompute(): void;
  66579. /** @hidden */
  66580. _initCache(): void;
  66581. /** @hidden */
  66582. _isSynchronized(): boolean;
  66583. /**
  66584. * Computes the world matrix of the node
  66585. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66586. * @returns the world matrix
  66587. */
  66588. computeWorldMatrix(force?: boolean): Matrix;
  66589. /**
  66590. * Gets the minZ used for shadow according to both the scene and the light.
  66591. * @param activeCamera The camera we are returning the min for
  66592. * @returns the depth min z
  66593. */
  66594. getDepthMinZ(activeCamera: Camera): number;
  66595. /**
  66596. * Gets the maxZ used for shadow according to both the scene and the light.
  66597. * @param activeCamera The camera we are returning the max for
  66598. * @returns the depth max z
  66599. */
  66600. getDepthMaxZ(activeCamera: Camera): number;
  66601. /**
  66602. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66603. * @param matrix The materix to updated with the projection information
  66604. * @param viewMatrix The transform matrix of the light
  66605. * @param renderList The list of mesh to render in the map
  66606. * @returns The current light
  66607. */
  66608. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66609. }
  66610. }
  66611. declare module BABYLON {
  66612. /**
  66613. * "Static Class" containing the most commonly used helper while dealing with material for
  66614. * rendering purpose.
  66615. *
  66616. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  66617. *
  66618. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  66619. */
  66620. export class MaterialHelper {
  66621. /**
  66622. * Bind the current view position to an effect.
  66623. * @param effect The effect to be bound
  66624. * @param scene The scene the eyes position is used from
  66625. */
  66626. static BindEyePosition(effect: Effect, scene: Scene): void;
  66627. /**
  66628. * Helps preparing the defines values about the UVs in used in the effect.
  66629. * UVs are shared as much as we can accross channels in the shaders.
  66630. * @param texture The texture we are preparing the UVs for
  66631. * @param defines The defines to update
  66632. * @param key The channel key "diffuse", "specular"... used in the shader
  66633. */
  66634. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  66635. /**
  66636. * Binds a texture matrix value to its corrsponding uniform
  66637. * @param texture The texture to bind the matrix for
  66638. * @param uniformBuffer The uniform buffer receivin the data
  66639. * @param key The channel key "diffuse", "specular"... used in the shader
  66640. */
  66641. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  66642. /**
  66643. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  66644. * @param mesh defines the current mesh
  66645. * @param scene defines the current scene
  66646. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  66647. * @param pointsCloud defines if point cloud rendering has to be turned on
  66648. * @param fogEnabled defines if fog has to be turned on
  66649. * @param alphaTest defines if alpha testing has to be turned on
  66650. * @param defines defines the current list of defines
  66651. */
  66652. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  66653. /**
  66654. * Helper used to prepare the list of defines associated with frame values for shader compilation
  66655. * @param scene defines the current scene
  66656. * @param engine defines the current engine
  66657. * @param defines specifies the list of active defines
  66658. * @param useInstances defines if instances have to be turned on
  66659. * @param useClipPlane defines if clip plane have to be turned on
  66660. */
  66661. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  66662. /**
  66663. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  66664. * @param mesh The mesh containing the geometry data we will draw
  66665. * @param defines The defines to update
  66666. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  66667. * @param useBones Precise whether bones should be used or not (override mesh info)
  66668. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  66669. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  66670. * @returns false if defines are considered not dirty and have not been checked
  66671. */
  66672. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  66673. /**
  66674. * Prepares the defines related to the light information passed in parameter
  66675. * @param scene The scene we are intending to draw
  66676. * @param mesh The mesh the effect is compiling for
  66677. * @param defines The defines to update
  66678. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  66679. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  66680. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  66681. * @returns true if normals will be required for the rest of the effect
  66682. */
  66683. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  66684. /**
  66685. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  66686. * that won t be acctive due to defines being turned off.
  66687. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  66688. * @param samplersList The samplers list
  66689. * @param defines The defines helping in the list generation
  66690. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  66691. */
  66692. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  66693. /**
  66694. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  66695. * @param defines The defines to update while falling back
  66696. * @param fallbacks The authorized effect fallbacks
  66697. * @param maxSimultaneousLights The maximum number of lights allowed
  66698. * @param rank the current rank of the Effect
  66699. * @returns The newly affected rank
  66700. */
  66701. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  66702. /**
  66703. * Prepares the list of attributes required for morph targets according to the effect defines.
  66704. * @param attribs The current list of supported attribs
  66705. * @param mesh The mesh to prepare the morph targets attributes for
  66706. * @param defines The current Defines of the effect
  66707. */
  66708. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  66709. /**
  66710. * Prepares the list of attributes required for bones according to the effect defines.
  66711. * @param attribs The current list of supported attribs
  66712. * @param mesh The mesh to prepare the bones attributes for
  66713. * @param defines The current Defines of the effect
  66714. * @param fallbacks The current efffect fallback strategy
  66715. */
  66716. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  66717. /**
  66718. * Prepares the list of attributes required for instances according to the effect defines.
  66719. * @param attribs The current list of supported attribs
  66720. * @param defines The current Defines of the effect
  66721. */
  66722. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  66723. /**
  66724. * Binds the light shadow information to the effect for the given mesh.
  66725. * @param light The light containing the generator
  66726. * @param scene The scene the lights belongs to
  66727. * @param mesh The mesh we are binding the information to render
  66728. * @param lightIndex The light index in the effect used to render the mesh
  66729. * @param effect The effect we are binding the data to
  66730. */
  66731. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  66732. /**
  66733. * Binds the light information to the effect.
  66734. * @param light The light containing the generator
  66735. * @param effect The effect we are binding the data to
  66736. * @param lightIndex The light index in the effect used to render
  66737. */
  66738. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  66739. /**
  66740. * Binds the lights information from the scene to the effect for the given mesh.
  66741. * @param scene The scene the lights belongs to
  66742. * @param mesh The mesh we are binding the information to render
  66743. * @param effect The effect we are binding the data to
  66744. * @param defines The generated defines for the effect
  66745. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  66746. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  66747. */
  66748. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  66749. private static _tempFogColor;
  66750. /**
  66751. * Binds the fog information from the scene to the effect for the given mesh.
  66752. * @param scene The scene the lights belongs to
  66753. * @param mesh The mesh we are binding the information to render
  66754. * @param effect The effect we are binding the data to
  66755. * @param linearSpace Defines if the fog effect is applied in linear space
  66756. */
  66757. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  66758. /**
  66759. * Binds the bones information from the mesh to the effect.
  66760. * @param mesh The mesh we are binding the information to render
  66761. * @param effect The effect we are binding the data to
  66762. */
  66763. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  66764. /**
  66765. * Binds the morph targets information from the mesh to the effect.
  66766. * @param abstractMesh The mesh we are binding the information to render
  66767. * @param effect The effect we are binding the data to
  66768. */
  66769. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  66770. /**
  66771. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  66772. * @param defines The generated defines used in the effect
  66773. * @param effect The effect we are binding the data to
  66774. * @param scene The scene we are willing to render with logarithmic scale for
  66775. */
  66776. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  66777. /**
  66778. * Binds the clip plane information from the scene to the effect.
  66779. * @param scene The scene the clip plane information are extracted from
  66780. * @param effect The effect we are binding the data to
  66781. */
  66782. static BindClipPlane(effect: Effect, scene: Scene): void;
  66783. }
  66784. }
  66785. declare module BABYLON {
  66786. /** @hidden */
  66787. export var kernelBlurVaryingDeclaration: {
  66788. name: string;
  66789. shader: string;
  66790. };
  66791. }
  66792. declare module BABYLON {
  66793. /** @hidden */
  66794. export var kernelBlurFragment: {
  66795. name: string;
  66796. shader: string;
  66797. };
  66798. }
  66799. declare module BABYLON {
  66800. /** @hidden */
  66801. export var kernelBlurFragment2: {
  66802. name: string;
  66803. shader: string;
  66804. };
  66805. }
  66806. declare module BABYLON {
  66807. /** @hidden */
  66808. export var kernelBlurPixelShader: {
  66809. name: string;
  66810. shader: string;
  66811. };
  66812. }
  66813. declare module BABYLON {
  66814. /** @hidden */
  66815. export var kernelBlurVertex: {
  66816. name: string;
  66817. shader: string;
  66818. };
  66819. }
  66820. declare module BABYLON {
  66821. /** @hidden */
  66822. export var kernelBlurVertexShader: {
  66823. name: string;
  66824. shader: string;
  66825. };
  66826. }
  66827. declare module BABYLON {
  66828. /**
  66829. * The Blur Post Process which blurs an image based on a kernel and direction.
  66830. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  66831. */
  66832. export class BlurPostProcess extends PostProcess {
  66833. /** The direction in which to blur the image. */
  66834. direction: Vector2;
  66835. private blockCompilation;
  66836. protected _kernel: number;
  66837. protected _idealKernel: number;
  66838. protected _packedFloat: boolean;
  66839. private _staticDefines;
  66840. /**
  66841. * Sets the length in pixels of the blur sample region
  66842. */
  66843. /**
  66844. * Gets the length in pixels of the blur sample region
  66845. */
  66846. kernel: number;
  66847. /**
  66848. * Sets wether or not the blur needs to unpack/repack floats
  66849. */
  66850. /**
  66851. * Gets wether or not the blur is unpacking/repacking floats
  66852. */
  66853. packedFloat: boolean;
  66854. /**
  66855. * Creates a new instance BlurPostProcess
  66856. * @param name The name of the effect.
  66857. * @param direction The direction in which to blur the image.
  66858. * @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.
  66859. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  66860. * @param camera The camera to apply the render pass to.
  66861. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66862. * @param engine The engine which the post process will be applied. (default: current engine)
  66863. * @param reusable If the post process can be reused on the same frame. (default: false)
  66864. * @param textureType Type of textures used when performing the post process. (default: 0)
  66865. * @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)
  66866. */
  66867. constructor(name: string,
  66868. /** The direction in which to blur the image. */
  66869. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  66870. /**
  66871. * Updates the effect with the current post process compile time values and recompiles the shader.
  66872. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  66873. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  66874. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  66875. * @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
  66876. * @param onCompiled Called when the shader has been compiled.
  66877. * @param onError Called if there is an error when compiling a shader.
  66878. */
  66879. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66880. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66881. /**
  66882. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  66883. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  66884. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  66885. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  66886. * The gaps between physical kernels are compensated for in the weighting of the samples
  66887. * @param idealKernel Ideal blur kernel.
  66888. * @return Nearest best kernel.
  66889. */
  66890. protected _nearestBestKernel(idealKernel: number): number;
  66891. /**
  66892. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  66893. * @param x The point on the Gaussian distribution to sample.
  66894. * @return the value of the Gaussian function at x.
  66895. */
  66896. protected _gaussianWeight(x: number): number;
  66897. /**
  66898. * Generates a string that can be used as a floating point number in GLSL.
  66899. * @param x Value to print.
  66900. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  66901. * @return GLSL float string.
  66902. */
  66903. protected _glslFloat(x: number, decimalFigures?: number): string;
  66904. }
  66905. }
  66906. declare module BABYLON {
  66907. /** @hidden */
  66908. export var shadowMapPixelShader: {
  66909. name: string;
  66910. shader: string;
  66911. };
  66912. }
  66913. declare module BABYLON {
  66914. /** @hidden */
  66915. export var bonesDeclaration: {
  66916. name: string;
  66917. shader: string;
  66918. };
  66919. }
  66920. declare module BABYLON {
  66921. /** @hidden */
  66922. export var morphTargetsVertexGlobalDeclaration: {
  66923. name: string;
  66924. shader: string;
  66925. };
  66926. }
  66927. declare module BABYLON {
  66928. /** @hidden */
  66929. export var morphTargetsVertexDeclaration: {
  66930. name: string;
  66931. shader: string;
  66932. };
  66933. }
  66934. declare module BABYLON {
  66935. /** @hidden */
  66936. export var instancesDeclaration: {
  66937. name: string;
  66938. shader: string;
  66939. };
  66940. }
  66941. declare module BABYLON {
  66942. /** @hidden */
  66943. export var helperFunctions: {
  66944. name: string;
  66945. shader: string;
  66946. };
  66947. }
  66948. declare module BABYLON {
  66949. /** @hidden */
  66950. export var morphTargetsVertex: {
  66951. name: string;
  66952. shader: string;
  66953. };
  66954. }
  66955. declare module BABYLON {
  66956. /** @hidden */
  66957. export var instancesVertex: {
  66958. name: string;
  66959. shader: string;
  66960. };
  66961. }
  66962. declare module BABYLON {
  66963. /** @hidden */
  66964. export var bonesVertex: {
  66965. name: string;
  66966. shader: string;
  66967. };
  66968. }
  66969. declare module BABYLON {
  66970. /** @hidden */
  66971. export var shadowMapVertexShader: {
  66972. name: string;
  66973. shader: string;
  66974. };
  66975. }
  66976. declare module BABYLON {
  66977. /** @hidden */
  66978. export var depthBoxBlurPixelShader: {
  66979. name: string;
  66980. shader: string;
  66981. };
  66982. }
  66983. declare module BABYLON {
  66984. /**
  66985. * Defines the options associated with the creation of a custom shader for a shadow generator.
  66986. */
  66987. export interface ICustomShaderOptions {
  66988. /**
  66989. * Gets or sets the custom shader name to use
  66990. */
  66991. shaderName: string;
  66992. /**
  66993. * The list of attribute names used in the shader
  66994. */
  66995. attributes?: string[];
  66996. /**
  66997. * The list of unifrom names used in the shader
  66998. */
  66999. uniforms?: string[];
  67000. /**
  67001. * The list of sampler names used in the shader
  67002. */
  67003. samplers?: string[];
  67004. /**
  67005. * The list of defines used in the shader
  67006. */
  67007. defines?: string[];
  67008. }
  67009. /**
  67010. * Interface to implement to create a shadow generator compatible with BJS.
  67011. */
  67012. export interface IShadowGenerator {
  67013. /**
  67014. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67015. * @returns The render target texture if present otherwise, null
  67016. */
  67017. getShadowMap(): Nullable<RenderTargetTexture>;
  67018. /**
  67019. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67020. * @returns The render target texture if the shadow map is present otherwise, null
  67021. */
  67022. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67023. /**
  67024. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67025. * @param subMesh The submesh we want to render in the shadow map
  67026. * @param useInstances Defines wether will draw in the map using instances
  67027. * @returns true if ready otherwise, false
  67028. */
  67029. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67030. /**
  67031. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67032. * @param defines Defines of the material we want to update
  67033. * @param lightIndex Index of the light in the enabled light list of the material
  67034. */
  67035. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  67036. /**
  67037. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67038. * defined in the generator but impacting the effect).
  67039. * It implies the unifroms available on the materials are the standard BJS ones.
  67040. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67041. * @param effect The effect we are binfing the information for
  67042. */
  67043. bindShadowLight(lightIndex: string, effect: Effect): void;
  67044. /**
  67045. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67046. * (eq to shadow prjection matrix * light transform matrix)
  67047. * @returns The transform matrix used to create the shadow map
  67048. */
  67049. getTransformMatrix(): Matrix;
  67050. /**
  67051. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67052. * Cube and 2D textures for instance.
  67053. */
  67054. recreateShadowMap(): void;
  67055. /**
  67056. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67057. * @param onCompiled Callback triggered at the and of the effects compilation
  67058. * @param options Sets of optional options forcing the compilation with different modes
  67059. */
  67060. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67061. useInstances: boolean;
  67062. }>): void;
  67063. /**
  67064. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67065. * @param options Sets of optional options forcing the compilation with different modes
  67066. * @returns A promise that resolves when the compilation completes
  67067. */
  67068. forceCompilationAsync(options?: Partial<{
  67069. useInstances: boolean;
  67070. }>): Promise<void>;
  67071. /**
  67072. * Serializes the shadow generator setup to a json object.
  67073. * @returns The serialized JSON object
  67074. */
  67075. serialize(): any;
  67076. /**
  67077. * Disposes the Shadow map and related Textures and effects.
  67078. */
  67079. dispose(): void;
  67080. }
  67081. /**
  67082. * Default implementation IShadowGenerator.
  67083. * This is the main object responsible of generating shadows in the framework.
  67084. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  67085. */
  67086. export class ShadowGenerator implements IShadowGenerator {
  67087. /**
  67088. * Shadow generator mode None: no filtering applied.
  67089. */
  67090. static readonly FILTER_NONE: number;
  67091. /**
  67092. * Shadow generator mode ESM: Exponential Shadow Mapping.
  67093. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67094. */
  67095. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  67096. /**
  67097. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  67098. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  67099. */
  67100. static readonly FILTER_POISSONSAMPLING: number;
  67101. /**
  67102. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  67103. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67104. */
  67105. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  67106. /**
  67107. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  67108. * edge artifacts on steep falloff.
  67109. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67110. */
  67111. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  67112. /**
  67113. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  67114. * edge artifacts on steep falloff.
  67115. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67116. */
  67117. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  67118. /**
  67119. * Shadow generator mode PCF: Percentage Closer Filtering
  67120. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  67121. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  67122. */
  67123. static readonly FILTER_PCF: number;
  67124. /**
  67125. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  67126. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  67127. * Contact Hardening
  67128. */
  67129. static readonly FILTER_PCSS: number;
  67130. /**
  67131. * Reserved for PCF and PCSS
  67132. * Highest Quality.
  67133. *
  67134. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  67135. *
  67136. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  67137. */
  67138. static readonly QUALITY_HIGH: number;
  67139. /**
  67140. * Reserved for PCF and PCSS
  67141. * Good tradeoff for quality/perf cross devices
  67142. *
  67143. * Execute PCF on a 3*3 kernel.
  67144. *
  67145. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  67146. */
  67147. static readonly QUALITY_MEDIUM: number;
  67148. /**
  67149. * Reserved for PCF and PCSS
  67150. * The lowest quality but the fastest.
  67151. *
  67152. * Execute PCF on a 1*1 kernel.
  67153. *
  67154. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  67155. */
  67156. static readonly QUALITY_LOW: number;
  67157. /** Gets or sets the custom shader name to use */
  67158. customShaderOptions: ICustomShaderOptions;
  67159. /**
  67160. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  67161. */
  67162. onBeforeShadowMapRenderObservable: Observable<Effect>;
  67163. /**
  67164. * Observable triggered before a mesh is rendered in the shadow map.
  67165. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  67166. */
  67167. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  67168. private _bias;
  67169. /**
  67170. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  67171. */
  67172. /**
  67173. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  67174. */
  67175. bias: number;
  67176. private _normalBias;
  67177. /**
  67178. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  67179. */
  67180. /**
  67181. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  67182. */
  67183. normalBias: number;
  67184. private _blurBoxOffset;
  67185. /**
  67186. * Gets the blur box offset: offset applied during the blur pass.
  67187. * Only useful if useKernelBlur = false
  67188. */
  67189. /**
  67190. * Sets the blur box offset: offset applied during the blur pass.
  67191. * Only useful if useKernelBlur = false
  67192. */
  67193. blurBoxOffset: number;
  67194. private _blurScale;
  67195. /**
  67196. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  67197. * 2 means half of the size.
  67198. */
  67199. /**
  67200. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  67201. * 2 means half of the size.
  67202. */
  67203. blurScale: number;
  67204. private _blurKernel;
  67205. /**
  67206. * Gets the blur kernel: kernel size of the blur pass.
  67207. * Only useful if useKernelBlur = true
  67208. */
  67209. /**
  67210. * Sets the blur kernel: kernel size of the blur pass.
  67211. * Only useful if useKernelBlur = true
  67212. */
  67213. blurKernel: number;
  67214. private _useKernelBlur;
  67215. /**
  67216. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  67217. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  67218. */
  67219. /**
  67220. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  67221. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  67222. */
  67223. useKernelBlur: boolean;
  67224. private _depthScale;
  67225. /**
  67226. * Gets the depth scale used in ESM mode.
  67227. */
  67228. /**
  67229. * Sets the depth scale used in ESM mode.
  67230. * This can override the scale stored on the light.
  67231. */
  67232. depthScale: number;
  67233. private _filter;
  67234. /**
  67235. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  67236. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  67237. */
  67238. /**
  67239. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  67240. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  67241. */
  67242. filter: number;
  67243. /**
  67244. * Gets if the current filter is set to Poisson Sampling.
  67245. */
  67246. /**
  67247. * Sets the current filter to Poisson Sampling.
  67248. */
  67249. usePoissonSampling: boolean;
  67250. /**
  67251. * Gets if the current filter is set to ESM.
  67252. */
  67253. /**
  67254. * Sets the current filter is to ESM.
  67255. */
  67256. useExponentialShadowMap: boolean;
  67257. /**
  67258. * Gets if the current filter is set to filtered ESM.
  67259. */
  67260. /**
  67261. * Gets if the current filter is set to filtered ESM.
  67262. */
  67263. useBlurExponentialShadowMap: boolean;
  67264. /**
  67265. * Gets if the current filter is set to "close ESM" (using the inverse of the
  67266. * exponential to prevent steep falloff artifacts).
  67267. */
  67268. /**
  67269. * Sets the current filter to "close ESM" (using the inverse of the
  67270. * exponential to prevent steep falloff artifacts).
  67271. */
  67272. useCloseExponentialShadowMap: boolean;
  67273. /**
  67274. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  67275. * exponential to prevent steep falloff artifacts).
  67276. */
  67277. /**
  67278. * Sets the current filter to filtered "close ESM" (using the inverse of the
  67279. * exponential to prevent steep falloff artifacts).
  67280. */
  67281. useBlurCloseExponentialShadowMap: boolean;
  67282. /**
  67283. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  67284. */
  67285. /**
  67286. * Sets the current filter to "PCF" (percentage closer filtering).
  67287. */
  67288. usePercentageCloserFiltering: boolean;
  67289. private _filteringQuality;
  67290. /**
  67291. * Gets the PCF or PCSS Quality.
  67292. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67293. */
  67294. /**
  67295. * Sets the PCF or PCSS Quality.
  67296. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67297. */
  67298. filteringQuality: number;
  67299. /**
  67300. * Gets if the current filter is set to "PCSS" (contact hardening).
  67301. */
  67302. /**
  67303. * Sets the current filter to "PCSS" (contact hardening).
  67304. */
  67305. useContactHardeningShadow: boolean;
  67306. private _contactHardeningLightSizeUVRatio;
  67307. /**
  67308. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67309. * Using a ratio helps keeping shape stability independently of the map size.
  67310. *
  67311. * It does not account for the light projection as it was having too much
  67312. * instability during the light setup or during light position changes.
  67313. *
  67314. * Only valid if useContactHardeningShadow is true.
  67315. */
  67316. /**
  67317. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67318. * Using a ratio helps keeping shape stability independently of the map size.
  67319. *
  67320. * It does not account for the light projection as it was having too much
  67321. * instability during the light setup or during light position changes.
  67322. *
  67323. * Only valid if useContactHardeningShadow is true.
  67324. */
  67325. contactHardeningLightSizeUVRatio: number;
  67326. private _darkness;
  67327. /**
  67328. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  67329. * 0 means strongest and 1 would means no shadow.
  67330. * @returns the darkness.
  67331. */
  67332. getDarkness(): number;
  67333. /**
  67334. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  67335. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  67336. * @returns the shadow generator allowing fluent coding.
  67337. */
  67338. setDarkness(darkness: number): ShadowGenerator;
  67339. private _transparencyShadow;
  67340. /**
  67341. * Sets the ability to have transparent shadow (boolean).
  67342. * @param transparent True if transparent else False
  67343. * @returns the shadow generator allowing fluent coding
  67344. */
  67345. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  67346. private _shadowMap;
  67347. private _shadowMap2;
  67348. /**
  67349. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67350. * @returns The render target texture if present otherwise, null
  67351. */
  67352. getShadowMap(): Nullable<RenderTargetTexture>;
  67353. /**
  67354. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67355. * @returns The render target texture if the shadow map is present otherwise, null
  67356. */
  67357. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67358. /**
  67359. * Helper function to add a mesh and its descendants to the list of shadow casters.
  67360. * @param mesh Mesh to add
  67361. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  67362. * @returns the Shadow Generator itself
  67363. */
  67364. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67365. /**
  67366. * Helper function to remove a mesh and its descendants from the list of shadow casters
  67367. * @param mesh Mesh to remove
  67368. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  67369. * @returns the Shadow Generator itself
  67370. */
  67371. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67372. /**
  67373. * Controls the extent to which the shadows fade out at the edge of the frustum
  67374. * Used only by directionals and spots
  67375. */
  67376. frustumEdgeFalloff: number;
  67377. private _light;
  67378. /**
  67379. * Returns the associated light object.
  67380. * @returns the light generating the shadow
  67381. */
  67382. getLight(): IShadowLight;
  67383. /**
  67384. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  67385. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  67386. * It might on the other hand introduce peter panning.
  67387. */
  67388. forceBackFacesOnly: boolean;
  67389. private _scene;
  67390. private _lightDirection;
  67391. private _effect;
  67392. private _viewMatrix;
  67393. private _projectionMatrix;
  67394. private _transformMatrix;
  67395. private _cachedPosition;
  67396. private _cachedDirection;
  67397. private _cachedDefines;
  67398. private _currentRenderID;
  67399. private _boxBlurPostprocess;
  67400. private _kernelBlurXPostprocess;
  67401. private _kernelBlurYPostprocess;
  67402. private _blurPostProcesses;
  67403. private _mapSize;
  67404. private _currentFaceIndex;
  67405. private _currentFaceIndexCache;
  67406. private _textureType;
  67407. private _defaultTextureMatrix;
  67408. /** @hidden */
  67409. static _SceneComponentInitialization: (scene: Scene) => void;
  67410. /**
  67411. * Creates a ShadowGenerator object.
  67412. * A ShadowGenerator is the required tool to use the shadows.
  67413. * Each light casting shadows needs to use its own ShadowGenerator.
  67414. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  67415. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  67416. * @param light The light object generating the shadows.
  67417. * @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.
  67418. */
  67419. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  67420. private _initializeGenerator;
  67421. private _initializeShadowMap;
  67422. private _initializeBlurRTTAndPostProcesses;
  67423. private _renderForShadowMap;
  67424. private _renderSubMeshForShadowMap;
  67425. private _applyFilterValues;
  67426. /**
  67427. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67428. * @param onCompiled Callback triggered at the and of the effects compilation
  67429. * @param options Sets of optional options forcing the compilation with different modes
  67430. */
  67431. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67432. useInstances: boolean;
  67433. }>): void;
  67434. /**
  67435. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67436. * @param options Sets of optional options forcing the compilation with different modes
  67437. * @returns A promise that resolves when the compilation completes
  67438. */
  67439. forceCompilationAsync(options?: Partial<{
  67440. useInstances: boolean;
  67441. }>): Promise<void>;
  67442. /**
  67443. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67444. * @param subMesh The submesh we want to render in the shadow map
  67445. * @param useInstances Defines wether will draw in the map using instances
  67446. * @returns true if ready otherwise, false
  67447. */
  67448. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67449. /**
  67450. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67451. * @param defines Defines of the material we want to update
  67452. * @param lightIndex Index of the light in the enabled light list of the material
  67453. */
  67454. prepareDefines(defines: any, lightIndex: number): void;
  67455. /**
  67456. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67457. * defined in the generator but impacting the effect).
  67458. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67459. * @param effect The effect we are binfing the information for
  67460. */
  67461. bindShadowLight(lightIndex: string, effect: Effect): void;
  67462. /**
  67463. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67464. * (eq to shadow prjection matrix * light transform matrix)
  67465. * @returns The transform matrix used to create the shadow map
  67466. */
  67467. getTransformMatrix(): Matrix;
  67468. /**
  67469. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67470. * Cube and 2D textures for instance.
  67471. */
  67472. recreateShadowMap(): void;
  67473. private _disposeBlurPostProcesses;
  67474. private _disposeRTTandPostProcesses;
  67475. /**
  67476. * Disposes the ShadowGenerator.
  67477. * Returns nothing.
  67478. */
  67479. dispose(): void;
  67480. /**
  67481. * Serializes the shadow generator setup to a json object.
  67482. * @returns The serialized JSON object
  67483. */
  67484. serialize(): any;
  67485. /**
  67486. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  67487. * @param parsedShadowGenerator The JSON object to parse
  67488. * @param scene The scene to create the shadow map for
  67489. * @returns The parsed shadow generator
  67490. */
  67491. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  67492. }
  67493. }
  67494. declare module BABYLON {
  67495. /**
  67496. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  67497. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  67498. * 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.
  67499. */
  67500. export abstract class Light extends Node {
  67501. /**
  67502. * Falloff Default: light is falling off following the material specification:
  67503. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  67504. */
  67505. static readonly FALLOFF_DEFAULT: number;
  67506. /**
  67507. * Falloff Physical: light is falling off following the inverse squared distance law.
  67508. */
  67509. static readonly FALLOFF_PHYSICAL: number;
  67510. /**
  67511. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  67512. * to enhance interoperability with other engines.
  67513. */
  67514. static readonly FALLOFF_GLTF: number;
  67515. /**
  67516. * Falloff Standard: light is falling off like in the standard material
  67517. * to enhance interoperability with other materials.
  67518. */
  67519. static readonly FALLOFF_STANDARD: number;
  67520. /**
  67521. * If every light affecting the material is in this lightmapMode,
  67522. * material.lightmapTexture adds or multiplies
  67523. * (depends on material.useLightmapAsShadowmap)
  67524. * after every other light calculations.
  67525. */
  67526. static readonly LIGHTMAP_DEFAULT: number;
  67527. /**
  67528. * material.lightmapTexture as only diffuse lighting from this light
  67529. * adds only specular lighting from this light
  67530. * adds dynamic shadows
  67531. */
  67532. static readonly LIGHTMAP_SPECULAR: number;
  67533. /**
  67534. * material.lightmapTexture as only lighting
  67535. * no light calculation from this light
  67536. * only adds dynamic shadows from this light
  67537. */
  67538. static readonly LIGHTMAP_SHADOWSONLY: number;
  67539. /**
  67540. * Each light type uses the default quantity according to its type:
  67541. * point/spot lights use luminous intensity
  67542. * directional lights use illuminance
  67543. */
  67544. static readonly INTENSITYMODE_AUTOMATIC: number;
  67545. /**
  67546. * lumen (lm)
  67547. */
  67548. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  67549. /**
  67550. * candela (lm/sr)
  67551. */
  67552. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  67553. /**
  67554. * lux (lm/m^2)
  67555. */
  67556. static readonly INTENSITYMODE_ILLUMINANCE: number;
  67557. /**
  67558. * nit (cd/m^2)
  67559. */
  67560. static readonly INTENSITYMODE_LUMINANCE: number;
  67561. /**
  67562. * Light type const id of the point light.
  67563. */
  67564. static readonly LIGHTTYPEID_POINTLIGHT: number;
  67565. /**
  67566. * Light type const id of the directional light.
  67567. */
  67568. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  67569. /**
  67570. * Light type const id of the spot light.
  67571. */
  67572. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  67573. /**
  67574. * Light type const id of the hemispheric light.
  67575. */
  67576. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  67577. /**
  67578. * Diffuse gives the basic color to an object.
  67579. */
  67580. diffuse: Color3;
  67581. /**
  67582. * Specular produces a highlight color on an object.
  67583. * Note: This is note affecting PBR materials.
  67584. */
  67585. specular: Color3;
  67586. /**
  67587. * Defines the falloff type for this light. This lets overrriding how punctual light are
  67588. * falling off base on range or angle.
  67589. * This can be set to any values in Light.FALLOFF_x.
  67590. *
  67591. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  67592. * other types of materials.
  67593. */
  67594. falloffType: number;
  67595. /**
  67596. * Strength of the light.
  67597. * Note: By default it is define in the framework own unit.
  67598. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  67599. */
  67600. intensity: number;
  67601. private _range;
  67602. protected _inverseSquaredRange: number;
  67603. /**
  67604. * Defines how far from the source the light is impacting in scene units.
  67605. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67606. */
  67607. /**
  67608. * Defines how far from the source the light is impacting in scene units.
  67609. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67610. */
  67611. range: number;
  67612. /**
  67613. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  67614. * of light.
  67615. */
  67616. private _photometricScale;
  67617. private _intensityMode;
  67618. /**
  67619. * Gets the photometric scale used to interpret the intensity.
  67620. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67621. */
  67622. /**
  67623. * Sets the photometric scale used to interpret the intensity.
  67624. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67625. */
  67626. intensityMode: number;
  67627. private _radius;
  67628. /**
  67629. * Gets the light radius used by PBR Materials to simulate soft area lights.
  67630. */
  67631. /**
  67632. * sets the light radius used by PBR Materials to simulate soft area lights.
  67633. */
  67634. radius: number;
  67635. private _renderPriority;
  67636. /**
  67637. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  67638. * exceeding the number allowed of the materials.
  67639. */
  67640. renderPriority: number;
  67641. private _shadowEnabled;
  67642. /**
  67643. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67644. * the current shadow generator.
  67645. */
  67646. /**
  67647. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67648. * the current shadow generator.
  67649. */
  67650. shadowEnabled: boolean;
  67651. private _includedOnlyMeshes;
  67652. /**
  67653. * Gets the only meshes impacted by this light.
  67654. */
  67655. /**
  67656. * Sets the only meshes impacted by this light.
  67657. */
  67658. includedOnlyMeshes: AbstractMesh[];
  67659. private _excludedMeshes;
  67660. /**
  67661. * Gets the meshes not impacted by this light.
  67662. */
  67663. /**
  67664. * Sets the meshes not impacted by this light.
  67665. */
  67666. excludedMeshes: AbstractMesh[];
  67667. private _excludeWithLayerMask;
  67668. /**
  67669. * Gets the layer id use to find what meshes are not impacted by the light.
  67670. * Inactive if 0
  67671. */
  67672. /**
  67673. * Sets the layer id use to find what meshes are not impacted by the light.
  67674. * Inactive if 0
  67675. */
  67676. excludeWithLayerMask: number;
  67677. private _includeOnlyWithLayerMask;
  67678. /**
  67679. * Gets the layer id use to find what meshes are impacted by the light.
  67680. * Inactive if 0
  67681. */
  67682. /**
  67683. * Sets the layer id use to find what meshes are impacted by the light.
  67684. * Inactive if 0
  67685. */
  67686. includeOnlyWithLayerMask: number;
  67687. private _lightmapMode;
  67688. /**
  67689. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67690. */
  67691. /**
  67692. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67693. */
  67694. lightmapMode: number;
  67695. /**
  67696. * Shadow generator associted to the light.
  67697. * @hidden Internal use only.
  67698. */
  67699. _shadowGenerator: Nullable<IShadowGenerator>;
  67700. /**
  67701. * @hidden Internal use only.
  67702. */
  67703. _excludedMeshesIds: string[];
  67704. /**
  67705. * @hidden Internal use only.
  67706. */
  67707. _includedOnlyMeshesIds: string[];
  67708. /**
  67709. * The current light unifom buffer.
  67710. * @hidden Internal use only.
  67711. */
  67712. _uniformBuffer: UniformBuffer;
  67713. /**
  67714. * Creates a Light object in the scene.
  67715. * Documentation : https://doc.babylonjs.com/babylon101/lights
  67716. * @param name The firendly name of the light
  67717. * @param scene The scene the light belongs too
  67718. */
  67719. constructor(name: string, scene: Scene);
  67720. protected abstract _buildUniformLayout(): void;
  67721. /**
  67722. * Sets the passed Effect "effect" with the Light information.
  67723. * @param effect The effect to update
  67724. * @param lightIndex The index of the light in the effect to update
  67725. * @returns The light
  67726. */
  67727. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  67728. /**
  67729. * Returns the string "Light".
  67730. * @returns the class name
  67731. */
  67732. getClassName(): string;
  67733. /** @hidden */
  67734. readonly _isLight: boolean;
  67735. /**
  67736. * Converts the light information to a readable string for debug purpose.
  67737. * @param fullDetails Supports for multiple levels of logging within scene loading
  67738. * @returns the human readable light info
  67739. */
  67740. toString(fullDetails?: boolean): string;
  67741. /** @hidden */
  67742. protected _syncParentEnabledState(): void;
  67743. /**
  67744. * Set the enabled state of this node.
  67745. * @param value - the new enabled state
  67746. */
  67747. setEnabled(value: boolean): void;
  67748. /**
  67749. * Returns the Light associated shadow generator if any.
  67750. * @return the associated shadow generator.
  67751. */
  67752. getShadowGenerator(): Nullable<IShadowGenerator>;
  67753. /**
  67754. * Returns a Vector3, the absolute light position in the World.
  67755. * @returns the world space position of the light
  67756. */
  67757. getAbsolutePosition(): Vector3;
  67758. /**
  67759. * Specifies if the light will affect the passed mesh.
  67760. * @param mesh The mesh to test against the light
  67761. * @return true the mesh is affected otherwise, false.
  67762. */
  67763. canAffectMesh(mesh: AbstractMesh): boolean;
  67764. /**
  67765. * Sort function to order lights for rendering.
  67766. * @param a First Light object to compare to second.
  67767. * @param b Second Light object to compare first.
  67768. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  67769. */
  67770. static CompareLightsPriority(a: Light, b: Light): number;
  67771. /**
  67772. * Releases resources associated with this node.
  67773. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67774. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67775. */
  67776. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67777. /**
  67778. * Returns the light type ID (integer).
  67779. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  67780. */
  67781. getTypeID(): number;
  67782. /**
  67783. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  67784. * @returns the scaled intensity in intensity mode unit
  67785. */
  67786. getScaledIntensity(): number;
  67787. /**
  67788. * Returns a new Light object, named "name", from the current one.
  67789. * @param name The name of the cloned light
  67790. * @returns the new created light
  67791. */
  67792. clone(name: string): Nullable<Light>;
  67793. /**
  67794. * Serializes the current light into a Serialization object.
  67795. * @returns the serialized object.
  67796. */
  67797. serialize(): any;
  67798. /**
  67799. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  67800. * This new light is named "name" and added to the passed scene.
  67801. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  67802. * @param name The friendly name of the light
  67803. * @param scene The scene the new light will belong to
  67804. * @returns the constructor function
  67805. */
  67806. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  67807. /**
  67808. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  67809. * @param parsedLight The JSON representation of the light
  67810. * @param scene The scene to create the parsed light in
  67811. * @returns the created light after parsing
  67812. */
  67813. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  67814. private _hookArrayForExcluded;
  67815. private _hookArrayForIncludedOnly;
  67816. private _resyncMeshes;
  67817. /**
  67818. * Forces the meshes to update their light related information in their rendering used effects
  67819. * @hidden Internal Use Only
  67820. */
  67821. _markMeshesAsLightDirty(): void;
  67822. /**
  67823. * Recomputes the cached photometric scale if needed.
  67824. */
  67825. private _computePhotometricScale;
  67826. /**
  67827. * Returns the Photometric Scale according to the light type and intensity mode.
  67828. */
  67829. private _getPhotometricScale;
  67830. /**
  67831. * Reorder the light in the scene according to their defined priority.
  67832. * @hidden Internal Use Only
  67833. */
  67834. _reorderLightsInScene(): void;
  67835. /**
  67836. * Prepares the list of defines specific to the light type.
  67837. * @param defines the list of defines
  67838. * @param lightIndex defines the index of the light for the effect
  67839. */
  67840. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  67841. }
  67842. }
  67843. declare module BABYLON {
  67844. /**
  67845. * Interface used to define Action
  67846. */
  67847. export interface IAction {
  67848. /**
  67849. * Trigger for the action
  67850. */
  67851. trigger: number;
  67852. /** Options of the trigger */
  67853. triggerOptions: any;
  67854. /**
  67855. * Gets the trigger parameters
  67856. * @returns the trigger parameters
  67857. */
  67858. getTriggerParameter(): any;
  67859. /**
  67860. * Internal only - executes current action event
  67861. * @hidden
  67862. */
  67863. _executeCurrent(evt?: ActionEvent): void;
  67864. /**
  67865. * Serialize placeholder for child classes
  67866. * @param parent of child
  67867. * @returns the serialized object
  67868. */
  67869. serialize(parent: any): any;
  67870. /**
  67871. * Internal only
  67872. * @hidden
  67873. */
  67874. _prepare(): void;
  67875. /**
  67876. * Internal only - manager for action
  67877. * @hidden
  67878. */
  67879. _actionManager: AbstractActionManager;
  67880. }
  67881. /**
  67882. * The action to be carried out following a trigger
  67883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  67884. */
  67885. export class Action implements IAction {
  67886. /** the trigger, with or without parameters, for the action */
  67887. triggerOptions: any;
  67888. /**
  67889. * Trigger for the action
  67890. */
  67891. trigger: number;
  67892. /**
  67893. * Internal only - manager for action
  67894. * @hidden
  67895. */
  67896. _actionManager: ActionManager;
  67897. private _nextActiveAction;
  67898. private _child;
  67899. private _condition?;
  67900. private _triggerParameter;
  67901. /**
  67902. * An event triggered prior to action being executed.
  67903. */
  67904. onBeforeExecuteObservable: Observable<Action>;
  67905. /**
  67906. * Creates a new Action
  67907. * @param triggerOptions the trigger, with or without parameters, for the action
  67908. * @param condition an optional determinant of action
  67909. */
  67910. constructor(
  67911. /** the trigger, with or without parameters, for the action */
  67912. triggerOptions: any, condition?: Condition);
  67913. /**
  67914. * Internal only
  67915. * @hidden
  67916. */
  67917. _prepare(): void;
  67918. /**
  67919. * Gets the trigger parameters
  67920. * @returns the trigger parameters
  67921. */
  67922. getTriggerParameter(): any;
  67923. /**
  67924. * Internal only - executes current action event
  67925. * @hidden
  67926. */
  67927. _executeCurrent(evt?: ActionEvent): void;
  67928. /**
  67929. * Execute placeholder for child classes
  67930. * @param evt optional action event
  67931. */
  67932. execute(evt?: ActionEvent): void;
  67933. /**
  67934. * Skips to next active action
  67935. */
  67936. skipToNextActiveAction(): void;
  67937. /**
  67938. * Adds action to chain of actions, may be a DoNothingAction
  67939. * @param action defines the next action to execute
  67940. * @returns The action passed in
  67941. * @see https://www.babylonjs-playground.com/#1T30HR#0
  67942. */
  67943. then(action: Action): Action;
  67944. /**
  67945. * Internal only
  67946. * @hidden
  67947. */
  67948. _getProperty(propertyPath: string): string;
  67949. /**
  67950. * Internal only
  67951. * @hidden
  67952. */
  67953. _getEffectiveTarget(target: any, propertyPath: string): any;
  67954. /**
  67955. * Serialize placeholder for child classes
  67956. * @param parent of child
  67957. * @returns the serialized object
  67958. */
  67959. serialize(parent: any): any;
  67960. /**
  67961. * Internal only called by serialize
  67962. * @hidden
  67963. */
  67964. protected _serialize(serializedAction: any, parent?: any): any;
  67965. /**
  67966. * Internal only
  67967. * @hidden
  67968. */
  67969. static _SerializeValueAsString: (value: any) => string;
  67970. /**
  67971. * Internal only
  67972. * @hidden
  67973. */
  67974. static _GetTargetProperty: (target: Scene | Node) => {
  67975. name: string;
  67976. targetType: string;
  67977. value: string;
  67978. };
  67979. }
  67980. }
  67981. declare module BABYLON {
  67982. /**
  67983. * A Condition applied to an Action
  67984. */
  67985. export class Condition {
  67986. /**
  67987. * Internal only - manager for action
  67988. * @hidden
  67989. */
  67990. _actionManager: ActionManager;
  67991. /**
  67992. * Internal only
  67993. * @hidden
  67994. */
  67995. _evaluationId: number;
  67996. /**
  67997. * Internal only
  67998. * @hidden
  67999. */
  68000. _currentResult: boolean;
  68001. /**
  68002. * Creates a new Condition
  68003. * @param actionManager the manager of the action the condition is applied to
  68004. */
  68005. constructor(actionManager: ActionManager);
  68006. /**
  68007. * Check if the current condition is valid
  68008. * @returns a boolean
  68009. */
  68010. isValid(): boolean;
  68011. /**
  68012. * Internal only
  68013. * @hidden
  68014. */
  68015. _getProperty(propertyPath: string): string;
  68016. /**
  68017. * Internal only
  68018. * @hidden
  68019. */
  68020. _getEffectiveTarget(target: any, propertyPath: string): any;
  68021. /**
  68022. * Serialize placeholder for child classes
  68023. * @returns the serialized object
  68024. */
  68025. serialize(): any;
  68026. /**
  68027. * Internal only
  68028. * @hidden
  68029. */
  68030. protected _serialize(serializedCondition: any): any;
  68031. }
  68032. /**
  68033. * Defines specific conditional operators as extensions of Condition
  68034. */
  68035. export class ValueCondition extends Condition {
  68036. /** path to specify the property of the target the conditional operator uses */
  68037. propertyPath: string;
  68038. /** the value compared by the conditional operator against the current value of the property */
  68039. value: any;
  68040. /** the conditional operator, default ValueCondition.IsEqual */
  68041. operator: number;
  68042. /**
  68043. * Internal only
  68044. * @hidden
  68045. */
  68046. private static _IsEqual;
  68047. /**
  68048. * Internal only
  68049. * @hidden
  68050. */
  68051. private static _IsDifferent;
  68052. /**
  68053. * Internal only
  68054. * @hidden
  68055. */
  68056. private static _IsGreater;
  68057. /**
  68058. * Internal only
  68059. * @hidden
  68060. */
  68061. private static _IsLesser;
  68062. /**
  68063. * returns the number for IsEqual
  68064. */
  68065. static readonly IsEqual: number;
  68066. /**
  68067. * Returns the number for IsDifferent
  68068. */
  68069. static readonly IsDifferent: number;
  68070. /**
  68071. * Returns the number for IsGreater
  68072. */
  68073. static readonly IsGreater: number;
  68074. /**
  68075. * Returns the number for IsLesser
  68076. */
  68077. static readonly IsLesser: number;
  68078. /**
  68079. * Internal only The action manager for the condition
  68080. * @hidden
  68081. */
  68082. _actionManager: ActionManager;
  68083. /**
  68084. * Internal only
  68085. * @hidden
  68086. */
  68087. private _target;
  68088. /**
  68089. * Internal only
  68090. * @hidden
  68091. */
  68092. private _effectiveTarget;
  68093. /**
  68094. * Internal only
  68095. * @hidden
  68096. */
  68097. private _property;
  68098. /**
  68099. * Creates a new ValueCondition
  68100. * @param actionManager manager for the action the condition applies to
  68101. * @param target for the action
  68102. * @param propertyPath path to specify the property of the target the conditional operator uses
  68103. * @param value the value compared by the conditional operator against the current value of the property
  68104. * @param operator the conditional operator, default ValueCondition.IsEqual
  68105. */
  68106. constructor(actionManager: ActionManager, target: any,
  68107. /** path to specify the property of the target the conditional operator uses */
  68108. propertyPath: string,
  68109. /** the value compared by the conditional operator against the current value of the property */
  68110. value: any,
  68111. /** the conditional operator, default ValueCondition.IsEqual */
  68112. operator?: number);
  68113. /**
  68114. * Compares the given value with the property value for the specified conditional operator
  68115. * @returns the result of the comparison
  68116. */
  68117. isValid(): boolean;
  68118. /**
  68119. * Serialize the ValueCondition into a JSON compatible object
  68120. * @returns serialization object
  68121. */
  68122. serialize(): any;
  68123. /**
  68124. * Gets the name of the conditional operator for the ValueCondition
  68125. * @param operator the conditional operator
  68126. * @returns the name
  68127. */
  68128. static GetOperatorName(operator: number): string;
  68129. }
  68130. /**
  68131. * Defines a predicate condition as an extension of Condition
  68132. */
  68133. export class PredicateCondition extends Condition {
  68134. /** defines the predicate function used to validate the condition */
  68135. predicate: () => boolean;
  68136. /**
  68137. * Internal only - manager for action
  68138. * @hidden
  68139. */
  68140. _actionManager: ActionManager;
  68141. /**
  68142. * Creates a new PredicateCondition
  68143. * @param actionManager manager for the action the condition applies to
  68144. * @param predicate defines the predicate function used to validate the condition
  68145. */
  68146. constructor(actionManager: ActionManager,
  68147. /** defines the predicate function used to validate the condition */
  68148. predicate: () => boolean);
  68149. /**
  68150. * @returns the validity of the predicate condition
  68151. */
  68152. isValid(): boolean;
  68153. }
  68154. /**
  68155. * Defines a state condition as an extension of Condition
  68156. */
  68157. export class StateCondition extends Condition {
  68158. /** Value to compare with target state */
  68159. value: string;
  68160. /**
  68161. * Internal only - manager for action
  68162. * @hidden
  68163. */
  68164. _actionManager: ActionManager;
  68165. /**
  68166. * Internal only
  68167. * @hidden
  68168. */
  68169. private _target;
  68170. /**
  68171. * Creates a new StateCondition
  68172. * @param actionManager manager for the action the condition applies to
  68173. * @param target of the condition
  68174. * @param value to compare with target state
  68175. */
  68176. constructor(actionManager: ActionManager, target: any,
  68177. /** Value to compare with target state */
  68178. value: string);
  68179. /**
  68180. * Gets a boolean indicating if the current condition is met
  68181. * @returns the validity of the state
  68182. */
  68183. isValid(): boolean;
  68184. /**
  68185. * Serialize the StateCondition into a JSON compatible object
  68186. * @returns serialization object
  68187. */
  68188. serialize(): any;
  68189. }
  68190. }
  68191. declare module BABYLON {
  68192. /**
  68193. * This defines an action responsible to toggle a boolean once triggered.
  68194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68195. */
  68196. export class SwitchBooleanAction extends Action {
  68197. /**
  68198. * The path to the boolean property in the target object
  68199. */
  68200. propertyPath: string;
  68201. private _target;
  68202. private _effectiveTarget;
  68203. private _property;
  68204. /**
  68205. * Instantiate the action
  68206. * @param triggerOptions defines the trigger options
  68207. * @param target defines the object containing the boolean
  68208. * @param propertyPath defines the path to the boolean property in the target object
  68209. * @param condition defines the trigger related conditions
  68210. */
  68211. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  68212. /** @hidden */
  68213. _prepare(): void;
  68214. /**
  68215. * Execute the action toggle the boolean value.
  68216. */
  68217. execute(): void;
  68218. /**
  68219. * Serializes the actions and its related information.
  68220. * @param parent defines the object to serialize in
  68221. * @returns the serialized object
  68222. */
  68223. serialize(parent: any): any;
  68224. }
  68225. /**
  68226. * This defines an action responsible to set a the state field of the target
  68227. * to a desired value once triggered.
  68228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68229. */
  68230. export class SetStateAction extends Action {
  68231. /**
  68232. * The value to store in the state field.
  68233. */
  68234. value: string;
  68235. private _target;
  68236. /**
  68237. * Instantiate the action
  68238. * @param triggerOptions defines the trigger options
  68239. * @param target defines the object containing the state property
  68240. * @param value defines the value to store in the state field
  68241. * @param condition defines the trigger related conditions
  68242. */
  68243. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  68244. /**
  68245. * Execute the action and store the value on the target state property.
  68246. */
  68247. execute(): void;
  68248. /**
  68249. * Serializes the actions and its related information.
  68250. * @param parent defines the object to serialize in
  68251. * @returns the serialized object
  68252. */
  68253. serialize(parent: any): any;
  68254. }
  68255. /**
  68256. * This defines an action responsible to set a property of the target
  68257. * to a desired value once triggered.
  68258. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68259. */
  68260. export class SetValueAction extends Action {
  68261. /**
  68262. * The path of the property to set in the target.
  68263. */
  68264. propertyPath: string;
  68265. /**
  68266. * The value to set in the property
  68267. */
  68268. value: any;
  68269. private _target;
  68270. private _effectiveTarget;
  68271. private _property;
  68272. /**
  68273. * Instantiate the action
  68274. * @param triggerOptions defines the trigger options
  68275. * @param target defines the object containing the property
  68276. * @param propertyPath defines the path of the property to set in the target
  68277. * @param value defines the value to set in the property
  68278. * @param condition defines the trigger related conditions
  68279. */
  68280. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68281. /** @hidden */
  68282. _prepare(): void;
  68283. /**
  68284. * Execute the action and set the targetted property to the desired value.
  68285. */
  68286. execute(): void;
  68287. /**
  68288. * Serializes the actions and its related information.
  68289. * @param parent defines the object to serialize in
  68290. * @returns the serialized object
  68291. */
  68292. serialize(parent: any): any;
  68293. }
  68294. /**
  68295. * This defines an action responsible to increment the target value
  68296. * to a desired value once triggered.
  68297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68298. */
  68299. export class IncrementValueAction extends Action {
  68300. /**
  68301. * The path of the property to increment in the target.
  68302. */
  68303. propertyPath: string;
  68304. /**
  68305. * The value we should increment the property by.
  68306. */
  68307. value: any;
  68308. private _target;
  68309. private _effectiveTarget;
  68310. private _property;
  68311. /**
  68312. * Instantiate the action
  68313. * @param triggerOptions defines the trigger options
  68314. * @param target defines the object containing the property
  68315. * @param propertyPath defines the path of the property to increment in the target
  68316. * @param value defines the value value we should increment the property by
  68317. * @param condition defines the trigger related conditions
  68318. */
  68319. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68320. /** @hidden */
  68321. _prepare(): void;
  68322. /**
  68323. * Execute the action and increment the target of the value amount.
  68324. */
  68325. execute(): void;
  68326. /**
  68327. * Serializes the actions and its related information.
  68328. * @param parent defines the object to serialize in
  68329. * @returns the serialized object
  68330. */
  68331. serialize(parent: any): any;
  68332. }
  68333. /**
  68334. * This defines an action responsible to start an animation once triggered.
  68335. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68336. */
  68337. export class PlayAnimationAction extends Action {
  68338. /**
  68339. * Where the animation should start (animation frame)
  68340. */
  68341. from: number;
  68342. /**
  68343. * Where the animation should stop (animation frame)
  68344. */
  68345. to: number;
  68346. /**
  68347. * Define if the animation should loop or stop after the first play.
  68348. */
  68349. loop?: boolean;
  68350. private _target;
  68351. /**
  68352. * Instantiate the action
  68353. * @param triggerOptions defines the trigger options
  68354. * @param target defines the target animation or animation name
  68355. * @param from defines from where the animation should start (animation frame)
  68356. * @param end defines where the animation should stop (animation frame)
  68357. * @param loop defines if the animation should loop or stop after the first play
  68358. * @param condition defines the trigger related conditions
  68359. */
  68360. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  68361. /** @hidden */
  68362. _prepare(): void;
  68363. /**
  68364. * Execute the action and play the animation.
  68365. */
  68366. execute(): void;
  68367. /**
  68368. * Serializes the actions and its related information.
  68369. * @param parent defines the object to serialize in
  68370. * @returns the serialized object
  68371. */
  68372. serialize(parent: any): any;
  68373. }
  68374. /**
  68375. * This defines an action responsible to stop an animation once triggered.
  68376. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68377. */
  68378. export class StopAnimationAction extends Action {
  68379. private _target;
  68380. /**
  68381. * Instantiate the action
  68382. * @param triggerOptions defines the trigger options
  68383. * @param target defines the target animation or animation name
  68384. * @param condition defines the trigger related conditions
  68385. */
  68386. constructor(triggerOptions: any, target: any, condition?: Condition);
  68387. /** @hidden */
  68388. _prepare(): void;
  68389. /**
  68390. * Execute the action and stop the animation.
  68391. */
  68392. execute(): void;
  68393. /**
  68394. * Serializes the actions and its related information.
  68395. * @param parent defines the object to serialize in
  68396. * @returns the serialized object
  68397. */
  68398. serialize(parent: any): any;
  68399. }
  68400. /**
  68401. * This defines an action responsible that does nothing once triggered.
  68402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68403. */
  68404. export class DoNothingAction extends Action {
  68405. /**
  68406. * Instantiate the action
  68407. * @param triggerOptions defines the trigger options
  68408. * @param condition defines the trigger related conditions
  68409. */
  68410. constructor(triggerOptions?: any, condition?: Condition);
  68411. /**
  68412. * Execute the action and do nothing.
  68413. */
  68414. execute(): void;
  68415. /**
  68416. * Serializes the actions and its related information.
  68417. * @param parent defines the object to serialize in
  68418. * @returns the serialized object
  68419. */
  68420. serialize(parent: any): any;
  68421. }
  68422. /**
  68423. * This defines an action responsible to trigger several actions once triggered.
  68424. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68425. */
  68426. export class CombineAction extends Action {
  68427. /**
  68428. * The list of aggregated animations to run.
  68429. */
  68430. children: Action[];
  68431. /**
  68432. * Instantiate the action
  68433. * @param triggerOptions defines the trigger options
  68434. * @param children defines the list of aggregated animations to run
  68435. * @param condition defines the trigger related conditions
  68436. */
  68437. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  68438. /** @hidden */
  68439. _prepare(): void;
  68440. /**
  68441. * Execute the action and executes all the aggregated actions.
  68442. */
  68443. execute(evt: ActionEvent): void;
  68444. /**
  68445. * Serializes the actions and its related information.
  68446. * @param parent defines the object to serialize in
  68447. * @returns the serialized object
  68448. */
  68449. serialize(parent: any): any;
  68450. }
  68451. /**
  68452. * This defines an action responsible to run code (external event) once triggered.
  68453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68454. */
  68455. export class ExecuteCodeAction extends Action {
  68456. /**
  68457. * The callback function to run.
  68458. */
  68459. func: (evt: ActionEvent) => void;
  68460. /**
  68461. * Instantiate the action
  68462. * @param triggerOptions defines the trigger options
  68463. * @param func defines the callback function to run
  68464. * @param condition defines the trigger related conditions
  68465. */
  68466. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  68467. /**
  68468. * Execute the action and run the attached code.
  68469. */
  68470. execute(evt: ActionEvent): void;
  68471. }
  68472. /**
  68473. * This defines an action responsible to set the parent property of the target once triggered.
  68474. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68475. */
  68476. export class SetParentAction extends Action {
  68477. private _parent;
  68478. private _target;
  68479. /**
  68480. * Instantiate the action
  68481. * @param triggerOptions defines the trigger options
  68482. * @param target defines the target containing the parent property
  68483. * @param parent defines from where the animation should start (animation frame)
  68484. * @param condition defines the trigger related conditions
  68485. */
  68486. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  68487. /** @hidden */
  68488. _prepare(): void;
  68489. /**
  68490. * Execute the action and set the parent property.
  68491. */
  68492. execute(): void;
  68493. /**
  68494. * Serializes the actions and its related information.
  68495. * @param parent defines the object to serialize in
  68496. * @returns the serialized object
  68497. */
  68498. serialize(parent: any): any;
  68499. }
  68500. }
  68501. declare module BABYLON {
  68502. /**
  68503. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  68504. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  68505. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68506. */
  68507. export class ActionManager extends AbstractActionManager {
  68508. /**
  68509. * Nothing
  68510. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68511. */
  68512. static readonly NothingTrigger: number;
  68513. /**
  68514. * On pick
  68515. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68516. */
  68517. static readonly OnPickTrigger: number;
  68518. /**
  68519. * On left pick
  68520. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68521. */
  68522. static readonly OnLeftPickTrigger: number;
  68523. /**
  68524. * On right pick
  68525. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68526. */
  68527. static readonly OnRightPickTrigger: number;
  68528. /**
  68529. * On center pick
  68530. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68531. */
  68532. static readonly OnCenterPickTrigger: number;
  68533. /**
  68534. * On pick down
  68535. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68536. */
  68537. static readonly OnPickDownTrigger: number;
  68538. /**
  68539. * On double pick
  68540. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68541. */
  68542. static readonly OnDoublePickTrigger: number;
  68543. /**
  68544. * On pick up
  68545. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68546. */
  68547. static readonly OnPickUpTrigger: number;
  68548. /**
  68549. * On pick out.
  68550. * This trigger will only be raised if you also declared a OnPickDown
  68551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68552. */
  68553. static readonly OnPickOutTrigger: number;
  68554. /**
  68555. * On long press
  68556. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68557. */
  68558. static readonly OnLongPressTrigger: number;
  68559. /**
  68560. * On pointer over
  68561. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68562. */
  68563. static readonly OnPointerOverTrigger: number;
  68564. /**
  68565. * On pointer out
  68566. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68567. */
  68568. static readonly OnPointerOutTrigger: number;
  68569. /**
  68570. * On every frame
  68571. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68572. */
  68573. static readonly OnEveryFrameTrigger: number;
  68574. /**
  68575. * On intersection enter
  68576. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68577. */
  68578. static readonly OnIntersectionEnterTrigger: number;
  68579. /**
  68580. * On intersection exit
  68581. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68582. */
  68583. static readonly OnIntersectionExitTrigger: number;
  68584. /**
  68585. * On key down
  68586. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68587. */
  68588. static readonly OnKeyDownTrigger: number;
  68589. /**
  68590. * On key up
  68591. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68592. */
  68593. static readonly OnKeyUpTrigger: number;
  68594. private _scene;
  68595. /**
  68596. * Creates a new action manager
  68597. * @param scene defines the hosting scene
  68598. */
  68599. constructor(scene: Scene);
  68600. /**
  68601. * Releases all associated resources
  68602. */
  68603. dispose(): void;
  68604. /**
  68605. * Gets hosting scene
  68606. * @returns the hosting scene
  68607. */
  68608. getScene(): Scene;
  68609. /**
  68610. * Does this action manager handles actions of any of the given triggers
  68611. * @param triggers defines the triggers to be tested
  68612. * @return a boolean indicating whether one (or more) of the triggers is handled
  68613. */
  68614. hasSpecificTriggers(triggers: number[]): boolean;
  68615. /**
  68616. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  68617. * speed.
  68618. * @param triggerA defines the trigger to be tested
  68619. * @param triggerB defines the trigger to be tested
  68620. * @return a boolean indicating whether one (or more) of the triggers is handled
  68621. */
  68622. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  68623. /**
  68624. * Does this action manager handles actions of a given trigger
  68625. * @param trigger defines the trigger to be tested
  68626. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  68627. * @return whether the trigger is handled
  68628. */
  68629. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  68630. /**
  68631. * Does this action manager has pointer triggers
  68632. */
  68633. readonly hasPointerTriggers: boolean;
  68634. /**
  68635. * Does this action manager has pick triggers
  68636. */
  68637. readonly hasPickTriggers: boolean;
  68638. /**
  68639. * Registers an action to this action manager
  68640. * @param action defines the action to be registered
  68641. * @return the action amended (prepared) after registration
  68642. */
  68643. registerAction(action: IAction): Nullable<IAction>;
  68644. /**
  68645. * Unregisters an action to this action manager
  68646. * @param action defines the action to be unregistered
  68647. * @return a boolean indicating whether the action has been unregistered
  68648. */
  68649. unregisterAction(action: IAction): Boolean;
  68650. /**
  68651. * Process a specific trigger
  68652. * @param trigger defines the trigger to process
  68653. * @param evt defines the event details to be processed
  68654. */
  68655. processTrigger(trigger: number, evt?: IActionEvent): void;
  68656. /** @hidden */
  68657. _getEffectiveTarget(target: any, propertyPath: string): any;
  68658. /** @hidden */
  68659. _getProperty(propertyPath: string): string;
  68660. /**
  68661. * Serialize this manager to a JSON object
  68662. * @param name defines the property name to store this manager
  68663. * @returns a JSON representation of this manager
  68664. */
  68665. serialize(name: string): any;
  68666. /**
  68667. * Creates a new ActionManager from a JSON data
  68668. * @param parsedActions defines the JSON data to read from
  68669. * @param object defines the hosting mesh
  68670. * @param scene defines the hosting scene
  68671. */
  68672. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  68673. /**
  68674. * Get a trigger name by index
  68675. * @param trigger defines the trigger index
  68676. * @returns a trigger name
  68677. */
  68678. static GetTriggerName(trigger: number): string;
  68679. }
  68680. }
  68681. declare module BABYLON {
  68682. /**
  68683. * Class representing a ray with position and direction
  68684. */
  68685. export class Ray {
  68686. /** origin point */
  68687. origin: Vector3;
  68688. /** direction */
  68689. direction: Vector3;
  68690. /** length of the ray */
  68691. length: number;
  68692. private static readonly TmpVector3;
  68693. private _tmpRay;
  68694. /**
  68695. * Creates a new ray
  68696. * @param origin origin point
  68697. * @param direction direction
  68698. * @param length length of the ray
  68699. */
  68700. constructor(
  68701. /** origin point */
  68702. origin: Vector3,
  68703. /** direction */
  68704. direction: Vector3,
  68705. /** length of the ray */
  68706. length?: number);
  68707. /**
  68708. * Checks if the ray intersects a box
  68709. * @param minimum bound of the box
  68710. * @param maximum bound of the box
  68711. * @param intersectionTreshold extra extend to be added to the box in all direction
  68712. * @returns if the box was hit
  68713. */
  68714. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  68715. /**
  68716. * Checks if the ray intersects a box
  68717. * @param box the bounding box to check
  68718. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  68719. * @returns if the box was hit
  68720. */
  68721. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  68722. /**
  68723. * If the ray hits a sphere
  68724. * @param sphere the bounding sphere to check
  68725. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  68726. * @returns true if it hits the sphere
  68727. */
  68728. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  68729. /**
  68730. * If the ray hits a triange
  68731. * @param vertex0 triangle vertex
  68732. * @param vertex1 triangle vertex
  68733. * @param vertex2 triangle vertex
  68734. * @returns intersection information if hit
  68735. */
  68736. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  68737. /**
  68738. * Checks if ray intersects a plane
  68739. * @param plane the plane to check
  68740. * @returns the distance away it was hit
  68741. */
  68742. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  68743. /**
  68744. * Checks if ray intersects a mesh
  68745. * @param mesh the mesh to check
  68746. * @param fastCheck if only the bounding box should checked
  68747. * @returns picking info of the intersecton
  68748. */
  68749. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  68750. /**
  68751. * Checks if ray intersects a mesh
  68752. * @param meshes the meshes to check
  68753. * @param fastCheck if only the bounding box should checked
  68754. * @param results array to store result in
  68755. * @returns Array of picking infos
  68756. */
  68757. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  68758. private _comparePickingInfo;
  68759. private static smallnum;
  68760. private static rayl;
  68761. /**
  68762. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  68763. * @param sega the first point of the segment to test the intersection against
  68764. * @param segb the second point of the segment to test the intersection against
  68765. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  68766. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  68767. */
  68768. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  68769. /**
  68770. * Update the ray from viewport position
  68771. * @param x position
  68772. * @param y y position
  68773. * @param viewportWidth viewport width
  68774. * @param viewportHeight viewport height
  68775. * @param world world matrix
  68776. * @param view view matrix
  68777. * @param projection projection matrix
  68778. * @returns this ray updated
  68779. */
  68780. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68781. /**
  68782. * Creates a ray with origin and direction of 0,0,0
  68783. * @returns the new ray
  68784. */
  68785. static Zero(): Ray;
  68786. /**
  68787. * Creates a new ray from screen space and viewport
  68788. * @param x position
  68789. * @param y y position
  68790. * @param viewportWidth viewport width
  68791. * @param viewportHeight viewport height
  68792. * @param world world matrix
  68793. * @param view view matrix
  68794. * @param projection projection matrix
  68795. * @returns new ray
  68796. */
  68797. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68798. /**
  68799. * 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
  68800. * transformed to the given world matrix.
  68801. * @param origin The origin point
  68802. * @param end The end point
  68803. * @param world a matrix to transform the ray to. Default is the identity matrix.
  68804. * @returns the new ray
  68805. */
  68806. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  68807. /**
  68808. * Transforms a ray by a matrix
  68809. * @param ray ray to transform
  68810. * @param matrix matrix to apply
  68811. * @returns the resulting new ray
  68812. */
  68813. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  68814. /**
  68815. * Transforms a ray by a matrix
  68816. * @param ray ray to transform
  68817. * @param matrix matrix to apply
  68818. * @param result ray to store result in
  68819. */
  68820. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  68821. /**
  68822. * Unproject a ray from screen space to object space
  68823. * @param sourceX defines the screen space x coordinate to use
  68824. * @param sourceY defines the screen space y coordinate to use
  68825. * @param viewportWidth defines the current width of the viewport
  68826. * @param viewportHeight defines the current height of the viewport
  68827. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68828. * @param view defines the view matrix to use
  68829. * @param projection defines the projection matrix to use
  68830. */
  68831. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  68832. }
  68833. /**
  68834. * Type used to define predicate used to select faces when a mesh intersection is detected
  68835. */
  68836. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  68837. interface Scene {
  68838. /** @hidden */
  68839. _tempPickingRay: Nullable<Ray>;
  68840. /** @hidden */
  68841. _cachedRayForTransform: Ray;
  68842. /** @hidden */
  68843. _pickWithRayInverseMatrix: Matrix;
  68844. /** @hidden */
  68845. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  68846. /** @hidden */
  68847. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  68848. }
  68849. }
  68850. declare module BABYLON {
  68851. /**
  68852. * Groups all the scene component constants in one place to ease maintenance.
  68853. * @hidden
  68854. */
  68855. export class SceneComponentConstants {
  68856. static readonly NAME_EFFECTLAYER: string;
  68857. static readonly NAME_LAYER: string;
  68858. static readonly NAME_LENSFLARESYSTEM: string;
  68859. static readonly NAME_BOUNDINGBOXRENDERER: string;
  68860. static readonly NAME_PARTICLESYSTEM: string;
  68861. static readonly NAME_GAMEPAD: string;
  68862. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  68863. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  68864. static readonly NAME_DEPTHRENDERER: string;
  68865. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  68866. static readonly NAME_SPRITE: string;
  68867. static readonly NAME_OUTLINERENDERER: string;
  68868. static readonly NAME_PROCEDURALTEXTURE: string;
  68869. static readonly NAME_SHADOWGENERATOR: string;
  68870. static readonly NAME_OCTREE: string;
  68871. static readonly NAME_PHYSICSENGINE: string;
  68872. static readonly NAME_AUDIO: string;
  68873. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  68874. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68875. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  68876. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68877. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  68878. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  68879. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  68880. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  68881. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  68882. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  68883. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  68884. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  68885. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  68886. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  68887. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  68888. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  68889. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  68890. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  68891. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  68892. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  68893. static readonly STEP_AFTERRENDER_AUDIO: number;
  68894. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  68895. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  68896. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  68897. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  68898. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  68899. static readonly STEP_POINTERMOVE_SPRITE: number;
  68900. static readonly STEP_POINTERDOWN_SPRITE: number;
  68901. static readonly STEP_POINTERUP_SPRITE: number;
  68902. }
  68903. /**
  68904. * This represents a scene component.
  68905. *
  68906. * This is used to decouple the dependency the scene is having on the different workloads like
  68907. * layers, post processes...
  68908. */
  68909. export interface ISceneComponent {
  68910. /**
  68911. * The name of the component. Each component must have a unique name.
  68912. */
  68913. name: string;
  68914. /**
  68915. * The scene the component belongs to.
  68916. */
  68917. scene: Scene;
  68918. /**
  68919. * Register the component to one instance of a scene.
  68920. */
  68921. register(): void;
  68922. /**
  68923. * Rebuilds the elements related to this component in case of
  68924. * context lost for instance.
  68925. */
  68926. rebuild(): void;
  68927. /**
  68928. * Disposes the component and the associated ressources.
  68929. */
  68930. dispose(): void;
  68931. }
  68932. /**
  68933. * This represents a SERIALIZABLE scene component.
  68934. *
  68935. * This extends Scene Component to add Serialization methods on top.
  68936. */
  68937. export interface ISceneSerializableComponent extends ISceneComponent {
  68938. /**
  68939. * Adds all the element from the container to the scene
  68940. * @param container the container holding the elements
  68941. */
  68942. addFromContainer(container: AbstractScene): void;
  68943. /**
  68944. * Removes all the elements in the container from the scene
  68945. * @param container contains the elements to remove
  68946. */
  68947. removeFromContainer(container: AbstractScene): void;
  68948. /**
  68949. * Serializes the component data to the specified json object
  68950. * @param serializationObject The object to serialize to
  68951. */
  68952. serialize(serializationObject: any): void;
  68953. }
  68954. /**
  68955. * Strong typing of a Mesh related stage step action
  68956. */
  68957. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  68958. /**
  68959. * Strong typing of a Evaluate Sub Mesh related stage step action
  68960. */
  68961. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  68962. /**
  68963. * Strong typing of a Active Mesh related stage step action
  68964. */
  68965. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  68966. /**
  68967. * Strong typing of a Camera related stage step action
  68968. */
  68969. export type CameraStageAction = (camera: Camera) => void;
  68970. /**
  68971. * Strong typing of a Render Target related stage step action
  68972. */
  68973. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  68974. /**
  68975. * Strong typing of a RenderingGroup related stage step action
  68976. */
  68977. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  68978. /**
  68979. * Strong typing of a Mesh Render related stage step action
  68980. */
  68981. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  68982. /**
  68983. * Strong typing of a simple stage step action
  68984. */
  68985. export type SimpleStageAction = () => void;
  68986. /**
  68987. * Strong typing of a render target action.
  68988. */
  68989. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  68990. /**
  68991. * Strong typing of a pointer move action.
  68992. */
  68993. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  68994. /**
  68995. * Strong typing of a pointer up/down action.
  68996. */
  68997. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  68998. /**
  68999. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  69000. * @hidden
  69001. */
  69002. export class Stage<T extends Function> extends Array<{
  69003. index: number;
  69004. component: ISceneComponent;
  69005. action: T;
  69006. }> {
  69007. /**
  69008. * Hide ctor from the rest of the world.
  69009. * @param items The items to add.
  69010. */
  69011. private constructor();
  69012. /**
  69013. * Creates a new Stage.
  69014. * @returns A new instance of a Stage
  69015. */
  69016. static Create<T extends Function>(): Stage<T>;
  69017. /**
  69018. * Registers a step in an ordered way in the targeted stage.
  69019. * @param index Defines the position to register the step in
  69020. * @param component Defines the component attached to the step
  69021. * @param action Defines the action to launch during the step
  69022. */
  69023. registerStep(index: number, component: ISceneComponent, action: T): void;
  69024. /**
  69025. * Clears all the steps from the stage.
  69026. */
  69027. clear(): void;
  69028. }
  69029. }
  69030. declare module BABYLON {
  69031. interface Scene {
  69032. /** @hidden */
  69033. _pointerOverSprite: Nullable<Sprite>;
  69034. /** @hidden */
  69035. _pickedDownSprite: Nullable<Sprite>;
  69036. /** @hidden */
  69037. _tempSpritePickingRay: Nullable<Ray>;
  69038. /**
  69039. * All of the sprite managers added to this scene
  69040. * @see http://doc.babylonjs.com/babylon101/sprites
  69041. */
  69042. spriteManagers: Array<ISpriteManager>;
  69043. /**
  69044. * An event triggered when sprites rendering is about to start
  69045. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69046. */
  69047. onBeforeSpritesRenderingObservable: Observable<Scene>;
  69048. /**
  69049. * An event triggered when sprites rendering is done
  69050. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69051. */
  69052. onAfterSpritesRenderingObservable: Observable<Scene>;
  69053. /** @hidden */
  69054. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69055. /** Launch a ray to try to pick a sprite in the scene
  69056. * @param x position on screen
  69057. * @param y position on screen
  69058. * @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
  69059. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69060. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  69061. * @returns a PickingInfo
  69062. */
  69063. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69064. /** Use the given ray to pick a sprite in the scene
  69065. * @param ray The ray (in world space) to use to pick meshes
  69066. * @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
  69067. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69068. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  69069. * @returns a PickingInfo
  69070. */
  69071. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69072. /**
  69073. * Force the sprite under the pointer
  69074. * @param sprite defines the sprite to use
  69075. */
  69076. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  69077. /**
  69078. * Gets the sprite under the pointer
  69079. * @returns a Sprite or null if no sprite is under the pointer
  69080. */
  69081. getPointerOverSprite(): Nullable<Sprite>;
  69082. }
  69083. /**
  69084. * Defines the sprite scene component responsible to manage sprites
  69085. * in a given scene.
  69086. */
  69087. export class SpriteSceneComponent implements ISceneComponent {
  69088. /**
  69089. * The component name helpfull to identify the component in the list of scene components.
  69090. */
  69091. readonly name: string;
  69092. /**
  69093. * The scene the component belongs to.
  69094. */
  69095. scene: Scene;
  69096. /** @hidden */
  69097. private _spritePredicate;
  69098. /**
  69099. * Creates a new instance of the component for the given scene
  69100. * @param scene Defines the scene to register the component in
  69101. */
  69102. constructor(scene: Scene);
  69103. /**
  69104. * Registers the component in a given scene
  69105. */
  69106. register(): void;
  69107. /**
  69108. * Rebuilds the elements related to this component in case of
  69109. * context lost for instance.
  69110. */
  69111. rebuild(): void;
  69112. /**
  69113. * Disposes the component and the associated ressources.
  69114. */
  69115. dispose(): void;
  69116. private _pickSpriteButKeepRay;
  69117. private _pointerMove;
  69118. private _pointerDown;
  69119. private _pointerUp;
  69120. }
  69121. }
  69122. declare module BABYLON {
  69123. /** @hidden */
  69124. export var fogFragmentDeclaration: {
  69125. name: string;
  69126. shader: string;
  69127. };
  69128. }
  69129. declare module BABYLON {
  69130. /** @hidden */
  69131. export var fogFragment: {
  69132. name: string;
  69133. shader: string;
  69134. };
  69135. }
  69136. declare module BABYLON {
  69137. /** @hidden */
  69138. export var spritesPixelShader: {
  69139. name: string;
  69140. shader: string;
  69141. };
  69142. }
  69143. declare module BABYLON {
  69144. /** @hidden */
  69145. export var fogVertexDeclaration: {
  69146. name: string;
  69147. shader: string;
  69148. };
  69149. }
  69150. declare module BABYLON {
  69151. /** @hidden */
  69152. export var spritesVertexShader: {
  69153. name: string;
  69154. shader: string;
  69155. };
  69156. }
  69157. declare module BABYLON {
  69158. /**
  69159. * Defines the minimum interface to fullfil in order to be a sprite manager.
  69160. */
  69161. export interface ISpriteManager extends IDisposable {
  69162. /**
  69163. * Restricts the camera to viewing objects with the same layerMask.
  69164. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  69165. */
  69166. layerMask: number;
  69167. /**
  69168. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  69169. */
  69170. isPickable: boolean;
  69171. /**
  69172. * Specifies the rendering group id for this mesh (0 by default)
  69173. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  69174. */
  69175. renderingGroupId: number;
  69176. /**
  69177. * Defines the list of sprites managed by the manager.
  69178. */
  69179. sprites: Array<Sprite>;
  69180. /**
  69181. * Tests the intersection of a sprite with a specific ray.
  69182. * @param ray The ray we are sending to test the collision
  69183. * @param camera The camera space we are sending rays in
  69184. * @param predicate A predicate allowing excluding sprites from the list of object to test
  69185. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  69186. * @returns picking info or null.
  69187. */
  69188. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  69189. /**
  69190. * Renders the list of sprites on screen.
  69191. */
  69192. render(): void;
  69193. }
  69194. /**
  69195. * Class used to manage multiple sprites on the same spritesheet
  69196. * @see http://doc.babylonjs.com/babylon101/sprites
  69197. */
  69198. export class SpriteManager implements ISpriteManager {
  69199. /** defines the manager's name */
  69200. name: string;
  69201. /** Gets the list of sprites */
  69202. sprites: Sprite[];
  69203. /** Gets or sets the rendering group id (0 by default) */
  69204. renderingGroupId: number;
  69205. /** Gets or sets camera layer mask */
  69206. layerMask: number;
  69207. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  69208. fogEnabled: boolean;
  69209. /** Gets or sets a boolean indicating if the sprites are pickable */
  69210. isPickable: boolean;
  69211. /** Defines the default width of a cell in the spritesheet */
  69212. cellWidth: number;
  69213. /** Defines the default height of a cell in the spritesheet */
  69214. cellHeight: number;
  69215. /**
  69216. * An event triggered when the manager is disposed.
  69217. */
  69218. onDisposeObservable: Observable<SpriteManager>;
  69219. private _onDisposeObserver;
  69220. /**
  69221. * Callback called when the manager is disposed
  69222. */
  69223. onDispose: () => void;
  69224. private _capacity;
  69225. private _spriteTexture;
  69226. private _epsilon;
  69227. private _scene;
  69228. private _vertexData;
  69229. private _buffer;
  69230. private _vertexBuffers;
  69231. private _indexBuffer;
  69232. private _effectBase;
  69233. private _effectFog;
  69234. /**
  69235. * Gets or sets the spritesheet texture
  69236. */
  69237. texture: Texture;
  69238. /**
  69239. * Creates a new sprite manager
  69240. * @param name defines the manager's name
  69241. * @param imgUrl defines the sprite sheet url
  69242. * @param capacity defines the maximum allowed number of sprites
  69243. * @param cellSize defines the size of a sprite cell
  69244. * @param scene defines the hosting scene
  69245. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  69246. * @param samplingMode defines the smapling mode to use with spritesheet
  69247. */
  69248. constructor(
  69249. /** defines the manager's name */
  69250. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  69251. private _appendSpriteVertex;
  69252. /**
  69253. * Intersects the sprites with a ray
  69254. * @param ray defines the ray to intersect with
  69255. * @param camera defines the current active camera
  69256. * @param predicate defines a predicate used to select candidate sprites
  69257. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  69258. * @returns null if no hit or a PickingInfo
  69259. */
  69260. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  69261. /**
  69262. * Render all child sprites
  69263. */
  69264. render(): void;
  69265. /**
  69266. * Release associated resources
  69267. */
  69268. dispose(): void;
  69269. }
  69270. }
  69271. declare module BABYLON {
  69272. /**
  69273. * Class used to represent a sprite
  69274. * @see http://doc.babylonjs.com/babylon101/sprites
  69275. */
  69276. export class Sprite {
  69277. /** defines the name */
  69278. name: string;
  69279. /** Gets or sets the current world position */
  69280. position: Vector3;
  69281. /** Gets or sets the main color */
  69282. color: Color4;
  69283. /** Gets or sets the width */
  69284. width: number;
  69285. /** Gets or sets the height */
  69286. height: number;
  69287. /** Gets or sets rotation angle */
  69288. angle: number;
  69289. /** Gets or sets the cell index in the sprite sheet */
  69290. cellIndex: number;
  69291. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  69292. invertU: number;
  69293. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  69294. invertV: number;
  69295. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  69296. disposeWhenFinishedAnimating: boolean;
  69297. /** Gets the list of attached animations */
  69298. animations: Animation[];
  69299. /** Gets or sets a boolean indicating if the sprite can be picked */
  69300. isPickable: boolean;
  69301. /**
  69302. * Gets or sets the associated action manager
  69303. */
  69304. actionManager: Nullable<ActionManager>;
  69305. private _animationStarted;
  69306. private _loopAnimation;
  69307. private _fromIndex;
  69308. private _toIndex;
  69309. private _delay;
  69310. private _direction;
  69311. private _manager;
  69312. private _time;
  69313. private _onAnimationEnd;
  69314. /**
  69315. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  69316. */
  69317. isVisible: boolean;
  69318. /**
  69319. * Gets or sets the sprite size
  69320. */
  69321. size: number;
  69322. /**
  69323. * Creates a new Sprite
  69324. * @param name defines the name
  69325. * @param manager defines the manager
  69326. */
  69327. constructor(
  69328. /** defines the name */
  69329. name: string, manager: ISpriteManager);
  69330. /**
  69331. * Starts an animation
  69332. * @param from defines the initial key
  69333. * @param to defines the end key
  69334. * @param loop defines if the animation must loop
  69335. * @param delay defines the start delay (in ms)
  69336. * @param onAnimationEnd defines a callback to call when animation ends
  69337. */
  69338. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  69339. /** Stops current animation (if any) */
  69340. stopAnimation(): void;
  69341. /** @hidden */
  69342. _animate(deltaTime: number): void;
  69343. /** Release associated resources */
  69344. dispose(): void;
  69345. }
  69346. }
  69347. declare module BABYLON {
  69348. /**
  69349. * Information about the result of picking within a scene
  69350. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  69351. */
  69352. export class PickingInfo {
  69353. /** @hidden */
  69354. _pickingUnavailable: boolean;
  69355. /**
  69356. * If the pick collided with an object
  69357. */
  69358. hit: boolean;
  69359. /**
  69360. * Distance away where the pick collided
  69361. */
  69362. distance: number;
  69363. /**
  69364. * The location of pick collision
  69365. */
  69366. pickedPoint: Nullable<Vector3>;
  69367. /**
  69368. * The mesh corresponding the the pick collision
  69369. */
  69370. pickedMesh: Nullable<AbstractMesh>;
  69371. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  69372. bu: number;
  69373. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  69374. bv: number;
  69375. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  69376. faceId: number;
  69377. /** Id of the the submesh that was picked */
  69378. subMeshId: number;
  69379. /** If a sprite was picked, this will be the sprite the pick collided with */
  69380. pickedSprite: Nullable<Sprite>;
  69381. /**
  69382. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  69383. */
  69384. originMesh: Nullable<AbstractMesh>;
  69385. /**
  69386. * The ray that was used to perform the picking.
  69387. */
  69388. ray: Nullable<Ray>;
  69389. /**
  69390. * Gets the normal correspodning to the face the pick collided with
  69391. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  69392. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  69393. * @returns The normal correspodning to the face the pick collided with
  69394. */
  69395. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  69396. /**
  69397. * Gets the texture coordinates of where the pick occured
  69398. * @returns the vector containing the coordnates of the texture
  69399. */
  69400. getTextureCoordinates(): Nullable<Vector2>;
  69401. }
  69402. }
  69403. declare module BABYLON {
  69404. /**
  69405. * Gather the list of pointer event types as constants.
  69406. */
  69407. export class PointerEventTypes {
  69408. /**
  69409. * 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.
  69410. */
  69411. static readonly POINTERDOWN: number;
  69412. /**
  69413. * The pointerup event is fired when a pointer is no longer active.
  69414. */
  69415. static readonly POINTERUP: number;
  69416. /**
  69417. * The pointermove event is fired when a pointer changes coordinates.
  69418. */
  69419. static readonly POINTERMOVE: number;
  69420. /**
  69421. * The pointerwheel event is fired when a mouse wheel has been rotated.
  69422. */
  69423. static readonly POINTERWHEEL: number;
  69424. /**
  69425. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  69426. */
  69427. static readonly POINTERPICK: number;
  69428. /**
  69429. * The pointertap event is fired when a the object has been touched and released without drag.
  69430. */
  69431. static readonly POINTERTAP: number;
  69432. /**
  69433. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  69434. */
  69435. static readonly POINTERDOUBLETAP: number;
  69436. }
  69437. /**
  69438. * Base class of pointer info types.
  69439. */
  69440. export class PointerInfoBase {
  69441. /**
  69442. * Defines the type of event (PointerEventTypes)
  69443. */
  69444. type: number;
  69445. /**
  69446. * Defines the related dom event
  69447. */
  69448. event: PointerEvent | MouseWheelEvent;
  69449. /**
  69450. * Instantiates the base class of pointers info.
  69451. * @param type Defines the type of event (PointerEventTypes)
  69452. * @param event Defines the related dom event
  69453. */
  69454. constructor(
  69455. /**
  69456. * Defines the type of event (PointerEventTypes)
  69457. */
  69458. type: number,
  69459. /**
  69460. * Defines the related dom event
  69461. */
  69462. event: PointerEvent | MouseWheelEvent);
  69463. }
  69464. /**
  69465. * This class is used to store pointer related info for the onPrePointerObservable event.
  69466. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  69467. */
  69468. export class PointerInfoPre extends PointerInfoBase {
  69469. /**
  69470. * Ray from a pointer if availible (eg. 6dof controller)
  69471. */
  69472. ray: Nullable<Ray>;
  69473. /**
  69474. * Defines the local position of the pointer on the canvas.
  69475. */
  69476. localPosition: Vector2;
  69477. /**
  69478. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  69479. */
  69480. skipOnPointerObservable: boolean;
  69481. /**
  69482. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  69483. * @param type Defines the type of event (PointerEventTypes)
  69484. * @param event Defines the related dom event
  69485. * @param localX Defines the local x coordinates of the pointer when the event occured
  69486. * @param localY Defines the local y coordinates of the pointer when the event occured
  69487. */
  69488. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  69489. }
  69490. /**
  69491. * This type contains all the data related to a pointer event in Babylon.js.
  69492. * 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.
  69493. */
  69494. export class PointerInfo extends PointerInfoBase {
  69495. /**
  69496. * Defines the picking info associated to the info (if any)\
  69497. */
  69498. pickInfo: Nullable<PickingInfo>;
  69499. /**
  69500. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  69501. * @param type Defines the type of event (PointerEventTypes)
  69502. * @param event Defines the related dom event
  69503. * @param pickInfo Defines the picking info associated to the info (if any)\
  69504. */
  69505. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  69506. /**
  69507. * Defines the picking info associated to the info (if any)\
  69508. */
  69509. pickInfo: Nullable<PickingInfo>);
  69510. }
  69511. /**
  69512. * Data relating to a touch event on the screen.
  69513. */
  69514. export interface PointerTouch {
  69515. /**
  69516. * X coordinate of touch.
  69517. */
  69518. x: number;
  69519. /**
  69520. * Y coordinate of touch.
  69521. */
  69522. y: number;
  69523. /**
  69524. * Id of touch. Unique for each finger.
  69525. */
  69526. pointerId: number;
  69527. /**
  69528. * Event type passed from DOM.
  69529. */
  69530. type: any;
  69531. }
  69532. }
  69533. declare module BABYLON {
  69534. /**
  69535. * Manage the mouse inputs to control the movement of a free camera.
  69536. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69537. */
  69538. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  69539. /**
  69540. * Define if touch is enabled in the mouse input
  69541. */
  69542. touchEnabled: boolean;
  69543. /**
  69544. * Defines the camera the input is attached to.
  69545. */
  69546. camera: FreeCamera;
  69547. /**
  69548. * Defines the buttons associated with the input to handle camera move.
  69549. */
  69550. buttons: number[];
  69551. /**
  69552. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  69553. */
  69554. angularSensibility: number;
  69555. private _pointerInput;
  69556. private _onMouseMove;
  69557. private _observer;
  69558. private previousPosition;
  69559. /**
  69560. * Manage the mouse inputs to control the movement of a free camera.
  69561. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69562. * @param touchEnabled Defines if touch is enabled or not
  69563. */
  69564. constructor(
  69565. /**
  69566. * Define if touch is enabled in the mouse input
  69567. */
  69568. touchEnabled?: boolean);
  69569. /**
  69570. * Attach the input controls to a specific dom element to get the input from.
  69571. * @param element Defines the element the controls should be listened from
  69572. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69573. */
  69574. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69575. /**
  69576. * Called on JS contextmenu event.
  69577. * Override this method to provide functionality.
  69578. */
  69579. protected onContextMenu(evt: PointerEvent): void;
  69580. /**
  69581. * Detach the current controls from the specified dom element.
  69582. * @param element Defines the element to stop listening the inputs from
  69583. */
  69584. detachControl(element: Nullable<HTMLElement>): void;
  69585. /**
  69586. * Gets the class name of the current intput.
  69587. * @returns the class name
  69588. */
  69589. getClassName(): string;
  69590. /**
  69591. * Get the friendly name associated with the input class.
  69592. * @returns the input friendly name
  69593. */
  69594. getSimpleName(): string;
  69595. }
  69596. }
  69597. declare module BABYLON {
  69598. /**
  69599. * Manage the touch inputs to control the movement of a free camera.
  69600. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69601. */
  69602. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  69603. /**
  69604. * Defines the camera the input is attached to.
  69605. */
  69606. camera: FreeCamera;
  69607. /**
  69608. * Defines the touch sensibility for rotation.
  69609. * The higher the faster.
  69610. */
  69611. touchAngularSensibility: number;
  69612. /**
  69613. * Defines the touch sensibility for move.
  69614. * The higher the faster.
  69615. */
  69616. touchMoveSensibility: number;
  69617. private _offsetX;
  69618. private _offsetY;
  69619. private _pointerPressed;
  69620. private _pointerInput;
  69621. private _observer;
  69622. private _onLostFocus;
  69623. /**
  69624. * Attach the input controls to a specific dom element to get the input from.
  69625. * @param element Defines the element the controls should be listened from
  69626. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69627. */
  69628. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69629. /**
  69630. * Detach the current controls from the specified dom element.
  69631. * @param element Defines the element to stop listening the inputs from
  69632. */
  69633. detachControl(element: Nullable<HTMLElement>): void;
  69634. /**
  69635. * Update the current camera state depending on the inputs that have been used this frame.
  69636. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  69637. */
  69638. checkInputs(): void;
  69639. /**
  69640. * Gets the class name of the current intput.
  69641. * @returns the class name
  69642. */
  69643. getClassName(): string;
  69644. /**
  69645. * Get the friendly name associated with the input class.
  69646. * @returns the input friendly name
  69647. */
  69648. getSimpleName(): string;
  69649. }
  69650. }
  69651. declare module BABYLON {
  69652. /**
  69653. * Default Inputs manager for the FreeCamera.
  69654. * It groups all the default supported inputs for ease of use.
  69655. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69656. */
  69657. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  69658. /**
  69659. * Instantiates a new FreeCameraInputsManager.
  69660. * @param camera Defines the camera the inputs belong to
  69661. */
  69662. constructor(camera: FreeCamera);
  69663. /**
  69664. * Add keyboard input support to the input manager.
  69665. * @returns the current input manager
  69666. */
  69667. addKeyboard(): FreeCameraInputsManager;
  69668. /**
  69669. * Add mouse input support to the input manager.
  69670. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  69671. * @returns the current input manager
  69672. */
  69673. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  69674. /**
  69675. * Add touch input support to the input manager.
  69676. * @returns the current input manager
  69677. */
  69678. addTouch(): FreeCameraInputsManager;
  69679. }
  69680. }
  69681. declare module BABYLON {
  69682. /**
  69683. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69684. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  69685. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69686. */
  69687. export class FreeCamera extends TargetCamera {
  69688. /**
  69689. * Define the collision ellipsoid of the camera.
  69690. * This is helpful to simulate a camera body like the player body around the camera
  69691. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  69692. */
  69693. ellipsoid: Vector3;
  69694. /**
  69695. * Define an offset for the position of the ellipsoid around the camera.
  69696. * This can be helpful to determine the center of the body near the gravity center of the body
  69697. * instead of its head.
  69698. */
  69699. ellipsoidOffset: Vector3;
  69700. /**
  69701. * Enable or disable collisions of the camera with the rest of the scene objects.
  69702. */
  69703. checkCollisions: boolean;
  69704. /**
  69705. * Enable or disable gravity on the camera.
  69706. */
  69707. applyGravity: boolean;
  69708. /**
  69709. * Define the input manager associated to the camera.
  69710. */
  69711. inputs: FreeCameraInputsManager;
  69712. /**
  69713. * Gets the input sensibility for a mouse input. (default is 2000.0)
  69714. * Higher values reduce sensitivity.
  69715. */
  69716. /**
  69717. * Sets the input sensibility for a mouse input. (default is 2000.0)
  69718. * Higher values reduce sensitivity.
  69719. */
  69720. angularSensibility: number;
  69721. /**
  69722. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  69723. */
  69724. keysUp: number[];
  69725. /**
  69726. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  69727. */
  69728. keysDown: number[];
  69729. /**
  69730. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  69731. */
  69732. keysLeft: number[];
  69733. /**
  69734. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  69735. */
  69736. keysRight: number[];
  69737. /**
  69738. * Event raised when the camera collide with a mesh in the scene.
  69739. */
  69740. onCollide: (collidedMesh: AbstractMesh) => void;
  69741. private _collider;
  69742. private _needMoveForGravity;
  69743. private _oldPosition;
  69744. private _diffPosition;
  69745. private _newPosition;
  69746. /** @hidden */
  69747. _localDirection: Vector3;
  69748. /** @hidden */
  69749. _transformedDirection: Vector3;
  69750. /**
  69751. * Instantiates a Free Camera.
  69752. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69753. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  69754. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69755. * @param name Define the name of the camera in the scene
  69756. * @param position Define the start position of the camera in the scene
  69757. * @param scene Define the scene the camera belongs to
  69758. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  69759. */
  69760. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  69761. /**
  69762. * Attached controls to the current camera.
  69763. * @param element Defines the element the controls should be listened from
  69764. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69765. */
  69766. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69767. /**
  69768. * Detach the current controls from the camera.
  69769. * The camera will stop reacting to inputs.
  69770. * @param element Defines the element to stop listening the inputs from
  69771. */
  69772. detachControl(element: HTMLElement): void;
  69773. private _collisionMask;
  69774. /**
  69775. * Define a collision mask to limit the list of object the camera can collide with
  69776. */
  69777. collisionMask: number;
  69778. /** @hidden */
  69779. _collideWithWorld(displacement: Vector3): void;
  69780. private _onCollisionPositionChange;
  69781. /** @hidden */
  69782. _checkInputs(): void;
  69783. /** @hidden */
  69784. _decideIfNeedsToMove(): boolean;
  69785. /** @hidden */
  69786. _updatePosition(): void;
  69787. /**
  69788. * Destroy the camera and release the current resources hold by it.
  69789. */
  69790. dispose(): void;
  69791. /**
  69792. * Gets the current object class name.
  69793. * @return the class name
  69794. */
  69795. getClassName(): string;
  69796. }
  69797. }
  69798. declare module BABYLON {
  69799. /**
  69800. * Represents a gamepad control stick position
  69801. */
  69802. export class StickValues {
  69803. /**
  69804. * The x component of the control stick
  69805. */
  69806. x: number;
  69807. /**
  69808. * The y component of the control stick
  69809. */
  69810. y: number;
  69811. /**
  69812. * Initializes the gamepad x and y control stick values
  69813. * @param x The x component of the gamepad control stick value
  69814. * @param y The y component of the gamepad control stick value
  69815. */
  69816. constructor(
  69817. /**
  69818. * The x component of the control stick
  69819. */
  69820. x: number,
  69821. /**
  69822. * The y component of the control stick
  69823. */
  69824. y: number);
  69825. }
  69826. /**
  69827. * An interface which manages callbacks for gamepad button changes
  69828. */
  69829. export interface GamepadButtonChanges {
  69830. /**
  69831. * Called when a gamepad has been changed
  69832. */
  69833. changed: boolean;
  69834. /**
  69835. * Called when a gamepad press event has been triggered
  69836. */
  69837. pressChanged: boolean;
  69838. /**
  69839. * Called when a touch event has been triggered
  69840. */
  69841. touchChanged: boolean;
  69842. /**
  69843. * Called when a value has changed
  69844. */
  69845. valueChanged: boolean;
  69846. }
  69847. /**
  69848. * Represents a gamepad
  69849. */
  69850. export class Gamepad {
  69851. /**
  69852. * The id of the gamepad
  69853. */
  69854. id: string;
  69855. /**
  69856. * The index of the gamepad
  69857. */
  69858. index: number;
  69859. /**
  69860. * The browser gamepad
  69861. */
  69862. browserGamepad: any;
  69863. /**
  69864. * Specifies what type of gamepad this represents
  69865. */
  69866. type: number;
  69867. private _leftStick;
  69868. private _rightStick;
  69869. /** @hidden */
  69870. _isConnected: boolean;
  69871. private _leftStickAxisX;
  69872. private _leftStickAxisY;
  69873. private _rightStickAxisX;
  69874. private _rightStickAxisY;
  69875. /**
  69876. * Triggered when the left control stick has been changed
  69877. */
  69878. private _onleftstickchanged;
  69879. /**
  69880. * Triggered when the right control stick has been changed
  69881. */
  69882. private _onrightstickchanged;
  69883. /**
  69884. * Represents a gamepad controller
  69885. */
  69886. static GAMEPAD: number;
  69887. /**
  69888. * Represents a generic controller
  69889. */
  69890. static GENERIC: number;
  69891. /**
  69892. * Represents an XBox controller
  69893. */
  69894. static XBOX: number;
  69895. /**
  69896. * Represents a pose-enabled controller
  69897. */
  69898. static POSE_ENABLED: number;
  69899. /**
  69900. * Specifies whether the left control stick should be Y-inverted
  69901. */
  69902. protected _invertLeftStickY: boolean;
  69903. /**
  69904. * Specifies if the gamepad has been connected
  69905. */
  69906. readonly isConnected: boolean;
  69907. /**
  69908. * Initializes the gamepad
  69909. * @param id The id of the gamepad
  69910. * @param index The index of the gamepad
  69911. * @param browserGamepad The browser gamepad
  69912. * @param leftStickX The x component of the left joystick
  69913. * @param leftStickY The y component of the left joystick
  69914. * @param rightStickX The x component of the right joystick
  69915. * @param rightStickY The y component of the right joystick
  69916. */
  69917. constructor(
  69918. /**
  69919. * The id of the gamepad
  69920. */
  69921. id: string,
  69922. /**
  69923. * The index of the gamepad
  69924. */
  69925. index: number,
  69926. /**
  69927. * The browser gamepad
  69928. */
  69929. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  69930. /**
  69931. * Callback triggered when the left joystick has changed
  69932. * @param callback
  69933. */
  69934. onleftstickchanged(callback: (values: StickValues) => void): void;
  69935. /**
  69936. * Callback triggered when the right joystick has changed
  69937. * @param callback
  69938. */
  69939. onrightstickchanged(callback: (values: StickValues) => void): void;
  69940. /**
  69941. * Gets the left joystick
  69942. */
  69943. /**
  69944. * Sets the left joystick values
  69945. */
  69946. leftStick: StickValues;
  69947. /**
  69948. * Gets the right joystick
  69949. */
  69950. /**
  69951. * Sets the right joystick value
  69952. */
  69953. rightStick: StickValues;
  69954. /**
  69955. * Updates the gamepad joystick positions
  69956. */
  69957. update(): void;
  69958. /**
  69959. * Disposes the gamepad
  69960. */
  69961. dispose(): void;
  69962. }
  69963. /**
  69964. * Represents a generic gamepad
  69965. */
  69966. export class GenericPad extends Gamepad {
  69967. private _buttons;
  69968. private _onbuttondown;
  69969. private _onbuttonup;
  69970. /**
  69971. * Observable triggered when a button has been pressed
  69972. */
  69973. onButtonDownObservable: Observable<number>;
  69974. /**
  69975. * Observable triggered when a button has been released
  69976. */
  69977. onButtonUpObservable: Observable<number>;
  69978. /**
  69979. * Callback triggered when a button has been pressed
  69980. * @param callback Called when a button has been pressed
  69981. */
  69982. onbuttondown(callback: (buttonPressed: number) => void): void;
  69983. /**
  69984. * Callback triggered when a button has been released
  69985. * @param callback Called when a button has been released
  69986. */
  69987. onbuttonup(callback: (buttonReleased: number) => void): void;
  69988. /**
  69989. * Initializes the generic gamepad
  69990. * @param id The id of the generic gamepad
  69991. * @param index The index of the generic gamepad
  69992. * @param browserGamepad The browser gamepad
  69993. */
  69994. constructor(id: string, index: number, browserGamepad: any);
  69995. private _setButtonValue;
  69996. /**
  69997. * Updates the generic gamepad
  69998. */
  69999. update(): void;
  70000. /**
  70001. * Disposes the generic gamepad
  70002. */
  70003. dispose(): void;
  70004. }
  70005. }
  70006. declare module BABYLON {
  70007. /**
  70008. * Defines the types of pose enabled controllers that are supported
  70009. */
  70010. export enum PoseEnabledControllerType {
  70011. /**
  70012. * HTC Vive
  70013. */
  70014. VIVE = 0,
  70015. /**
  70016. * Oculus Rift
  70017. */
  70018. OCULUS = 1,
  70019. /**
  70020. * Windows mixed reality
  70021. */
  70022. WINDOWS = 2,
  70023. /**
  70024. * Samsung gear VR
  70025. */
  70026. GEAR_VR = 3,
  70027. /**
  70028. * Google Daydream
  70029. */
  70030. DAYDREAM = 4,
  70031. /**
  70032. * Generic
  70033. */
  70034. GENERIC = 5
  70035. }
  70036. /**
  70037. * Defines the MutableGamepadButton interface for the state of a gamepad button
  70038. */
  70039. export interface MutableGamepadButton {
  70040. /**
  70041. * Value of the button/trigger
  70042. */
  70043. value: number;
  70044. /**
  70045. * If the button/trigger is currently touched
  70046. */
  70047. touched: boolean;
  70048. /**
  70049. * If the button/trigger is currently pressed
  70050. */
  70051. pressed: boolean;
  70052. }
  70053. /**
  70054. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  70055. * @hidden
  70056. */
  70057. export interface ExtendedGamepadButton extends GamepadButton {
  70058. /**
  70059. * If the button/trigger is currently pressed
  70060. */
  70061. readonly pressed: boolean;
  70062. /**
  70063. * If the button/trigger is currently touched
  70064. */
  70065. readonly touched: boolean;
  70066. /**
  70067. * Value of the button/trigger
  70068. */
  70069. readonly value: number;
  70070. }
  70071. /** @hidden */
  70072. export interface _GamePadFactory {
  70073. /**
  70074. * Returns wether or not the current gamepad can be created for this type of controller.
  70075. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  70076. * @returns true if it can be created, otherwise false
  70077. */
  70078. canCreate(gamepadInfo: any): boolean;
  70079. /**
  70080. * Creates a new instance of the Gamepad.
  70081. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  70082. * @returns the new gamepad instance
  70083. */
  70084. create(gamepadInfo: any): Gamepad;
  70085. }
  70086. /**
  70087. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  70088. */
  70089. export class PoseEnabledControllerHelper {
  70090. /** @hidden */
  70091. static _ControllerFactories: _GamePadFactory[];
  70092. /** @hidden */
  70093. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  70094. /**
  70095. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  70096. * @param vrGamepad the gamepad to initialized
  70097. * @returns a vr controller of the type the gamepad identified as
  70098. */
  70099. static InitiateController(vrGamepad: any): Gamepad;
  70100. }
  70101. /**
  70102. * Defines the PoseEnabledController object that contains state of a vr capable controller
  70103. */
  70104. export class PoseEnabledController extends Gamepad implements PoseControlled {
  70105. private _deviceRoomPosition;
  70106. private _deviceRoomRotationQuaternion;
  70107. /**
  70108. * The device position in babylon space
  70109. */
  70110. devicePosition: Vector3;
  70111. /**
  70112. * The device rotation in babylon space
  70113. */
  70114. deviceRotationQuaternion: Quaternion;
  70115. /**
  70116. * The scale factor of the device in babylon space
  70117. */
  70118. deviceScaleFactor: number;
  70119. /**
  70120. * (Likely devicePosition should be used instead) The device position in its room space
  70121. */
  70122. position: Vector3;
  70123. /**
  70124. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  70125. */
  70126. rotationQuaternion: Quaternion;
  70127. /**
  70128. * The type of controller (Eg. Windows mixed reality)
  70129. */
  70130. controllerType: PoseEnabledControllerType;
  70131. protected _calculatedPosition: Vector3;
  70132. private _calculatedRotation;
  70133. /**
  70134. * The raw pose from the device
  70135. */
  70136. rawPose: DevicePose;
  70137. private _trackPosition;
  70138. private _maxRotationDistFromHeadset;
  70139. private _draggedRoomRotation;
  70140. /**
  70141. * @hidden
  70142. */
  70143. _disableTrackPosition(fixedPosition: Vector3): void;
  70144. /**
  70145. * Internal, the mesh attached to the controller
  70146. * @hidden
  70147. */
  70148. _mesh: Nullable<AbstractMesh>;
  70149. private _poseControlledCamera;
  70150. private _leftHandSystemQuaternion;
  70151. /**
  70152. * Internal, matrix used to convert room space to babylon space
  70153. * @hidden
  70154. */
  70155. _deviceToWorld: Matrix;
  70156. /**
  70157. * Node to be used when casting a ray from the controller
  70158. * @hidden
  70159. */
  70160. _pointingPoseNode: Nullable<TransformNode>;
  70161. /**
  70162. * Name of the child mesh that can be used to cast a ray from the controller
  70163. */
  70164. static readonly POINTING_POSE: string;
  70165. /**
  70166. * Creates a new PoseEnabledController from a gamepad
  70167. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  70168. */
  70169. constructor(browserGamepad: any);
  70170. private _workingMatrix;
  70171. /**
  70172. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  70173. */
  70174. update(): void;
  70175. /**
  70176. * Updates only the pose device and mesh without doing any button event checking
  70177. */
  70178. protected _updatePoseAndMesh(): void;
  70179. /**
  70180. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  70181. * @param poseData raw pose fromthe device
  70182. */
  70183. updateFromDevice(poseData: DevicePose): void;
  70184. /**
  70185. * @hidden
  70186. */
  70187. _meshAttachedObservable: Observable<AbstractMesh>;
  70188. /**
  70189. * Attaches a mesh to the controller
  70190. * @param mesh the mesh to be attached
  70191. */
  70192. attachToMesh(mesh: AbstractMesh): void;
  70193. /**
  70194. * Attaches the controllers mesh to a camera
  70195. * @param camera the camera the mesh should be attached to
  70196. */
  70197. attachToPoseControlledCamera(camera: TargetCamera): void;
  70198. /**
  70199. * Disposes of the controller
  70200. */
  70201. dispose(): void;
  70202. /**
  70203. * The mesh that is attached to the controller
  70204. */
  70205. readonly mesh: Nullable<AbstractMesh>;
  70206. /**
  70207. * Gets the ray of the controller in the direction the controller is pointing
  70208. * @param length the length the resulting ray should be
  70209. * @returns a ray in the direction the controller is pointing
  70210. */
  70211. getForwardRay(length?: number): Ray;
  70212. }
  70213. }
  70214. declare module BABYLON {
  70215. /**
  70216. * Defines the WebVRController object that represents controllers tracked in 3D space
  70217. */
  70218. export abstract class WebVRController extends PoseEnabledController {
  70219. /**
  70220. * Internal, the default controller model for the controller
  70221. */
  70222. protected _defaultModel: AbstractMesh;
  70223. /**
  70224. * Fired when the trigger state has changed
  70225. */
  70226. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  70227. /**
  70228. * Fired when the main button state has changed
  70229. */
  70230. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  70231. /**
  70232. * Fired when the secondary button state has changed
  70233. */
  70234. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  70235. /**
  70236. * Fired when the pad state has changed
  70237. */
  70238. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  70239. /**
  70240. * Fired when controllers stick values have changed
  70241. */
  70242. onPadValuesChangedObservable: Observable<StickValues>;
  70243. /**
  70244. * Array of button availible on the controller
  70245. */
  70246. protected _buttons: Array<MutableGamepadButton>;
  70247. private _onButtonStateChange;
  70248. /**
  70249. * Fired when a controller button's state has changed
  70250. * @param callback the callback containing the button that was modified
  70251. */
  70252. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  70253. /**
  70254. * X and Y axis corrisponding to the controllers joystick
  70255. */
  70256. pad: StickValues;
  70257. /**
  70258. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  70259. */
  70260. hand: string;
  70261. /**
  70262. * The default controller model for the controller
  70263. */
  70264. readonly defaultModel: AbstractMesh;
  70265. /**
  70266. * Creates a new WebVRController from a gamepad
  70267. * @param vrGamepad the gamepad that the WebVRController should be created from
  70268. */
  70269. constructor(vrGamepad: any);
  70270. /**
  70271. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  70272. */
  70273. update(): void;
  70274. /**
  70275. * Function to be called when a button is modified
  70276. */
  70277. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  70278. /**
  70279. * Loads a mesh and attaches it to the controller
  70280. * @param scene the scene the mesh should be added to
  70281. * @param meshLoaded callback for when the mesh has been loaded
  70282. */
  70283. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  70284. private _setButtonValue;
  70285. private _changes;
  70286. private _checkChanges;
  70287. /**
  70288. * Disposes of th webVRCOntroller
  70289. */
  70290. dispose(): void;
  70291. }
  70292. }
  70293. declare module BABYLON {
  70294. /**
  70295. * The HemisphericLight simulates the ambient environment light,
  70296. * so the passed direction is the light reflection direction, not the incoming direction.
  70297. */
  70298. export class HemisphericLight extends Light {
  70299. /**
  70300. * The groundColor is the light in the opposite direction to the one specified during creation.
  70301. * 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.
  70302. */
  70303. groundColor: Color3;
  70304. /**
  70305. * The light reflection direction, not the incoming direction.
  70306. */
  70307. direction: Vector3;
  70308. /**
  70309. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  70310. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  70311. * The HemisphericLight can't cast shadows.
  70312. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70313. * @param name The friendly name of the light
  70314. * @param direction The direction of the light reflection
  70315. * @param scene The scene the light belongs to
  70316. */
  70317. constructor(name: string, direction: Vector3, scene: Scene);
  70318. protected _buildUniformLayout(): void;
  70319. /**
  70320. * Returns the string "HemisphericLight".
  70321. * @return The class name
  70322. */
  70323. getClassName(): string;
  70324. /**
  70325. * Sets the HemisphericLight direction towards the passed target (Vector3).
  70326. * Returns the updated direction.
  70327. * @param target The target the direction should point to
  70328. * @return The computed direction
  70329. */
  70330. setDirectionToTarget(target: Vector3): Vector3;
  70331. /**
  70332. * Returns the shadow generator associated to the light.
  70333. * @returns Always null for hemispheric lights because it does not support shadows.
  70334. */
  70335. getShadowGenerator(): Nullable<IShadowGenerator>;
  70336. /**
  70337. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  70338. * @param effect The effect to update
  70339. * @param lightIndex The index of the light in the effect to update
  70340. * @returns The hemispheric light
  70341. */
  70342. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  70343. /**
  70344. * Computes the world matrix of the node
  70345. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  70346. * @param useWasUpdatedFlag defines a reserved property
  70347. * @returns the world matrix
  70348. */
  70349. computeWorldMatrix(): Matrix;
  70350. /**
  70351. * Returns the integer 3.
  70352. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70353. */
  70354. getTypeID(): number;
  70355. /**
  70356. * Prepares the list of defines specific to the light type.
  70357. * @param defines the list of defines
  70358. * @param lightIndex defines the index of the light for the effect
  70359. */
  70360. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70361. }
  70362. }
  70363. declare module BABYLON {
  70364. /**
  70365. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  70366. * IMPORTANT!! The data is right-hand data.
  70367. * @export
  70368. * @interface DevicePose
  70369. */
  70370. export interface DevicePose {
  70371. /**
  70372. * The position of the device, values in array are [x,y,z].
  70373. */
  70374. readonly position: Nullable<Float32Array>;
  70375. /**
  70376. * The linearVelocity of the device, values in array are [x,y,z].
  70377. */
  70378. readonly linearVelocity: Nullable<Float32Array>;
  70379. /**
  70380. * The linearAcceleration of the device, values in array are [x,y,z].
  70381. */
  70382. readonly linearAcceleration: Nullable<Float32Array>;
  70383. /**
  70384. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  70385. */
  70386. readonly orientation: Nullable<Float32Array>;
  70387. /**
  70388. * The angularVelocity of the device, values in array are [x,y,z].
  70389. */
  70390. readonly angularVelocity: Nullable<Float32Array>;
  70391. /**
  70392. * The angularAcceleration of the device, values in array are [x,y,z].
  70393. */
  70394. readonly angularAcceleration: Nullable<Float32Array>;
  70395. }
  70396. /**
  70397. * Interface representing a pose controlled object in Babylon.
  70398. * A pose controlled object has both regular pose values as well as pose values
  70399. * from an external device such as a VR head mounted display
  70400. */
  70401. export interface PoseControlled {
  70402. /**
  70403. * The position of the object in babylon space.
  70404. */
  70405. position: Vector3;
  70406. /**
  70407. * The rotation quaternion of the object in babylon space.
  70408. */
  70409. rotationQuaternion: Quaternion;
  70410. /**
  70411. * The position of the device in babylon space.
  70412. */
  70413. devicePosition?: Vector3;
  70414. /**
  70415. * The rotation quaternion of the device in babylon space.
  70416. */
  70417. deviceRotationQuaternion: Quaternion;
  70418. /**
  70419. * The raw pose coming from the device.
  70420. */
  70421. rawPose: Nullable<DevicePose>;
  70422. /**
  70423. * The scale of the device to be used when translating from device space to babylon space.
  70424. */
  70425. deviceScaleFactor: number;
  70426. /**
  70427. * Updates the poseControlled values based on the input device pose.
  70428. * @param poseData the pose data to update the object with
  70429. */
  70430. updateFromDevice(poseData: DevicePose): void;
  70431. }
  70432. /**
  70433. * Set of options to customize the webVRCamera
  70434. */
  70435. export interface WebVROptions {
  70436. /**
  70437. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  70438. */
  70439. trackPosition?: boolean;
  70440. /**
  70441. * Sets the scale of the vrDevice in babylon space. (default: 1)
  70442. */
  70443. positionScale?: number;
  70444. /**
  70445. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  70446. */
  70447. displayName?: string;
  70448. /**
  70449. * Should the native controller meshes be initialized. (default: true)
  70450. */
  70451. controllerMeshes?: boolean;
  70452. /**
  70453. * Creating a default HemiLight only on controllers. (default: true)
  70454. */
  70455. defaultLightingOnControllers?: boolean;
  70456. /**
  70457. * If you don't want to use the default VR button of the helper. (default: false)
  70458. */
  70459. useCustomVRButton?: boolean;
  70460. /**
  70461. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  70462. */
  70463. customVRButton?: HTMLButtonElement;
  70464. /**
  70465. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  70466. */
  70467. rayLength?: number;
  70468. /**
  70469. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  70470. */
  70471. defaultHeight?: number;
  70472. }
  70473. /**
  70474. * This represents a WebVR camera.
  70475. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  70476. * @example http://doc.babylonjs.com/how_to/webvr_camera
  70477. */
  70478. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  70479. private webVROptions;
  70480. /**
  70481. * @hidden
  70482. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  70483. */
  70484. _vrDevice: any;
  70485. /**
  70486. * The rawPose of the vrDevice.
  70487. */
  70488. rawPose: Nullable<DevicePose>;
  70489. private _onVREnabled;
  70490. private _specsVersion;
  70491. private _attached;
  70492. private _frameData;
  70493. protected _descendants: Array<Node>;
  70494. private _deviceRoomPosition;
  70495. /** @hidden */
  70496. _deviceRoomRotationQuaternion: Quaternion;
  70497. private _standingMatrix;
  70498. /**
  70499. * Represents device position in babylon space.
  70500. */
  70501. devicePosition: Vector3;
  70502. /**
  70503. * Represents device rotation in babylon space.
  70504. */
  70505. deviceRotationQuaternion: Quaternion;
  70506. /**
  70507. * The scale of the device to be used when translating from device space to babylon space.
  70508. */
  70509. deviceScaleFactor: number;
  70510. private _deviceToWorld;
  70511. private _worldToDevice;
  70512. /**
  70513. * References to the webVR controllers for the vrDevice.
  70514. */
  70515. controllers: Array<WebVRController>;
  70516. /**
  70517. * Emits an event when a controller is attached.
  70518. */
  70519. onControllersAttachedObservable: Observable<WebVRController[]>;
  70520. /**
  70521. * Emits an event when a controller's mesh has been loaded;
  70522. */
  70523. onControllerMeshLoadedObservable: Observable<WebVRController>;
  70524. /**
  70525. * Emits an event when the HMD's pose has been updated.
  70526. */
  70527. onPoseUpdatedFromDeviceObservable: Observable<any>;
  70528. private _poseSet;
  70529. /**
  70530. * If the rig cameras be used as parent instead of this camera.
  70531. */
  70532. rigParenting: boolean;
  70533. private _lightOnControllers;
  70534. private _defaultHeight?;
  70535. /**
  70536. * Instantiates a WebVRFreeCamera.
  70537. * @param name The name of the WebVRFreeCamera
  70538. * @param position The starting anchor position for the camera
  70539. * @param scene The scene the camera belongs to
  70540. * @param webVROptions a set of customizable options for the webVRCamera
  70541. */
  70542. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  70543. /**
  70544. * Gets the device distance from the ground in meters.
  70545. * @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.
  70546. */
  70547. deviceDistanceToRoomGround(): number;
  70548. /**
  70549. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70550. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  70551. */
  70552. useStandingMatrix(callback?: (bool: boolean) => void): void;
  70553. /**
  70554. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70555. * @returns A promise with a boolean set to if the standing matrix is supported.
  70556. */
  70557. useStandingMatrixAsync(): Promise<boolean>;
  70558. /**
  70559. * Disposes the camera
  70560. */
  70561. dispose(): void;
  70562. /**
  70563. * Gets a vrController by name.
  70564. * @param name The name of the controller to retreive
  70565. * @returns the controller matching the name specified or null if not found
  70566. */
  70567. getControllerByName(name: string): Nullable<WebVRController>;
  70568. private _leftController;
  70569. /**
  70570. * The controller corrisponding to the users left hand.
  70571. */
  70572. readonly leftController: Nullable<WebVRController>;
  70573. private _rightController;
  70574. /**
  70575. * The controller corrisponding to the users right hand.
  70576. */
  70577. readonly rightController: Nullable<WebVRController>;
  70578. /**
  70579. * Casts a ray forward from the vrCamera's gaze.
  70580. * @param length Length of the ray (default: 100)
  70581. * @returns the ray corrisponding to the gaze
  70582. */
  70583. getForwardRay(length?: number): Ray;
  70584. /**
  70585. * @hidden
  70586. * Updates the camera based on device's frame data
  70587. */
  70588. _checkInputs(): void;
  70589. /**
  70590. * Updates the poseControlled values based on the input device pose.
  70591. * @param poseData Pose coming from the device
  70592. */
  70593. updateFromDevice(poseData: DevicePose): void;
  70594. private _htmlElementAttached;
  70595. private _detachIfAttached;
  70596. /**
  70597. * WebVR's attach control will start broadcasting frames to the device.
  70598. * Note that in certain browsers (chrome for example) this function must be called
  70599. * within a user-interaction callback. Example:
  70600. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  70601. *
  70602. * @param element html element to attach the vrDevice to
  70603. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  70604. */
  70605. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70606. /**
  70607. * Detaches the camera from the html element and disables VR
  70608. *
  70609. * @param element html element to detach from
  70610. */
  70611. detachControl(element: HTMLElement): void;
  70612. /**
  70613. * @returns the name of this class
  70614. */
  70615. getClassName(): string;
  70616. /**
  70617. * Calls resetPose on the vrDisplay
  70618. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  70619. */
  70620. resetToCurrentRotation(): void;
  70621. /**
  70622. * @hidden
  70623. * Updates the rig cameras (left and right eye)
  70624. */
  70625. _updateRigCameras(): void;
  70626. private _workingVector;
  70627. private _oneVector;
  70628. private _workingMatrix;
  70629. private updateCacheCalled;
  70630. private _correctPositionIfNotTrackPosition;
  70631. /**
  70632. * @hidden
  70633. * Updates the cached values of the camera
  70634. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  70635. */
  70636. _updateCache(ignoreParentClass?: boolean): void;
  70637. /**
  70638. * @hidden
  70639. * Get current device position in babylon world
  70640. */
  70641. _computeDevicePosition(): void;
  70642. /**
  70643. * Updates the current device position and rotation in the babylon world
  70644. */
  70645. update(): void;
  70646. /**
  70647. * @hidden
  70648. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  70649. * @returns an identity matrix
  70650. */
  70651. _getViewMatrix(): Matrix;
  70652. private _tmpMatrix;
  70653. /**
  70654. * This function is called by the two RIG cameras.
  70655. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  70656. * @hidden
  70657. */
  70658. _getWebVRViewMatrix(): Matrix;
  70659. /** @hidden */
  70660. _getWebVRProjectionMatrix(): Matrix;
  70661. private _onGamepadConnectedObserver;
  70662. private _onGamepadDisconnectedObserver;
  70663. private _updateCacheWhenTrackingDisabledObserver;
  70664. /**
  70665. * Initializes the controllers and their meshes
  70666. */
  70667. initControllers(): void;
  70668. }
  70669. }
  70670. declare module BABYLON {
  70671. /**
  70672. * Size options for a post process
  70673. */
  70674. export type PostProcessOptions = {
  70675. width: number;
  70676. height: number;
  70677. };
  70678. /**
  70679. * PostProcess can be used to apply a shader to a texture after it has been rendered
  70680. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70681. */
  70682. export class PostProcess {
  70683. /** Name of the PostProcess. */
  70684. name: string;
  70685. /**
  70686. * Gets or sets the unique id of the post process
  70687. */
  70688. uniqueId: number;
  70689. /**
  70690. * Width of the texture to apply the post process on
  70691. */
  70692. width: number;
  70693. /**
  70694. * Height of the texture to apply the post process on
  70695. */
  70696. height: number;
  70697. /**
  70698. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  70699. * @hidden
  70700. */
  70701. _outputTexture: Nullable<InternalTexture>;
  70702. /**
  70703. * Sampling mode used by the shader
  70704. * See https://doc.babylonjs.com/classes/3.1/texture
  70705. */
  70706. renderTargetSamplingMode: number;
  70707. /**
  70708. * Clear color to use when screen clearing
  70709. */
  70710. clearColor: Color4;
  70711. /**
  70712. * If the buffer needs to be cleared before applying the post process. (default: true)
  70713. * Should be set to false if shader will overwrite all previous pixels.
  70714. */
  70715. autoClear: boolean;
  70716. /**
  70717. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  70718. */
  70719. alphaMode: number;
  70720. /**
  70721. * Sets the setAlphaBlendConstants of the babylon engine
  70722. */
  70723. alphaConstants: Color4;
  70724. /**
  70725. * Animations to be used for the post processing
  70726. */
  70727. animations: Animation[];
  70728. /**
  70729. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  70730. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  70731. */
  70732. enablePixelPerfectMode: boolean;
  70733. /**
  70734. * Force the postprocess to be applied without taking in account viewport
  70735. */
  70736. forceFullscreenViewport: boolean;
  70737. /**
  70738. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  70739. *
  70740. * | Value | Type | Description |
  70741. * | ----- | ----------------------------------- | ----------- |
  70742. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  70743. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  70744. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  70745. *
  70746. */
  70747. scaleMode: number;
  70748. /**
  70749. * Force textures to be a power of two (default: false)
  70750. */
  70751. alwaysForcePOT: boolean;
  70752. private _samples;
  70753. /**
  70754. * Number of sample textures (default: 1)
  70755. */
  70756. samples: number;
  70757. /**
  70758. * Modify the scale of the post process to be the same as the viewport (default: false)
  70759. */
  70760. adaptScaleToCurrentViewport: boolean;
  70761. private _camera;
  70762. private _scene;
  70763. private _engine;
  70764. private _options;
  70765. private _reusable;
  70766. private _textureType;
  70767. /**
  70768. * Smart array of input and output textures for the post process.
  70769. * @hidden
  70770. */
  70771. _textures: SmartArray<InternalTexture>;
  70772. /**
  70773. * The index in _textures that corresponds to the output texture.
  70774. * @hidden
  70775. */
  70776. _currentRenderTextureInd: number;
  70777. private _effect;
  70778. private _samplers;
  70779. private _fragmentUrl;
  70780. private _vertexUrl;
  70781. private _parameters;
  70782. private _scaleRatio;
  70783. protected _indexParameters: any;
  70784. private _shareOutputWithPostProcess;
  70785. private _texelSize;
  70786. private _forcedOutputTexture;
  70787. /**
  70788. * Returns the fragment url or shader name used in the post process.
  70789. * @returns the fragment url or name in the shader store.
  70790. */
  70791. getEffectName(): string;
  70792. /**
  70793. * An event triggered when the postprocess is activated.
  70794. */
  70795. onActivateObservable: Observable<Camera>;
  70796. private _onActivateObserver;
  70797. /**
  70798. * A function that is added to the onActivateObservable
  70799. */
  70800. onActivate: Nullable<(camera: Camera) => void>;
  70801. /**
  70802. * An event triggered when the postprocess changes its size.
  70803. */
  70804. onSizeChangedObservable: Observable<PostProcess>;
  70805. private _onSizeChangedObserver;
  70806. /**
  70807. * A function that is added to the onSizeChangedObservable
  70808. */
  70809. onSizeChanged: (postProcess: PostProcess) => void;
  70810. /**
  70811. * An event triggered when the postprocess applies its effect.
  70812. */
  70813. onApplyObservable: Observable<Effect>;
  70814. private _onApplyObserver;
  70815. /**
  70816. * A function that is added to the onApplyObservable
  70817. */
  70818. onApply: (effect: Effect) => void;
  70819. /**
  70820. * An event triggered before rendering the postprocess
  70821. */
  70822. onBeforeRenderObservable: Observable<Effect>;
  70823. private _onBeforeRenderObserver;
  70824. /**
  70825. * A function that is added to the onBeforeRenderObservable
  70826. */
  70827. onBeforeRender: (effect: Effect) => void;
  70828. /**
  70829. * An event triggered after rendering the postprocess
  70830. */
  70831. onAfterRenderObservable: Observable<Effect>;
  70832. private _onAfterRenderObserver;
  70833. /**
  70834. * A function that is added to the onAfterRenderObservable
  70835. */
  70836. onAfterRender: (efect: Effect) => void;
  70837. /**
  70838. * 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
  70839. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  70840. */
  70841. inputTexture: InternalTexture;
  70842. /**
  70843. * Gets the camera which post process is applied to.
  70844. * @returns The camera the post process is applied to.
  70845. */
  70846. getCamera(): Camera;
  70847. /**
  70848. * Gets the texel size of the postprocess.
  70849. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  70850. */
  70851. readonly texelSize: Vector2;
  70852. /**
  70853. * Creates a new instance PostProcess
  70854. * @param name The name of the PostProcess.
  70855. * @param fragmentUrl The url of the fragment shader to be used.
  70856. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  70857. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  70858. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  70859. * @param camera The camera to apply the render pass to.
  70860. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70861. * @param engine The engine which the post process will be applied. (default: current engine)
  70862. * @param reusable If the post process can be reused on the same frame. (default: false)
  70863. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  70864. * @param textureType Type of textures used when performing the post process. (default: 0)
  70865. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  70866. * @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
  70867. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  70868. */
  70869. constructor(
  70870. /** Name of the PostProcess. */
  70871. 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);
  70872. /**
  70873. * Gets a string idenfifying the name of the class
  70874. * @returns "PostProcess" string
  70875. */
  70876. getClassName(): string;
  70877. /**
  70878. * Gets the engine which this post process belongs to.
  70879. * @returns The engine the post process was enabled with.
  70880. */
  70881. getEngine(): Engine;
  70882. /**
  70883. * The effect that is created when initializing the post process.
  70884. * @returns The created effect corrisponding the the postprocess.
  70885. */
  70886. getEffect(): Effect;
  70887. /**
  70888. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  70889. * @param postProcess The post process to share the output with.
  70890. * @returns This post process.
  70891. */
  70892. shareOutputWith(postProcess: PostProcess): PostProcess;
  70893. /**
  70894. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  70895. * This should be called if the post process that shares output with this post process is disabled/disposed.
  70896. */
  70897. useOwnOutput(): void;
  70898. /**
  70899. * Updates the effect with the current post process compile time values and recompiles the shader.
  70900. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70901. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70902. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70903. * @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
  70904. * @param onCompiled Called when the shader has been compiled.
  70905. * @param onError Called if there is an error when compiling a shader.
  70906. */
  70907. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70908. /**
  70909. * The post process is reusable if it can be used multiple times within one frame.
  70910. * @returns If the post process is reusable
  70911. */
  70912. isReusable(): boolean;
  70913. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  70914. markTextureDirty(): void;
  70915. /**
  70916. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  70917. * 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.
  70918. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  70919. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  70920. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  70921. * @returns The target texture that was bound to be written to.
  70922. */
  70923. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  70924. /**
  70925. * If the post process is supported.
  70926. */
  70927. readonly isSupported: boolean;
  70928. /**
  70929. * The aspect ratio of the output texture.
  70930. */
  70931. readonly aspectRatio: number;
  70932. /**
  70933. * Get a value indicating if the post-process is ready to be used
  70934. * @returns true if the post-process is ready (shader is compiled)
  70935. */
  70936. isReady(): boolean;
  70937. /**
  70938. * Binds all textures and uniforms to the shader, this will be run on every pass.
  70939. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  70940. */
  70941. apply(): Nullable<Effect>;
  70942. private _disposeTextures;
  70943. /**
  70944. * Disposes the post process.
  70945. * @param camera The camera to dispose the post process on.
  70946. */
  70947. dispose(camera?: Camera): void;
  70948. }
  70949. }
  70950. declare module BABYLON {
  70951. /**
  70952. * PostProcessManager is used to manage one or more post processes or post process pipelines
  70953. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70954. */
  70955. export class PostProcessManager {
  70956. private _scene;
  70957. private _indexBuffer;
  70958. private _vertexBuffers;
  70959. /**
  70960. * Creates a new instance PostProcess
  70961. * @param scene The scene that the post process is associated with.
  70962. */
  70963. constructor(scene: Scene);
  70964. private _prepareBuffers;
  70965. private _buildIndexBuffer;
  70966. /**
  70967. * Rebuilds the vertex buffers of the manager.
  70968. * @hidden
  70969. */
  70970. _rebuild(): void;
  70971. /**
  70972. * Prepares a frame to be run through a post process.
  70973. * @param sourceTexture The input texture to the post procesess. (default: null)
  70974. * @param postProcesses An array of post processes to be run. (default: null)
  70975. * @returns True if the post processes were able to be run.
  70976. * @hidden
  70977. */
  70978. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  70979. /**
  70980. * Manually render a set of post processes to a texture.
  70981. * @param postProcesses An array of post processes to be run.
  70982. * @param targetTexture The target texture to render to.
  70983. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  70984. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  70985. * @param lodLevel defines which lod of the texture to render to
  70986. */
  70987. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  70988. /**
  70989. * Finalize the result of the output of the postprocesses.
  70990. * @param doNotPresent If true the result will not be displayed to the screen.
  70991. * @param targetTexture The target texture to render to.
  70992. * @param faceIndex The index of the face to bind the target texture to.
  70993. * @param postProcesses The array of post processes to render.
  70994. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  70995. * @hidden
  70996. */
  70997. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  70998. /**
  70999. * Disposes of the post process manager.
  71000. */
  71001. dispose(): void;
  71002. }
  71003. }
  71004. declare module BABYLON {
  71005. interface AbstractScene {
  71006. /**
  71007. * The list of layers (background and foreground) of the scene
  71008. */
  71009. layers: Array<Layer>;
  71010. }
  71011. /**
  71012. * Defines the layer scene component responsible to manage any layers
  71013. * in a given scene.
  71014. */
  71015. export class LayerSceneComponent implements ISceneComponent {
  71016. /**
  71017. * The component name helpfull to identify the component in the list of scene components.
  71018. */
  71019. readonly name: string;
  71020. /**
  71021. * The scene the component belongs to.
  71022. */
  71023. scene: Scene;
  71024. private _engine;
  71025. /**
  71026. * Creates a new instance of the component for the given scene
  71027. * @param scene Defines the scene to register the component in
  71028. */
  71029. constructor(scene: Scene);
  71030. /**
  71031. * Registers the component in a given scene
  71032. */
  71033. register(): void;
  71034. /**
  71035. * Rebuilds the elements related to this component in case of
  71036. * context lost for instance.
  71037. */
  71038. rebuild(): void;
  71039. /**
  71040. * Disposes the component and the associated ressources.
  71041. */
  71042. dispose(): void;
  71043. private _draw;
  71044. private _drawCameraPredicate;
  71045. private _drawCameraBackground;
  71046. private _drawCameraForeground;
  71047. private _drawRenderTargetPredicate;
  71048. private _drawRenderTargetBackground;
  71049. private _drawRenderTargetForeground;
  71050. }
  71051. }
  71052. declare module BABYLON {
  71053. /** @hidden */
  71054. export var layerPixelShader: {
  71055. name: string;
  71056. shader: string;
  71057. };
  71058. }
  71059. declare module BABYLON {
  71060. /** @hidden */
  71061. export var layerVertexShader: {
  71062. name: string;
  71063. shader: string;
  71064. };
  71065. }
  71066. declare module BABYLON {
  71067. /**
  71068. * This represents a full screen 2d layer.
  71069. * This can be useful to display a picture in the background of your scene for instance.
  71070. * @see https://www.babylonjs-playground.com/#08A2BS#1
  71071. */
  71072. export class Layer {
  71073. /**
  71074. * Define the name of the layer.
  71075. */
  71076. name: string;
  71077. /**
  71078. * Define the texture the layer should display.
  71079. */
  71080. texture: Nullable<Texture>;
  71081. /**
  71082. * Is the layer in background or foreground.
  71083. */
  71084. isBackground: boolean;
  71085. /**
  71086. * Define the color of the layer (instead of texture).
  71087. */
  71088. color: Color4;
  71089. /**
  71090. * Define the scale of the layer in order to zoom in out of the texture.
  71091. */
  71092. scale: Vector2;
  71093. /**
  71094. * Define an offset for the layer in order to shift the texture.
  71095. */
  71096. offset: Vector2;
  71097. /**
  71098. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  71099. */
  71100. alphaBlendingMode: number;
  71101. /**
  71102. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  71103. * Alpha test will not mix with the background color in case of transparency.
  71104. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  71105. */
  71106. alphaTest: boolean;
  71107. /**
  71108. * Define a mask to restrict the layer to only some of the scene cameras.
  71109. */
  71110. layerMask: number;
  71111. /**
  71112. * Define the list of render target the layer is visible into.
  71113. */
  71114. renderTargetTextures: RenderTargetTexture[];
  71115. /**
  71116. * Define if the layer is only used in renderTarget or if it also
  71117. * renders in the main frame buffer of the canvas.
  71118. */
  71119. renderOnlyInRenderTargetTextures: boolean;
  71120. private _scene;
  71121. private _vertexBuffers;
  71122. private _indexBuffer;
  71123. private _effect;
  71124. private _alphaTestEffect;
  71125. /**
  71126. * An event triggered when the layer is disposed.
  71127. */
  71128. onDisposeObservable: Observable<Layer>;
  71129. private _onDisposeObserver;
  71130. /**
  71131. * Back compatibility with callback before the onDisposeObservable existed.
  71132. * The set callback will be triggered when the layer has been disposed.
  71133. */
  71134. onDispose: () => void;
  71135. /**
  71136. * An event triggered before rendering the scene
  71137. */
  71138. onBeforeRenderObservable: Observable<Layer>;
  71139. private _onBeforeRenderObserver;
  71140. /**
  71141. * Back compatibility with callback before the onBeforeRenderObservable existed.
  71142. * The set callback will be triggered just before rendering the layer.
  71143. */
  71144. onBeforeRender: () => void;
  71145. /**
  71146. * An event triggered after rendering the scene
  71147. */
  71148. onAfterRenderObservable: Observable<Layer>;
  71149. private _onAfterRenderObserver;
  71150. /**
  71151. * Back compatibility with callback before the onAfterRenderObservable existed.
  71152. * The set callback will be triggered just after rendering the layer.
  71153. */
  71154. onAfterRender: () => void;
  71155. /**
  71156. * Instantiates a new layer.
  71157. * This represents a full screen 2d layer.
  71158. * This can be useful to display a picture in the background of your scene for instance.
  71159. * @see https://www.babylonjs-playground.com/#08A2BS#1
  71160. * @param name Define the name of the layer in the scene
  71161. * @param imgUrl Define the url of the texture to display in the layer
  71162. * @param scene Define the scene the layer belongs to
  71163. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  71164. * @param color Defines a color for the layer
  71165. */
  71166. constructor(
  71167. /**
  71168. * Define the name of the layer.
  71169. */
  71170. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  71171. private _createIndexBuffer;
  71172. /** @hidden */
  71173. _rebuild(): void;
  71174. /**
  71175. * Renders the layer in the scene.
  71176. */
  71177. render(): void;
  71178. /**
  71179. * Disposes and releases the associated ressources.
  71180. */
  71181. dispose(): void;
  71182. }
  71183. }
  71184. declare module BABYLON {
  71185. interface AbstractScene {
  71186. /**
  71187. * The list of procedural textures added to the scene
  71188. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71189. */
  71190. proceduralTextures: Array<ProceduralTexture>;
  71191. }
  71192. /**
  71193. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  71194. * in a given scene.
  71195. */
  71196. export class ProceduralTextureSceneComponent implements ISceneComponent {
  71197. /**
  71198. * The component name helpfull to identify the component in the list of scene components.
  71199. */
  71200. readonly name: string;
  71201. /**
  71202. * The scene the component belongs to.
  71203. */
  71204. scene: Scene;
  71205. /**
  71206. * Creates a new instance of the component for the given scene
  71207. * @param scene Defines the scene to register the component in
  71208. */
  71209. constructor(scene: Scene);
  71210. /**
  71211. * Registers the component in a given scene
  71212. */
  71213. register(): void;
  71214. /**
  71215. * Rebuilds the elements related to this component in case of
  71216. * context lost for instance.
  71217. */
  71218. rebuild(): void;
  71219. /**
  71220. * Disposes the component and the associated ressources.
  71221. */
  71222. dispose(): void;
  71223. private _beforeClear;
  71224. }
  71225. }
  71226. declare module BABYLON {
  71227. /** @hidden */
  71228. export var proceduralVertexShader: {
  71229. name: string;
  71230. shader: string;
  71231. };
  71232. }
  71233. declare module BABYLON {
  71234. /**
  71235. * 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.
  71236. * This is the base class of any Procedural texture and contains most of the shareable code.
  71237. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71238. */
  71239. export class ProceduralTexture extends Texture {
  71240. isCube: boolean;
  71241. /**
  71242. * Define if the texture is enabled or not (disabled texture will not render)
  71243. */
  71244. isEnabled: boolean;
  71245. /**
  71246. * Define if the texture must be cleared before rendering (default is true)
  71247. */
  71248. autoClear: boolean;
  71249. /**
  71250. * Callback called when the texture is generated
  71251. */
  71252. onGenerated: () => void;
  71253. /**
  71254. * Event raised when the texture is generated
  71255. */
  71256. onGeneratedObservable: Observable<ProceduralTexture>;
  71257. /** @hidden */
  71258. _generateMipMaps: boolean;
  71259. /** @hidden **/
  71260. _effect: Effect;
  71261. /** @hidden */
  71262. _textures: {
  71263. [key: string]: Texture;
  71264. };
  71265. private _size;
  71266. private _currentRefreshId;
  71267. private _refreshRate;
  71268. private _vertexBuffers;
  71269. private _indexBuffer;
  71270. private _uniforms;
  71271. private _samplers;
  71272. private _fragment;
  71273. private _floats;
  71274. private _ints;
  71275. private _floatsArrays;
  71276. private _colors3;
  71277. private _colors4;
  71278. private _vectors2;
  71279. private _vectors3;
  71280. private _matrices;
  71281. private _fallbackTexture;
  71282. private _fallbackTextureUsed;
  71283. private _engine;
  71284. private _cachedDefines;
  71285. private _contentUpdateId;
  71286. private _contentData;
  71287. /**
  71288. * Instantiates a new procedural texture.
  71289. * 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.
  71290. * This is the base class of any Procedural texture and contains most of the shareable code.
  71291. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71292. * @param name Define the name of the texture
  71293. * @param size Define the size of the texture to create
  71294. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  71295. * @param scene Define the scene the texture belongs to
  71296. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  71297. * @param generateMipMaps Define if the texture should creates mip maps or not
  71298. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  71299. */
  71300. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  71301. /**
  71302. * The effect that is created when initializing the post process.
  71303. * @returns The created effect corrisponding the the postprocess.
  71304. */
  71305. getEffect(): Effect;
  71306. /**
  71307. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  71308. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  71309. */
  71310. getContent(): Nullable<ArrayBufferView>;
  71311. private _createIndexBuffer;
  71312. /** @hidden */
  71313. _rebuild(): void;
  71314. /**
  71315. * Resets the texture in order to recreate its associated resources.
  71316. * This can be called in case of context loss
  71317. */
  71318. reset(): void;
  71319. protected _getDefines(): string;
  71320. /**
  71321. * Is the texture ready to be used ? (rendered at least once)
  71322. * @returns true if ready, otherwise, false.
  71323. */
  71324. isReady(): boolean;
  71325. /**
  71326. * Resets the refresh counter of the texture and start bak from scratch.
  71327. * Could be useful to regenerate the texture if it is setup to render only once.
  71328. */
  71329. resetRefreshCounter(): void;
  71330. /**
  71331. * Set the fragment shader to use in order to render the texture.
  71332. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  71333. */
  71334. setFragment(fragment: any): void;
  71335. /**
  71336. * Define the refresh rate of the texture or the rendering frequency.
  71337. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  71338. */
  71339. refreshRate: number;
  71340. /** @hidden */
  71341. _shouldRender(): boolean;
  71342. /**
  71343. * Get the size the texture is rendering at.
  71344. * @returns the size (texture is always squared)
  71345. */
  71346. getRenderSize(): number;
  71347. /**
  71348. * Resize the texture to new value.
  71349. * @param size Define the new size the texture should have
  71350. * @param generateMipMaps Define whether the new texture should create mip maps
  71351. */
  71352. resize(size: number, generateMipMaps: boolean): void;
  71353. private _checkUniform;
  71354. /**
  71355. * Set a texture in the shader program used to render.
  71356. * @param name Define the name of the uniform samplers as defined in the shader
  71357. * @param texture Define the texture to bind to this sampler
  71358. * @return the texture itself allowing "fluent" like uniform updates
  71359. */
  71360. setTexture(name: string, texture: Texture): ProceduralTexture;
  71361. /**
  71362. * Set a float in the shader.
  71363. * @param name Define the name of the uniform as defined in the shader
  71364. * @param value Define the value to give to the uniform
  71365. * @return the texture itself allowing "fluent" like uniform updates
  71366. */
  71367. setFloat(name: string, value: number): ProceduralTexture;
  71368. /**
  71369. * Set a int in the shader.
  71370. * @param name Define the name of the uniform as defined in the shader
  71371. * @param value Define the value to give to the uniform
  71372. * @return the texture itself allowing "fluent" like uniform updates
  71373. */
  71374. setInt(name: string, value: number): ProceduralTexture;
  71375. /**
  71376. * Set an array of floats in the shader.
  71377. * @param name Define the name of the uniform as defined in the shader
  71378. * @param value Define the value to give to the uniform
  71379. * @return the texture itself allowing "fluent" like uniform updates
  71380. */
  71381. setFloats(name: string, value: number[]): ProceduralTexture;
  71382. /**
  71383. * Set a vec3 in the shader from a Color3.
  71384. * @param name Define the name of the uniform as defined in the shader
  71385. * @param value Define the value to give to the uniform
  71386. * @return the texture itself allowing "fluent" like uniform updates
  71387. */
  71388. setColor3(name: string, value: Color3): ProceduralTexture;
  71389. /**
  71390. * Set a vec4 in the shader from a Color4.
  71391. * @param name Define the name of the uniform as defined in the shader
  71392. * @param value Define the value to give to the uniform
  71393. * @return the texture itself allowing "fluent" like uniform updates
  71394. */
  71395. setColor4(name: string, value: Color4): ProceduralTexture;
  71396. /**
  71397. * Set a vec2 in the shader from a Vector2.
  71398. * @param name Define the name of the uniform as defined in the shader
  71399. * @param value Define the value to give to the uniform
  71400. * @return the texture itself allowing "fluent" like uniform updates
  71401. */
  71402. setVector2(name: string, value: Vector2): ProceduralTexture;
  71403. /**
  71404. * Set a vec3 in the shader from a Vector3.
  71405. * @param name Define the name of the uniform as defined in the shader
  71406. * @param value Define the value to give to the uniform
  71407. * @return the texture itself allowing "fluent" like uniform updates
  71408. */
  71409. setVector3(name: string, value: Vector3): ProceduralTexture;
  71410. /**
  71411. * Set a mat4 in the shader from a MAtrix.
  71412. * @param name Define the name of the uniform as defined in the shader
  71413. * @param value Define the value to give to the uniform
  71414. * @return the texture itself allowing "fluent" like uniform updates
  71415. */
  71416. setMatrix(name: string, value: Matrix): ProceduralTexture;
  71417. /**
  71418. * Render the texture to its associated render target.
  71419. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  71420. */
  71421. render(useCameraPostProcess?: boolean): void;
  71422. /**
  71423. * Clone the texture.
  71424. * @returns the cloned texture
  71425. */
  71426. clone(): ProceduralTexture;
  71427. /**
  71428. * Dispose the texture and release its asoociated resources.
  71429. */
  71430. dispose(): void;
  71431. }
  71432. }
  71433. declare module BABYLON {
  71434. /**
  71435. * This represents the base class for particle system in Babylon.
  71436. * 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.
  71437. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71438. * @example https://doc.babylonjs.com/babylon101/particles
  71439. */
  71440. export class BaseParticleSystem {
  71441. /**
  71442. * Source color is added to the destination color without alpha affecting the result
  71443. */
  71444. static BLENDMODE_ONEONE: number;
  71445. /**
  71446. * Blend current color and particle color using particle’s alpha
  71447. */
  71448. static BLENDMODE_STANDARD: number;
  71449. /**
  71450. * Add current color and particle color multiplied by particle’s alpha
  71451. */
  71452. static BLENDMODE_ADD: number;
  71453. /**
  71454. * Multiply current color with particle color
  71455. */
  71456. static BLENDMODE_MULTIPLY: number;
  71457. /**
  71458. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  71459. */
  71460. static BLENDMODE_MULTIPLYADD: number;
  71461. /**
  71462. * List of animations used by the particle system.
  71463. */
  71464. animations: Animation[];
  71465. /**
  71466. * The id of the Particle system.
  71467. */
  71468. id: string;
  71469. /**
  71470. * The friendly name of the Particle system.
  71471. */
  71472. name: string;
  71473. /**
  71474. * The rendering group used by the Particle system to chose when to render.
  71475. */
  71476. renderingGroupId: number;
  71477. /**
  71478. * The emitter represents the Mesh or position we are attaching the particle system to.
  71479. */
  71480. emitter: Nullable<AbstractMesh | Vector3>;
  71481. /**
  71482. * The maximum number of particles to emit per frame
  71483. */
  71484. emitRate: number;
  71485. /**
  71486. * If you want to launch only a few particles at once, that can be done, as well.
  71487. */
  71488. manualEmitCount: number;
  71489. /**
  71490. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  71491. */
  71492. updateSpeed: number;
  71493. /**
  71494. * The amount of time the particle system is running (depends of the overall update speed).
  71495. */
  71496. targetStopDuration: number;
  71497. /**
  71498. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  71499. */
  71500. disposeOnStop: boolean;
  71501. /**
  71502. * Minimum power of emitting particles.
  71503. */
  71504. minEmitPower: number;
  71505. /**
  71506. * Maximum power of emitting particles.
  71507. */
  71508. maxEmitPower: number;
  71509. /**
  71510. * Minimum life time of emitting particles.
  71511. */
  71512. minLifeTime: number;
  71513. /**
  71514. * Maximum life time of emitting particles.
  71515. */
  71516. maxLifeTime: number;
  71517. /**
  71518. * Minimum Size of emitting particles.
  71519. */
  71520. minSize: number;
  71521. /**
  71522. * Maximum Size of emitting particles.
  71523. */
  71524. maxSize: number;
  71525. /**
  71526. * Minimum scale of emitting particles on X axis.
  71527. */
  71528. minScaleX: number;
  71529. /**
  71530. * Maximum scale of emitting particles on X axis.
  71531. */
  71532. maxScaleX: number;
  71533. /**
  71534. * Minimum scale of emitting particles on Y axis.
  71535. */
  71536. minScaleY: number;
  71537. /**
  71538. * Maximum scale of emitting particles on Y axis.
  71539. */
  71540. maxScaleY: number;
  71541. /**
  71542. * Gets or sets the minimal initial rotation in radians.
  71543. */
  71544. minInitialRotation: number;
  71545. /**
  71546. * Gets or sets the maximal initial rotation in radians.
  71547. */
  71548. maxInitialRotation: number;
  71549. /**
  71550. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  71551. */
  71552. minAngularSpeed: number;
  71553. /**
  71554. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  71555. */
  71556. maxAngularSpeed: number;
  71557. /**
  71558. * The texture used to render each particle. (this can be a spritesheet)
  71559. */
  71560. particleTexture: Nullable<Texture>;
  71561. /**
  71562. * The layer mask we are rendering the particles through.
  71563. */
  71564. layerMask: number;
  71565. /**
  71566. * This can help using your own shader to render the particle system.
  71567. * The according effect will be created
  71568. */
  71569. customShader: any;
  71570. /**
  71571. * By default particle system starts as soon as they are created. This prevents the
  71572. * automatic start to happen and let you decide when to start emitting particles.
  71573. */
  71574. preventAutoStart: boolean;
  71575. private _noiseTexture;
  71576. /**
  71577. * Gets or sets a texture used to add random noise to particle positions
  71578. */
  71579. noiseTexture: Nullable<ProceduralTexture>;
  71580. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  71581. noiseStrength: Vector3;
  71582. /**
  71583. * Callback triggered when the particle animation is ending.
  71584. */
  71585. onAnimationEnd: Nullable<() => void>;
  71586. /**
  71587. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  71588. */
  71589. blendMode: number;
  71590. /**
  71591. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71592. * to override the particles.
  71593. */
  71594. forceDepthWrite: boolean;
  71595. /** 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 */
  71596. preWarmCycles: number;
  71597. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  71598. preWarmStepOffset: number;
  71599. /**
  71600. * 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)
  71601. */
  71602. spriteCellChangeSpeed: number;
  71603. /**
  71604. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  71605. */
  71606. startSpriteCellID: number;
  71607. /**
  71608. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  71609. */
  71610. endSpriteCellID: number;
  71611. /**
  71612. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  71613. */
  71614. spriteCellWidth: number;
  71615. /**
  71616. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  71617. */
  71618. spriteCellHeight: number;
  71619. /**
  71620. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  71621. */
  71622. spriteRandomStartCell: boolean;
  71623. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  71624. translationPivot: Vector2;
  71625. /** @hidden */
  71626. protected _isAnimationSheetEnabled: boolean;
  71627. /**
  71628. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  71629. */
  71630. beginAnimationOnStart: boolean;
  71631. /**
  71632. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  71633. */
  71634. beginAnimationFrom: number;
  71635. /**
  71636. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  71637. */
  71638. beginAnimationTo: number;
  71639. /**
  71640. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  71641. */
  71642. beginAnimationLoop: boolean;
  71643. /**
  71644. * Gets or sets a world offset applied to all particles
  71645. */
  71646. worldOffset: Vector3;
  71647. /**
  71648. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  71649. */
  71650. isAnimationSheetEnabled: boolean;
  71651. /**
  71652. * Get hosting scene
  71653. * @returns the scene
  71654. */
  71655. getScene(): Scene;
  71656. /**
  71657. * You can use gravity if you want to give an orientation to your particles.
  71658. */
  71659. gravity: Vector3;
  71660. protected _colorGradients: Nullable<Array<ColorGradient>>;
  71661. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  71662. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  71663. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  71664. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  71665. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  71666. protected _dragGradients: Nullable<Array<FactorGradient>>;
  71667. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  71668. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  71669. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  71670. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  71671. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  71672. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  71673. /**
  71674. * Defines the delay in milliseconds before starting the system (0 by default)
  71675. */
  71676. startDelay: number;
  71677. /**
  71678. * Gets the current list of drag gradients.
  71679. * You must use addDragGradient and removeDragGradient to udpate this list
  71680. * @returns the list of drag gradients
  71681. */
  71682. getDragGradients(): Nullable<Array<FactorGradient>>;
  71683. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  71684. limitVelocityDamping: number;
  71685. /**
  71686. * Gets the current list of limit velocity gradients.
  71687. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  71688. * @returns the list of limit velocity gradients
  71689. */
  71690. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  71691. /**
  71692. * Gets the current list of color gradients.
  71693. * You must use addColorGradient and removeColorGradient to udpate this list
  71694. * @returns the list of color gradients
  71695. */
  71696. getColorGradients(): Nullable<Array<ColorGradient>>;
  71697. /**
  71698. * Gets the current list of size gradients.
  71699. * You must use addSizeGradient and removeSizeGradient to udpate this list
  71700. * @returns the list of size gradients
  71701. */
  71702. getSizeGradients(): Nullable<Array<FactorGradient>>;
  71703. /**
  71704. * Gets the current list of color remap gradients.
  71705. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  71706. * @returns the list of color remap gradients
  71707. */
  71708. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  71709. /**
  71710. * Gets the current list of alpha remap gradients.
  71711. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  71712. * @returns the list of alpha remap gradients
  71713. */
  71714. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  71715. /**
  71716. * Gets the current list of life time gradients.
  71717. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  71718. * @returns the list of life time gradients
  71719. */
  71720. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  71721. /**
  71722. * Gets the current list of angular speed gradients.
  71723. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  71724. * @returns the list of angular speed gradients
  71725. */
  71726. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  71727. /**
  71728. * Gets the current list of velocity gradients.
  71729. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  71730. * @returns the list of velocity gradients
  71731. */
  71732. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  71733. /**
  71734. * Gets the current list of start size gradients.
  71735. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  71736. * @returns the list of start size gradients
  71737. */
  71738. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  71739. /**
  71740. * Gets the current list of emit rate gradients.
  71741. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  71742. * @returns the list of emit rate gradients
  71743. */
  71744. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  71745. /**
  71746. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71747. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71748. */
  71749. direction1: Vector3;
  71750. /**
  71751. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71752. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71753. */
  71754. direction2: Vector3;
  71755. /**
  71756. * 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.
  71757. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71758. */
  71759. minEmitBox: Vector3;
  71760. /**
  71761. * 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.
  71762. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71763. */
  71764. maxEmitBox: Vector3;
  71765. /**
  71766. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71767. */
  71768. color1: Color4;
  71769. /**
  71770. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71771. */
  71772. color2: Color4;
  71773. /**
  71774. * Color the particle will have at the end of its lifetime
  71775. */
  71776. colorDead: Color4;
  71777. /**
  71778. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  71779. */
  71780. textureMask: Color4;
  71781. /**
  71782. * The particle emitter type defines the emitter used by the particle system.
  71783. * It can be for example box, sphere, or cone...
  71784. */
  71785. particleEmitterType: IParticleEmitterType;
  71786. /** @hidden */
  71787. _isSubEmitter: boolean;
  71788. /**
  71789. * Gets or sets the billboard mode to use when isBillboardBased = true.
  71790. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  71791. */
  71792. billboardMode: number;
  71793. protected _isBillboardBased: boolean;
  71794. /**
  71795. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  71796. */
  71797. isBillboardBased: boolean;
  71798. /**
  71799. * The scene the particle system belongs to.
  71800. */
  71801. protected _scene: Scene;
  71802. /**
  71803. * Local cache of defines for image processing.
  71804. */
  71805. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  71806. /**
  71807. * Default configuration related to image processing available in the standard Material.
  71808. */
  71809. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  71810. /**
  71811. * Gets the image processing configuration used either in this material.
  71812. */
  71813. /**
  71814. * Sets the Default image processing configuration used either in the this material.
  71815. *
  71816. * If sets to null, the scene one is in use.
  71817. */
  71818. imageProcessingConfiguration: ImageProcessingConfiguration;
  71819. /**
  71820. * Attaches a new image processing configuration to the Standard Material.
  71821. * @param configuration
  71822. */
  71823. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  71824. /** @hidden */
  71825. protected _reset(): void;
  71826. /** @hidden */
  71827. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  71828. /**
  71829. * Instantiates a particle system.
  71830. * 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.
  71831. * @param name The name of the particle system
  71832. */
  71833. constructor(name: string);
  71834. /**
  71835. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  71836. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71837. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71838. * @returns the emitter
  71839. */
  71840. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  71841. /**
  71842. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  71843. * @param radius The radius of the hemisphere to emit from
  71844. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71845. * @returns the emitter
  71846. */
  71847. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  71848. /**
  71849. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  71850. * @param radius The radius of the sphere to emit from
  71851. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71852. * @returns the emitter
  71853. */
  71854. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  71855. /**
  71856. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  71857. * @param radius The radius of the sphere to emit from
  71858. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  71859. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  71860. * @returns the emitter
  71861. */
  71862. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  71863. /**
  71864. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  71865. * @param radius The radius of the emission cylinder
  71866. * @param height The height of the emission cylinder
  71867. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  71868. * @param directionRandomizer How much to randomize the particle direction [0-1]
  71869. * @returns the emitter
  71870. */
  71871. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  71872. /**
  71873. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  71874. * @param radius The radius of the cylinder to emit from
  71875. * @param height The height of the emission cylinder
  71876. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71877. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  71878. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  71879. * @returns the emitter
  71880. */
  71881. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  71882. /**
  71883. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  71884. * @param radius The radius of the cone to emit from
  71885. * @param angle The base angle of the cone
  71886. * @returns the emitter
  71887. */
  71888. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  71889. /**
  71890. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  71891. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71892. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71893. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71894. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71895. * @returns the emitter
  71896. */
  71897. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  71898. }
  71899. }
  71900. declare module BABYLON {
  71901. /**
  71902. * Type of sub emitter
  71903. */
  71904. export enum SubEmitterType {
  71905. /**
  71906. * Attached to the particle over it's lifetime
  71907. */
  71908. ATTACHED = 0,
  71909. /**
  71910. * Created when the particle dies
  71911. */
  71912. END = 1
  71913. }
  71914. /**
  71915. * Sub emitter class used to emit particles from an existing particle
  71916. */
  71917. export class SubEmitter {
  71918. /**
  71919. * the particle system to be used by the sub emitter
  71920. */
  71921. particleSystem: ParticleSystem;
  71922. /**
  71923. * Type of the submitter (Default: END)
  71924. */
  71925. type: SubEmitterType;
  71926. /**
  71927. * 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)
  71928. * Note: This only is supported when using an emitter of type Mesh
  71929. */
  71930. inheritDirection: boolean;
  71931. /**
  71932. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  71933. */
  71934. inheritedVelocityAmount: number;
  71935. /**
  71936. * Creates a sub emitter
  71937. * @param particleSystem the particle system to be used by the sub emitter
  71938. */
  71939. constructor(
  71940. /**
  71941. * the particle system to be used by the sub emitter
  71942. */
  71943. particleSystem: ParticleSystem);
  71944. /**
  71945. * Clones the sub emitter
  71946. * @returns the cloned sub emitter
  71947. */
  71948. clone(): SubEmitter;
  71949. /**
  71950. * Serialize current object to a JSON object
  71951. * @returns the serialized object
  71952. */
  71953. serialize(): any;
  71954. /** @hidden */
  71955. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  71956. /**
  71957. * Creates a new SubEmitter from a serialized JSON version
  71958. * @param serializationObject defines the JSON object to read from
  71959. * @param scene defines the hosting scene
  71960. * @param rootUrl defines the rootUrl for data loading
  71961. * @returns a new SubEmitter
  71962. */
  71963. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  71964. /** Release associated resources */
  71965. dispose(): void;
  71966. }
  71967. }
  71968. declare module BABYLON {
  71969. /** @hidden */
  71970. export var clipPlaneFragmentDeclaration: {
  71971. name: string;
  71972. shader: string;
  71973. };
  71974. }
  71975. declare module BABYLON {
  71976. /** @hidden */
  71977. export var imageProcessingDeclaration: {
  71978. name: string;
  71979. shader: string;
  71980. };
  71981. }
  71982. declare module BABYLON {
  71983. /** @hidden */
  71984. export var imageProcessingFunctions: {
  71985. name: string;
  71986. shader: string;
  71987. };
  71988. }
  71989. declare module BABYLON {
  71990. /** @hidden */
  71991. export var clipPlaneFragment: {
  71992. name: string;
  71993. shader: string;
  71994. };
  71995. }
  71996. declare module BABYLON {
  71997. /** @hidden */
  71998. export var particlesPixelShader: {
  71999. name: string;
  72000. shader: string;
  72001. };
  72002. }
  72003. declare module BABYLON {
  72004. /** @hidden */
  72005. export var clipPlaneVertexDeclaration: {
  72006. name: string;
  72007. shader: string;
  72008. };
  72009. }
  72010. declare module BABYLON {
  72011. /** @hidden */
  72012. export var clipPlaneVertex: {
  72013. name: string;
  72014. shader: string;
  72015. };
  72016. }
  72017. declare module BABYLON {
  72018. /** @hidden */
  72019. export var particlesVertexShader: {
  72020. name: string;
  72021. shader: string;
  72022. };
  72023. }
  72024. declare module BABYLON {
  72025. /**
  72026. * This represents a particle system in Babylon.
  72027. * 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.
  72028. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  72029. * @example https://doc.babylonjs.com/babylon101/particles
  72030. */
  72031. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  72032. /**
  72033. * Billboard mode will only apply to Y axis
  72034. */
  72035. static readonly BILLBOARDMODE_Y: number;
  72036. /**
  72037. * Billboard mode will apply to all axes
  72038. */
  72039. static readonly BILLBOARDMODE_ALL: number;
  72040. /**
  72041. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  72042. */
  72043. static readonly BILLBOARDMODE_STRETCHED: number;
  72044. /**
  72045. * This function can be defined to provide custom update for active particles.
  72046. * This function will be called instead of regular update (age, position, color, etc.).
  72047. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  72048. */
  72049. updateFunction: (particles: Particle[]) => void;
  72050. private _emitterWorldMatrix;
  72051. /**
  72052. * This function can be defined to specify initial direction for every new particle.
  72053. * It by default use the emitterType defined function
  72054. */
  72055. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  72056. /**
  72057. * This function can be defined to specify initial position for every new particle.
  72058. * It by default use the emitterType defined function
  72059. */
  72060. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  72061. /**
  72062. * @hidden
  72063. */
  72064. _inheritedVelocityOffset: Vector3;
  72065. /**
  72066. * An event triggered when the system is disposed
  72067. */
  72068. onDisposeObservable: Observable<ParticleSystem>;
  72069. private _onDisposeObserver;
  72070. /**
  72071. * Sets a callback that will be triggered when the system is disposed
  72072. */
  72073. onDispose: () => void;
  72074. private _particles;
  72075. private _epsilon;
  72076. private _capacity;
  72077. private _stockParticles;
  72078. private _newPartsExcess;
  72079. private _vertexData;
  72080. private _vertexBuffer;
  72081. private _vertexBuffers;
  72082. private _spriteBuffer;
  72083. private _indexBuffer;
  72084. private _effect;
  72085. private _customEffect;
  72086. private _cachedDefines;
  72087. private _scaledColorStep;
  72088. private _colorDiff;
  72089. private _scaledDirection;
  72090. private _scaledGravity;
  72091. private _currentRenderId;
  72092. private _alive;
  72093. private _useInstancing;
  72094. private _started;
  72095. private _stopped;
  72096. private _actualFrame;
  72097. private _scaledUpdateSpeed;
  72098. private _vertexBufferSize;
  72099. /** @hidden */
  72100. _currentEmitRateGradient: Nullable<FactorGradient>;
  72101. /** @hidden */
  72102. _currentEmitRate1: number;
  72103. /** @hidden */
  72104. _currentEmitRate2: number;
  72105. /** @hidden */
  72106. _currentStartSizeGradient: Nullable<FactorGradient>;
  72107. /** @hidden */
  72108. _currentStartSize1: number;
  72109. /** @hidden */
  72110. _currentStartSize2: number;
  72111. private readonly _rawTextureWidth;
  72112. private _rampGradientsTexture;
  72113. private _useRampGradients;
  72114. /** Gets or sets a boolean indicating that ramp gradients must be used
  72115. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72116. */
  72117. useRampGradients: boolean;
  72118. /**
  72119. * 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.
  72120. * 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: [])
  72121. */
  72122. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  72123. private _subEmitters;
  72124. /**
  72125. * @hidden
  72126. * If the particle systems emitter should be disposed when the particle system is disposed
  72127. */
  72128. _disposeEmitterOnDispose: boolean;
  72129. /**
  72130. * The current active Sub-systems, this property is used by the root particle system only.
  72131. */
  72132. activeSubSystems: Array<ParticleSystem>;
  72133. private _rootParticleSystem;
  72134. /**
  72135. * Gets the current list of active particles
  72136. */
  72137. readonly particles: Particle[];
  72138. /**
  72139. * Returns the string "ParticleSystem"
  72140. * @returns a string containing the class name
  72141. */
  72142. getClassName(): string;
  72143. /**
  72144. * Instantiates a particle system.
  72145. * 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.
  72146. * @param name The name of the particle system
  72147. * @param capacity The max number of particles alive at the same time
  72148. * @param scene The scene the particle system belongs to
  72149. * @param customEffect a custom effect used to change the way particles are rendered by default
  72150. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72151. * @param epsilon Offset used to render the particles
  72152. */
  72153. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  72154. private _addFactorGradient;
  72155. private _removeFactorGradient;
  72156. /**
  72157. * Adds a new life time gradient
  72158. * @param gradient defines the gradient to use (between 0 and 1)
  72159. * @param factor defines the life time factor to affect to the specified gradient
  72160. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72161. * @returns the current particle system
  72162. */
  72163. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72164. /**
  72165. * Remove a specific life time gradient
  72166. * @param gradient defines the gradient to remove
  72167. * @returns the current particle system
  72168. */
  72169. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72170. /**
  72171. * Adds a new size gradient
  72172. * @param gradient defines the gradient to use (between 0 and 1)
  72173. * @param factor defines the size factor to affect to the specified gradient
  72174. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72175. * @returns the current particle system
  72176. */
  72177. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72178. /**
  72179. * Remove a specific size gradient
  72180. * @param gradient defines the gradient to remove
  72181. * @returns the current particle system
  72182. */
  72183. removeSizeGradient(gradient: number): IParticleSystem;
  72184. /**
  72185. * Adds a new color remap gradient
  72186. * @param gradient defines the gradient to use (between 0 and 1)
  72187. * @param min defines the color remap minimal range
  72188. * @param max defines the color remap maximal range
  72189. * @returns the current particle system
  72190. */
  72191. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72192. /**
  72193. * Remove a specific color remap gradient
  72194. * @param gradient defines the gradient to remove
  72195. * @returns the current particle system
  72196. */
  72197. removeColorRemapGradient(gradient: number): IParticleSystem;
  72198. /**
  72199. * Adds a new alpha remap gradient
  72200. * @param gradient defines the gradient to use (between 0 and 1)
  72201. * @param min defines the alpha remap minimal range
  72202. * @param max defines the alpha remap maximal range
  72203. * @returns the current particle system
  72204. */
  72205. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72206. /**
  72207. * Remove a specific alpha remap gradient
  72208. * @param gradient defines the gradient to remove
  72209. * @returns the current particle system
  72210. */
  72211. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  72212. /**
  72213. * Adds a new angular speed gradient
  72214. * @param gradient defines the gradient to use (between 0 and 1)
  72215. * @param factor defines the angular speed to affect to the specified gradient
  72216. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72217. * @returns the current particle system
  72218. */
  72219. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72220. /**
  72221. * Remove a specific angular speed gradient
  72222. * @param gradient defines the gradient to remove
  72223. * @returns the current particle system
  72224. */
  72225. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  72226. /**
  72227. * Adds a new velocity gradient
  72228. * @param gradient defines the gradient to use (between 0 and 1)
  72229. * @param factor defines the velocity to affect to the specified gradient
  72230. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72231. * @returns the current particle system
  72232. */
  72233. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72234. /**
  72235. * Remove a specific velocity gradient
  72236. * @param gradient defines the gradient to remove
  72237. * @returns the current particle system
  72238. */
  72239. removeVelocityGradient(gradient: number): IParticleSystem;
  72240. /**
  72241. * Adds a new limit velocity gradient
  72242. * @param gradient defines the gradient to use (between 0 and 1)
  72243. * @param factor defines the limit velocity value to affect to the specified gradient
  72244. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72245. * @returns the current particle system
  72246. */
  72247. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72248. /**
  72249. * Remove a specific limit velocity gradient
  72250. * @param gradient defines the gradient to remove
  72251. * @returns the current particle system
  72252. */
  72253. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  72254. /**
  72255. * Adds a new drag gradient
  72256. * @param gradient defines the gradient to use (between 0 and 1)
  72257. * @param factor defines the drag value to affect to the specified gradient
  72258. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72259. * @returns the current particle system
  72260. */
  72261. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72262. /**
  72263. * Remove a specific drag gradient
  72264. * @param gradient defines the gradient to remove
  72265. * @returns the current particle system
  72266. */
  72267. removeDragGradient(gradient: number): IParticleSystem;
  72268. /**
  72269. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  72270. * @param gradient defines the gradient to use (between 0 and 1)
  72271. * @param factor defines the emit rate value to affect to the specified gradient
  72272. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72273. * @returns the current particle system
  72274. */
  72275. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72276. /**
  72277. * Remove a specific emit rate gradient
  72278. * @param gradient defines the gradient to remove
  72279. * @returns the current particle system
  72280. */
  72281. removeEmitRateGradient(gradient: number): IParticleSystem;
  72282. /**
  72283. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  72284. * @param gradient defines the gradient to use (between 0 and 1)
  72285. * @param factor defines the start size value to affect to the specified gradient
  72286. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72287. * @returns the current particle system
  72288. */
  72289. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72290. /**
  72291. * Remove a specific start size gradient
  72292. * @param gradient defines the gradient to remove
  72293. * @returns the current particle system
  72294. */
  72295. removeStartSizeGradient(gradient: number): IParticleSystem;
  72296. private _createRampGradientTexture;
  72297. /**
  72298. * Gets the current list of ramp gradients.
  72299. * You must use addRampGradient and removeRampGradient to udpate this list
  72300. * @returns the list of ramp gradients
  72301. */
  72302. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72303. /**
  72304. * Adds a new ramp gradient used to remap particle colors
  72305. * @param gradient defines the gradient to use (between 0 and 1)
  72306. * @param color defines the color to affect to the specified gradient
  72307. * @returns the current particle system
  72308. */
  72309. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  72310. /**
  72311. * Remove a specific ramp gradient
  72312. * @param gradient defines the gradient to remove
  72313. * @returns the current particle system
  72314. */
  72315. removeRampGradient(gradient: number): ParticleSystem;
  72316. /**
  72317. * Adds a new color gradient
  72318. * @param gradient defines the gradient to use (between 0 and 1)
  72319. * @param color1 defines the color to affect to the specified gradient
  72320. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72321. * @returns this particle system
  72322. */
  72323. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  72324. /**
  72325. * Remove a specific color gradient
  72326. * @param gradient defines the gradient to remove
  72327. * @returns this particle system
  72328. */
  72329. removeColorGradient(gradient: number): IParticleSystem;
  72330. private _fetchR;
  72331. protected _reset(): void;
  72332. private _resetEffect;
  72333. private _createVertexBuffers;
  72334. private _createIndexBuffer;
  72335. /**
  72336. * Gets the maximum number of particles active at the same time.
  72337. * @returns The max number of active particles.
  72338. */
  72339. getCapacity(): number;
  72340. /**
  72341. * Gets whether there are still active particles in the system.
  72342. * @returns True if it is alive, otherwise false.
  72343. */
  72344. isAlive(): boolean;
  72345. /**
  72346. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72347. * @returns True if it has been started, otherwise false.
  72348. */
  72349. isStarted(): boolean;
  72350. private _prepareSubEmitterInternalArray;
  72351. /**
  72352. * Starts the particle system and begins to emit
  72353. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72354. */
  72355. start(delay?: number): void;
  72356. /**
  72357. * Stops the particle system.
  72358. * @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.
  72359. */
  72360. stop(stopSubEmitters?: boolean): void;
  72361. /**
  72362. * Remove all active particles
  72363. */
  72364. reset(): void;
  72365. /**
  72366. * @hidden (for internal use only)
  72367. */
  72368. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  72369. /**
  72370. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  72371. * Its lifetime will start back at 0.
  72372. */
  72373. recycleParticle: (particle: Particle) => void;
  72374. private _stopSubEmitters;
  72375. private _createParticle;
  72376. private _removeFromRoot;
  72377. private _emitFromParticle;
  72378. private _update;
  72379. /** @hidden */
  72380. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  72381. /** @hidden */
  72382. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  72383. /** @hidden */
  72384. private _getEffect;
  72385. /**
  72386. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72387. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  72388. */
  72389. animate(preWarmOnly?: boolean): void;
  72390. private _appendParticleVertices;
  72391. /**
  72392. * Rebuilds the particle system.
  72393. */
  72394. rebuild(): void;
  72395. /**
  72396. * Is this system ready to be used/rendered
  72397. * @return true if the system is ready
  72398. */
  72399. isReady(): boolean;
  72400. private _render;
  72401. /**
  72402. * Renders the particle system in its current state.
  72403. * @returns the current number of particles
  72404. */
  72405. render(): number;
  72406. /**
  72407. * Disposes the particle system and free the associated resources
  72408. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72409. */
  72410. dispose(disposeTexture?: boolean): void;
  72411. /**
  72412. * Clones the particle system.
  72413. * @param name The name of the cloned object
  72414. * @param newEmitter The new emitter to use
  72415. * @returns the cloned particle system
  72416. */
  72417. clone(name: string, newEmitter: any): ParticleSystem;
  72418. /**
  72419. * Serializes the particle system to a JSON object.
  72420. * @returns the JSON object
  72421. */
  72422. serialize(): any;
  72423. /** @hidden */
  72424. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  72425. /** @hidden */
  72426. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  72427. /**
  72428. * Parses a JSON object to create a particle system.
  72429. * @param parsedParticleSystem The JSON object to parse
  72430. * @param scene The scene to create the particle system in
  72431. * @param rootUrl The root url to use to load external dependencies like texture
  72432. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72433. * @returns the Parsed particle system
  72434. */
  72435. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  72436. }
  72437. }
  72438. declare module BABYLON {
  72439. /**
  72440. * A particle represents one of the element emitted by a particle system.
  72441. * This is mainly define by its coordinates, direction, velocity and age.
  72442. */
  72443. export class Particle {
  72444. /**
  72445. * The particle system the particle belongs to.
  72446. */
  72447. particleSystem: ParticleSystem;
  72448. private static _Count;
  72449. /**
  72450. * Unique ID of the particle
  72451. */
  72452. id: number;
  72453. /**
  72454. * The world position of the particle in the scene.
  72455. */
  72456. position: Vector3;
  72457. /**
  72458. * The world direction of the particle in the scene.
  72459. */
  72460. direction: Vector3;
  72461. /**
  72462. * The color of the particle.
  72463. */
  72464. color: Color4;
  72465. /**
  72466. * The color change of the particle per step.
  72467. */
  72468. colorStep: Color4;
  72469. /**
  72470. * Defines how long will the life of the particle be.
  72471. */
  72472. lifeTime: number;
  72473. /**
  72474. * The current age of the particle.
  72475. */
  72476. age: number;
  72477. /**
  72478. * The current size of the particle.
  72479. */
  72480. size: number;
  72481. /**
  72482. * The current scale of the particle.
  72483. */
  72484. scale: Vector2;
  72485. /**
  72486. * The current angle of the particle.
  72487. */
  72488. angle: number;
  72489. /**
  72490. * Defines how fast is the angle changing.
  72491. */
  72492. angularSpeed: number;
  72493. /**
  72494. * Defines the cell index used by the particle to be rendered from a sprite.
  72495. */
  72496. cellIndex: number;
  72497. /**
  72498. * The information required to support color remapping
  72499. */
  72500. remapData: Vector4;
  72501. /** @hidden */
  72502. _randomCellOffset?: number;
  72503. /** @hidden */
  72504. _initialDirection: Nullable<Vector3>;
  72505. /** @hidden */
  72506. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  72507. /** @hidden */
  72508. _initialStartSpriteCellID: number;
  72509. /** @hidden */
  72510. _initialEndSpriteCellID: number;
  72511. /** @hidden */
  72512. _currentColorGradient: Nullable<ColorGradient>;
  72513. /** @hidden */
  72514. _currentColor1: Color4;
  72515. /** @hidden */
  72516. _currentColor2: Color4;
  72517. /** @hidden */
  72518. _currentSizeGradient: Nullable<FactorGradient>;
  72519. /** @hidden */
  72520. _currentSize1: number;
  72521. /** @hidden */
  72522. _currentSize2: number;
  72523. /** @hidden */
  72524. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  72525. /** @hidden */
  72526. _currentAngularSpeed1: number;
  72527. /** @hidden */
  72528. _currentAngularSpeed2: number;
  72529. /** @hidden */
  72530. _currentVelocityGradient: Nullable<FactorGradient>;
  72531. /** @hidden */
  72532. _currentVelocity1: number;
  72533. /** @hidden */
  72534. _currentVelocity2: number;
  72535. /** @hidden */
  72536. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  72537. /** @hidden */
  72538. _currentLimitVelocity1: number;
  72539. /** @hidden */
  72540. _currentLimitVelocity2: number;
  72541. /** @hidden */
  72542. _currentDragGradient: Nullable<FactorGradient>;
  72543. /** @hidden */
  72544. _currentDrag1: number;
  72545. /** @hidden */
  72546. _currentDrag2: number;
  72547. /** @hidden */
  72548. _randomNoiseCoordinates1: Vector3;
  72549. /** @hidden */
  72550. _randomNoiseCoordinates2: Vector3;
  72551. /**
  72552. * Creates a new instance Particle
  72553. * @param particleSystem the particle system the particle belongs to
  72554. */
  72555. constructor(
  72556. /**
  72557. * The particle system the particle belongs to.
  72558. */
  72559. particleSystem: ParticleSystem);
  72560. private updateCellInfoFromSystem;
  72561. /**
  72562. * Defines how the sprite cell index is updated for the particle
  72563. */
  72564. updateCellIndex(): void;
  72565. /** @hidden */
  72566. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  72567. /** @hidden */
  72568. _inheritParticleInfoToSubEmitters(): void;
  72569. /** @hidden */
  72570. _reset(): void;
  72571. /**
  72572. * Copy the properties of particle to another one.
  72573. * @param other the particle to copy the information to.
  72574. */
  72575. copyTo(other: Particle): void;
  72576. }
  72577. }
  72578. declare module BABYLON {
  72579. /**
  72580. * Particle emitter represents a volume emitting particles.
  72581. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  72582. */
  72583. export interface IParticleEmitterType {
  72584. /**
  72585. * Called by the particle System when the direction is computed for the created particle.
  72586. * @param worldMatrix is the world matrix of the particle system
  72587. * @param directionToUpdate is the direction vector to update with the result
  72588. * @param particle is the particle we are computed the direction for
  72589. */
  72590. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72591. /**
  72592. * Called by the particle System when the position is computed for the created particle.
  72593. * @param worldMatrix is the world matrix of the particle system
  72594. * @param positionToUpdate is the position vector to update with the result
  72595. * @param particle is the particle we are computed the position for
  72596. */
  72597. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72598. /**
  72599. * Clones the current emitter and returns a copy of it
  72600. * @returns the new emitter
  72601. */
  72602. clone(): IParticleEmitterType;
  72603. /**
  72604. * Called by the GPUParticleSystem to setup the update shader
  72605. * @param effect defines the update shader
  72606. */
  72607. applyToShader(effect: Effect): void;
  72608. /**
  72609. * Returns a string to use to update the GPU particles update shader
  72610. * @returns the effect defines string
  72611. */
  72612. getEffectDefines(): string;
  72613. /**
  72614. * Returns a string representing the class name
  72615. * @returns a string containing the class name
  72616. */
  72617. getClassName(): string;
  72618. /**
  72619. * Serializes the particle system to a JSON object.
  72620. * @returns the JSON object
  72621. */
  72622. serialize(): any;
  72623. /**
  72624. * Parse properties from a JSON object
  72625. * @param serializationObject defines the JSON object
  72626. */
  72627. parse(serializationObject: any): void;
  72628. }
  72629. }
  72630. declare module BABYLON {
  72631. /**
  72632. * Particle emitter emitting particles from the inside of a box.
  72633. * It emits the particles randomly between 2 given directions.
  72634. */
  72635. export class BoxParticleEmitter implements IParticleEmitterType {
  72636. /**
  72637. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72638. */
  72639. direction1: Vector3;
  72640. /**
  72641. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72642. */
  72643. direction2: Vector3;
  72644. /**
  72645. * 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.
  72646. */
  72647. minEmitBox: Vector3;
  72648. /**
  72649. * 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.
  72650. */
  72651. maxEmitBox: Vector3;
  72652. /**
  72653. * Creates a new instance BoxParticleEmitter
  72654. */
  72655. constructor();
  72656. /**
  72657. * Called by the particle System when the direction is computed for the created particle.
  72658. * @param worldMatrix is the world matrix of the particle system
  72659. * @param directionToUpdate is the direction vector to update with the result
  72660. * @param particle is the particle we are computed the direction for
  72661. */
  72662. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72663. /**
  72664. * Called by the particle System when the position is computed for the created particle.
  72665. * @param worldMatrix is the world matrix of the particle system
  72666. * @param positionToUpdate is the position vector to update with the result
  72667. * @param particle is the particle we are computed the position for
  72668. */
  72669. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72670. /**
  72671. * Clones the current emitter and returns a copy of it
  72672. * @returns the new emitter
  72673. */
  72674. clone(): BoxParticleEmitter;
  72675. /**
  72676. * Called by the GPUParticleSystem to setup the update shader
  72677. * @param effect defines the update shader
  72678. */
  72679. applyToShader(effect: Effect): void;
  72680. /**
  72681. * Returns a string to use to update the GPU particles update shader
  72682. * @returns a string containng the defines string
  72683. */
  72684. getEffectDefines(): string;
  72685. /**
  72686. * Returns the string "BoxParticleEmitter"
  72687. * @returns a string containing the class name
  72688. */
  72689. getClassName(): string;
  72690. /**
  72691. * Serializes the particle system to a JSON object.
  72692. * @returns the JSON object
  72693. */
  72694. serialize(): any;
  72695. /**
  72696. * Parse properties from a JSON object
  72697. * @param serializationObject defines the JSON object
  72698. */
  72699. parse(serializationObject: any): void;
  72700. }
  72701. }
  72702. declare module BABYLON {
  72703. /**
  72704. * Particle emitter emitting particles from the inside of a cone.
  72705. * It emits the particles alongside the cone volume from the base to the particle.
  72706. * The emission direction might be randomized.
  72707. */
  72708. export class ConeParticleEmitter implements IParticleEmitterType {
  72709. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72710. directionRandomizer: number;
  72711. private _radius;
  72712. private _angle;
  72713. private _height;
  72714. /**
  72715. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  72716. */
  72717. radiusRange: number;
  72718. /**
  72719. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  72720. */
  72721. heightRange: number;
  72722. /**
  72723. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  72724. */
  72725. emitFromSpawnPointOnly: boolean;
  72726. /**
  72727. * Gets or sets the radius of the emission cone
  72728. */
  72729. radius: number;
  72730. /**
  72731. * Gets or sets the angle of the emission cone
  72732. */
  72733. angle: number;
  72734. private _buildHeight;
  72735. /**
  72736. * Creates a new instance ConeParticleEmitter
  72737. * @param radius the radius of the emission cone (1 by default)
  72738. * @param angle the cone base angle (PI by default)
  72739. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  72740. */
  72741. constructor(radius?: number, angle?: number,
  72742. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72743. directionRandomizer?: number);
  72744. /**
  72745. * Called by the particle System when the direction is computed for the created particle.
  72746. * @param worldMatrix is the world matrix of the particle system
  72747. * @param directionToUpdate is the direction vector to update with the result
  72748. * @param particle is the particle we are computed the direction for
  72749. */
  72750. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72751. /**
  72752. * Called by the particle System when the position is computed for the created particle.
  72753. * @param worldMatrix is the world matrix of the particle system
  72754. * @param positionToUpdate is the position vector to update with the result
  72755. * @param particle is the particle we are computed the position for
  72756. */
  72757. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72758. /**
  72759. * Clones the current emitter and returns a copy of it
  72760. * @returns the new emitter
  72761. */
  72762. clone(): ConeParticleEmitter;
  72763. /**
  72764. * Called by the GPUParticleSystem to setup the update shader
  72765. * @param effect defines the update shader
  72766. */
  72767. applyToShader(effect: Effect): void;
  72768. /**
  72769. * Returns a string to use to update the GPU particles update shader
  72770. * @returns a string containng the defines string
  72771. */
  72772. getEffectDefines(): string;
  72773. /**
  72774. * Returns the string "ConeParticleEmitter"
  72775. * @returns a string containing the class name
  72776. */
  72777. getClassName(): string;
  72778. /**
  72779. * Serializes the particle system to a JSON object.
  72780. * @returns the JSON object
  72781. */
  72782. serialize(): any;
  72783. /**
  72784. * Parse properties from a JSON object
  72785. * @param serializationObject defines the JSON object
  72786. */
  72787. parse(serializationObject: any): void;
  72788. }
  72789. }
  72790. declare module BABYLON {
  72791. /**
  72792. * Particle emitter emitting particles from the inside of a cylinder.
  72793. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  72794. */
  72795. export class CylinderParticleEmitter implements IParticleEmitterType {
  72796. /**
  72797. * The radius of the emission cylinder.
  72798. */
  72799. radius: number;
  72800. /**
  72801. * The height of the emission cylinder.
  72802. */
  72803. height: number;
  72804. /**
  72805. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72806. */
  72807. radiusRange: number;
  72808. /**
  72809. * How much to randomize the particle direction [0-1].
  72810. */
  72811. directionRandomizer: number;
  72812. /**
  72813. * Creates a new instance CylinderParticleEmitter
  72814. * @param radius the radius of the emission cylinder (1 by default)
  72815. * @param height the height of the emission cylinder (1 by default)
  72816. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72817. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72818. */
  72819. constructor(
  72820. /**
  72821. * The radius of the emission cylinder.
  72822. */
  72823. radius?: number,
  72824. /**
  72825. * The height of the emission cylinder.
  72826. */
  72827. height?: number,
  72828. /**
  72829. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72830. */
  72831. radiusRange?: number,
  72832. /**
  72833. * How much to randomize the particle direction [0-1].
  72834. */
  72835. directionRandomizer?: number);
  72836. /**
  72837. * Called by the particle System when the direction is computed for the created particle.
  72838. * @param worldMatrix is the world matrix of the particle system
  72839. * @param directionToUpdate is the direction vector to update with the result
  72840. * @param particle is the particle we are computed the direction for
  72841. */
  72842. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72843. /**
  72844. * Called by the particle System when the position is computed for the created particle.
  72845. * @param worldMatrix is the world matrix of the particle system
  72846. * @param positionToUpdate is the position vector to update with the result
  72847. * @param particle is the particle we are computed the position for
  72848. */
  72849. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72850. /**
  72851. * Clones the current emitter and returns a copy of it
  72852. * @returns the new emitter
  72853. */
  72854. clone(): CylinderParticleEmitter;
  72855. /**
  72856. * Called by the GPUParticleSystem to setup the update shader
  72857. * @param effect defines the update shader
  72858. */
  72859. applyToShader(effect: Effect): void;
  72860. /**
  72861. * Returns a string to use to update the GPU particles update shader
  72862. * @returns a string containng the defines string
  72863. */
  72864. getEffectDefines(): string;
  72865. /**
  72866. * Returns the string "CylinderParticleEmitter"
  72867. * @returns a string containing the class name
  72868. */
  72869. getClassName(): string;
  72870. /**
  72871. * Serializes the particle system to a JSON object.
  72872. * @returns the JSON object
  72873. */
  72874. serialize(): any;
  72875. /**
  72876. * Parse properties from a JSON object
  72877. * @param serializationObject defines the JSON object
  72878. */
  72879. parse(serializationObject: any): void;
  72880. }
  72881. /**
  72882. * Particle emitter emitting particles from the inside of a cylinder.
  72883. * It emits the particles randomly between two vectors.
  72884. */
  72885. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  72886. /**
  72887. * The min limit of the emission direction.
  72888. */
  72889. direction1: Vector3;
  72890. /**
  72891. * The max limit of the emission direction.
  72892. */
  72893. direction2: Vector3;
  72894. /**
  72895. * Creates a new instance CylinderDirectedParticleEmitter
  72896. * @param radius the radius of the emission cylinder (1 by default)
  72897. * @param height the height of the emission cylinder (1 by default)
  72898. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72899. * @param direction1 the min limit of the emission direction (up vector by default)
  72900. * @param direction2 the max limit of the emission direction (up vector by default)
  72901. */
  72902. constructor(radius?: number, height?: number, radiusRange?: number,
  72903. /**
  72904. * The min limit of the emission direction.
  72905. */
  72906. direction1?: Vector3,
  72907. /**
  72908. * The max limit of the emission direction.
  72909. */
  72910. direction2?: Vector3);
  72911. /**
  72912. * Called by the particle System when the direction is computed for the created particle.
  72913. * @param worldMatrix is the world matrix of the particle system
  72914. * @param directionToUpdate is the direction vector to update with the result
  72915. * @param particle is the particle we are computed the direction for
  72916. */
  72917. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72918. /**
  72919. * Clones the current emitter and returns a copy of it
  72920. * @returns the new emitter
  72921. */
  72922. clone(): CylinderDirectedParticleEmitter;
  72923. /**
  72924. * Called by the GPUParticleSystem to setup the update shader
  72925. * @param effect defines the update shader
  72926. */
  72927. applyToShader(effect: Effect): void;
  72928. /**
  72929. * Returns a string to use to update the GPU particles update shader
  72930. * @returns a string containng the defines string
  72931. */
  72932. getEffectDefines(): string;
  72933. /**
  72934. * Returns the string "CylinderDirectedParticleEmitter"
  72935. * @returns a string containing the class name
  72936. */
  72937. getClassName(): string;
  72938. /**
  72939. * Serializes the particle system to a JSON object.
  72940. * @returns the JSON object
  72941. */
  72942. serialize(): any;
  72943. /**
  72944. * Parse properties from a JSON object
  72945. * @param serializationObject defines the JSON object
  72946. */
  72947. parse(serializationObject: any): void;
  72948. }
  72949. }
  72950. declare module BABYLON {
  72951. /**
  72952. * Particle emitter emitting particles from the inside of a hemisphere.
  72953. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  72954. */
  72955. export class HemisphericParticleEmitter implements IParticleEmitterType {
  72956. /**
  72957. * The radius of the emission hemisphere.
  72958. */
  72959. radius: number;
  72960. /**
  72961. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72962. */
  72963. radiusRange: number;
  72964. /**
  72965. * How much to randomize the particle direction [0-1].
  72966. */
  72967. directionRandomizer: number;
  72968. /**
  72969. * Creates a new instance HemisphericParticleEmitter
  72970. * @param radius the radius of the emission hemisphere (1 by default)
  72971. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72972. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72973. */
  72974. constructor(
  72975. /**
  72976. * The radius of the emission hemisphere.
  72977. */
  72978. radius?: number,
  72979. /**
  72980. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72981. */
  72982. radiusRange?: number,
  72983. /**
  72984. * How much to randomize the particle direction [0-1].
  72985. */
  72986. directionRandomizer?: number);
  72987. /**
  72988. * Called by the particle System when the direction is computed for the created particle.
  72989. * @param worldMatrix is the world matrix of the particle system
  72990. * @param directionToUpdate is the direction vector to update with the result
  72991. * @param particle is the particle we are computed the direction for
  72992. */
  72993. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72994. /**
  72995. * Called by the particle System when the position is computed for the created particle.
  72996. * @param worldMatrix is the world matrix of the particle system
  72997. * @param positionToUpdate is the position vector to update with the result
  72998. * @param particle is the particle we are computed the position for
  72999. */
  73000. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73001. /**
  73002. * Clones the current emitter and returns a copy of it
  73003. * @returns the new emitter
  73004. */
  73005. clone(): HemisphericParticleEmitter;
  73006. /**
  73007. * Called by the GPUParticleSystem to setup the update shader
  73008. * @param effect defines the update shader
  73009. */
  73010. applyToShader(effect: Effect): void;
  73011. /**
  73012. * Returns a string to use to update the GPU particles update shader
  73013. * @returns a string containng the defines string
  73014. */
  73015. getEffectDefines(): string;
  73016. /**
  73017. * Returns the string "HemisphericParticleEmitter"
  73018. * @returns a string containing the class name
  73019. */
  73020. getClassName(): string;
  73021. /**
  73022. * Serializes the particle system to a JSON object.
  73023. * @returns the JSON object
  73024. */
  73025. serialize(): any;
  73026. /**
  73027. * Parse properties from a JSON object
  73028. * @param serializationObject defines the JSON object
  73029. */
  73030. parse(serializationObject: any): void;
  73031. }
  73032. }
  73033. declare module BABYLON {
  73034. /**
  73035. * Particle emitter emitting particles from a point.
  73036. * It emits the particles randomly between 2 given directions.
  73037. */
  73038. export class PointParticleEmitter implements IParticleEmitterType {
  73039. /**
  73040. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73041. */
  73042. direction1: Vector3;
  73043. /**
  73044. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73045. */
  73046. direction2: Vector3;
  73047. /**
  73048. * Creates a new instance PointParticleEmitter
  73049. */
  73050. constructor();
  73051. /**
  73052. * Called by the particle System when the direction is computed for the created particle.
  73053. * @param worldMatrix is the world matrix of the particle system
  73054. * @param directionToUpdate is the direction vector to update with the result
  73055. * @param particle is the particle we are computed the direction for
  73056. */
  73057. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73058. /**
  73059. * Called by the particle System when the position is computed for the created particle.
  73060. * @param worldMatrix is the world matrix of the particle system
  73061. * @param positionToUpdate is the position vector to update with the result
  73062. * @param particle is the particle we are computed the position for
  73063. */
  73064. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73065. /**
  73066. * Clones the current emitter and returns a copy of it
  73067. * @returns the new emitter
  73068. */
  73069. clone(): PointParticleEmitter;
  73070. /**
  73071. * Called by the GPUParticleSystem to setup the update shader
  73072. * @param effect defines the update shader
  73073. */
  73074. applyToShader(effect: Effect): void;
  73075. /**
  73076. * Returns a string to use to update the GPU particles update shader
  73077. * @returns a string containng the defines string
  73078. */
  73079. getEffectDefines(): string;
  73080. /**
  73081. * Returns the string "PointParticleEmitter"
  73082. * @returns a string containing the class name
  73083. */
  73084. getClassName(): string;
  73085. /**
  73086. * Serializes the particle system to a JSON object.
  73087. * @returns the JSON object
  73088. */
  73089. serialize(): any;
  73090. /**
  73091. * Parse properties from a JSON object
  73092. * @param serializationObject defines the JSON object
  73093. */
  73094. parse(serializationObject: any): void;
  73095. }
  73096. }
  73097. declare module BABYLON {
  73098. /**
  73099. * Particle emitter emitting particles from the inside of a sphere.
  73100. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  73101. */
  73102. export class SphereParticleEmitter implements IParticleEmitterType {
  73103. /**
  73104. * The radius of the emission sphere.
  73105. */
  73106. radius: number;
  73107. /**
  73108. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73109. */
  73110. radiusRange: number;
  73111. /**
  73112. * How much to randomize the particle direction [0-1].
  73113. */
  73114. directionRandomizer: number;
  73115. /**
  73116. * Creates a new instance SphereParticleEmitter
  73117. * @param radius the radius of the emission sphere (1 by default)
  73118. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73119. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73120. */
  73121. constructor(
  73122. /**
  73123. * The radius of the emission sphere.
  73124. */
  73125. radius?: number,
  73126. /**
  73127. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73128. */
  73129. radiusRange?: number,
  73130. /**
  73131. * How much to randomize the particle direction [0-1].
  73132. */
  73133. directionRandomizer?: number);
  73134. /**
  73135. * Called by the particle System when the direction is computed for the created particle.
  73136. * @param worldMatrix is the world matrix of the particle system
  73137. * @param directionToUpdate is the direction vector to update with the result
  73138. * @param particle is the particle we are computed the direction for
  73139. */
  73140. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73141. /**
  73142. * Called by the particle System when the position is computed for the created particle.
  73143. * @param worldMatrix is the world matrix of the particle system
  73144. * @param positionToUpdate is the position vector to update with the result
  73145. * @param particle is the particle we are computed the position for
  73146. */
  73147. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73148. /**
  73149. * Clones the current emitter and returns a copy of it
  73150. * @returns the new emitter
  73151. */
  73152. clone(): SphereParticleEmitter;
  73153. /**
  73154. * Called by the GPUParticleSystem to setup the update shader
  73155. * @param effect defines the update shader
  73156. */
  73157. applyToShader(effect: Effect): void;
  73158. /**
  73159. * Returns a string to use to update the GPU particles update shader
  73160. * @returns a string containng the defines string
  73161. */
  73162. getEffectDefines(): string;
  73163. /**
  73164. * Returns the string "SphereParticleEmitter"
  73165. * @returns a string containing the class name
  73166. */
  73167. getClassName(): string;
  73168. /**
  73169. * Serializes the particle system to a JSON object.
  73170. * @returns the JSON object
  73171. */
  73172. serialize(): any;
  73173. /**
  73174. * Parse properties from a JSON object
  73175. * @param serializationObject defines the JSON object
  73176. */
  73177. parse(serializationObject: any): void;
  73178. }
  73179. /**
  73180. * Particle emitter emitting particles from the inside of a sphere.
  73181. * It emits the particles randomly between two vectors.
  73182. */
  73183. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  73184. /**
  73185. * The min limit of the emission direction.
  73186. */
  73187. direction1: Vector3;
  73188. /**
  73189. * The max limit of the emission direction.
  73190. */
  73191. direction2: Vector3;
  73192. /**
  73193. * Creates a new instance SphereDirectedParticleEmitter
  73194. * @param radius the radius of the emission sphere (1 by default)
  73195. * @param direction1 the min limit of the emission direction (up vector by default)
  73196. * @param direction2 the max limit of the emission direction (up vector by default)
  73197. */
  73198. constructor(radius?: number,
  73199. /**
  73200. * The min limit of the emission direction.
  73201. */
  73202. direction1?: Vector3,
  73203. /**
  73204. * The max limit of the emission direction.
  73205. */
  73206. direction2?: Vector3);
  73207. /**
  73208. * Called by the particle System when the direction is computed for the created particle.
  73209. * @param worldMatrix is the world matrix of the particle system
  73210. * @param directionToUpdate is the direction vector to update with the result
  73211. * @param particle is the particle we are computed the direction for
  73212. */
  73213. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73214. /**
  73215. * Clones the current emitter and returns a copy of it
  73216. * @returns the new emitter
  73217. */
  73218. clone(): SphereDirectedParticleEmitter;
  73219. /**
  73220. * Called by the GPUParticleSystem to setup the update shader
  73221. * @param effect defines the update shader
  73222. */
  73223. applyToShader(effect: Effect): void;
  73224. /**
  73225. * Returns a string to use to update the GPU particles update shader
  73226. * @returns a string containng the defines string
  73227. */
  73228. getEffectDefines(): string;
  73229. /**
  73230. * Returns the string "SphereDirectedParticleEmitter"
  73231. * @returns a string containing the class name
  73232. */
  73233. getClassName(): string;
  73234. /**
  73235. * Serializes the particle system to a JSON object.
  73236. * @returns the JSON object
  73237. */
  73238. serialize(): any;
  73239. /**
  73240. * Parse properties from a JSON object
  73241. * @param serializationObject defines the JSON object
  73242. */
  73243. parse(serializationObject: any): void;
  73244. }
  73245. }
  73246. declare module BABYLON {
  73247. /**
  73248. * Interface representing a particle system in Babylon.js.
  73249. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  73250. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  73251. */
  73252. export interface IParticleSystem {
  73253. /**
  73254. * List of animations used by the particle system.
  73255. */
  73256. animations: Animation[];
  73257. /**
  73258. * The id of the Particle system.
  73259. */
  73260. id: string;
  73261. /**
  73262. * The name of the Particle system.
  73263. */
  73264. name: string;
  73265. /**
  73266. * The emitter represents the Mesh or position we are attaching the particle system to.
  73267. */
  73268. emitter: Nullable<AbstractMesh | Vector3>;
  73269. /**
  73270. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73271. */
  73272. isBillboardBased: boolean;
  73273. /**
  73274. * The rendering group used by the Particle system to chose when to render.
  73275. */
  73276. renderingGroupId: number;
  73277. /**
  73278. * The layer mask we are rendering the particles through.
  73279. */
  73280. layerMask: number;
  73281. /**
  73282. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73283. */
  73284. updateSpeed: number;
  73285. /**
  73286. * The amount of time the particle system is running (depends of the overall update speed).
  73287. */
  73288. targetStopDuration: number;
  73289. /**
  73290. * The texture used to render each particle. (this can be a spritesheet)
  73291. */
  73292. particleTexture: Nullable<Texture>;
  73293. /**
  73294. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  73295. */
  73296. blendMode: number;
  73297. /**
  73298. * Minimum life time of emitting particles.
  73299. */
  73300. minLifeTime: number;
  73301. /**
  73302. * Maximum life time of emitting particles.
  73303. */
  73304. maxLifeTime: number;
  73305. /**
  73306. * Minimum Size of emitting particles.
  73307. */
  73308. minSize: number;
  73309. /**
  73310. * Maximum Size of emitting particles.
  73311. */
  73312. maxSize: number;
  73313. /**
  73314. * Minimum scale of emitting particles on X axis.
  73315. */
  73316. minScaleX: number;
  73317. /**
  73318. * Maximum scale of emitting particles on X axis.
  73319. */
  73320. maxScaleX: number;
  73321. /**
  73322. * Minimum scale of emitting particles on Y axis.
  73323. */
  73324. minScaleY: number;
  73325. /**
  73326. * Maximum scale of emitting particles on Y axis.
  73327. */
  73328. maxScaleY: number;
  73329. /**
  73330. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73331. */
  73332. color1: Color4;
  73333. /**
  73334. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73335. */
  73336. color2: Color4;
  73337. /**
  73338. * Color the particle will have at the end of its lifetime.
  73339. */
  73340. colorDead: Color4;
  73341. /**
  73342. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  73343. */
  73344. emitRate: number;
  73345. /**
  73346. * You can use gravity if you want to give an orientation to your particles.
  73347. */
  73348. gravity: Vector3;
  73349. /**
  73350. * Minimum power of emitting particles.
  73351. */
  73352. minEmitPower: number;
  73353. /**
  73354. * Maximum power of emitting particles.
  73355. */
  73356. maxEmitPower: number;
  73357. /**
  73358. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73359. */
  73360. minAngularSpeed: number;
  73361. /**
  73362. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73363. */
  73364. maxAngularSpeed: number;
  73365. /**
  73366. * Gets or sets the minimal initial rotation in radians.
  73367. */
  73368. minInitialRotation: number;
  73369. /**
  73370. * Gets or sets the maximal initial rotation in radians.
  73371. */
  73372. maxInitialRotation: number;
  73373. /**
  73374. * The particle emitter type defines the emitter used by the particle system.
  73375. * It can be for example box, sphere, or cone...
  73376. */
  73377. particleEmitterType: Nullable<IParticleEmitterType>;
  73378. /**
  73379. * Defines the delay in milliseconds before starting the system (0 by default)
  73380. */
  73381. startDelay: number;
  73382. /**
  73383. * 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
  73384. */
  73385. preWarmCycles: number;
  73386. /**
  73387. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  73388. */
  73389. preWarmStepOffset: number;
  73390. /**
  73391. * 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)
  73392. */
  73393. spriteCellChangeSpeed: number;
  73394. /**
  73395. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73396. */
  73397. startSpriteCellID: number;
  73398. /**
  73399. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73400. */
  73401. endSpriteCellID: number;
  73402. /**
  73403. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73404. */
  73405. spriteCellWidth: number;
  73406. /**
  73407. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73408. */
  73409. spriteCellHeight: number;
  73410. /**
  73411. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73412. */
  73413. spriteRandomStartCell: boolean;
  73414. /**
  73415. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  73416. */
  73417. isAnimationSheetEnabled: boolean;
  73418. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73419. translationPivot: Vector2;
  73420. /**
  73421. * Gets or sets a texture used to add random noise to particle positions
  73422. */
  73423. noiseTexture: Nullable<BaseTexture>;
  73424. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73425. noiseStrength: Vector3;
  73426. /**
  73427. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73428. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73429. */
  73430. billboardMode: number;
  73431. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73432. limitVelocityDamping: number;
  73433. /**
  73434. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73435. */
  73436. beginAnimationOnStart: boolean;
  73437. /**
  73438. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73439. */
  73440. beginAnimationFrom: number;
  73441. /**
  73442. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73443. */
  73444. beginAnimationTo: number;
  73445. /**
  73446. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73447. */
  73448. beginAnimationLoop: boolean;
  73449. /**
  73450. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73451. */
  73452. disposeOnStop: boolean;
  73453. /**
  73454. * Gets the maximum number of particles active at the same time.
  73455. * @returns The max number of active particles.
  73456. */
  73457. getCapacity(): number;
  73458. /**
  73459. * Gets if the system has been started. (Note: this will still be true after stop is called)
  73460. * @returns True if it has been started, otherwise false.
  73461. */
  73462. isStarted(): boolean;
  73463. /**
  73464. * Animates the particle system for this frame.
  73465. */
  73466. animate(): void;
  73467. /**
  73468. * Renders the particle system in its current state.
  73469. * @returns the current number of particles
  73470. */
  73471. render(): number;
  73472. /**
  73473. * Dispose the particle system and frees its associated resources.
  73474. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73475. */
  73476. dispose(disposeTexture?: boolean): void;
  73477. /**
  73478. * Clones the particle system.
  73479. * @param name The name of the cloned object
  73480. * @param newEmitter The new emitter to use
  73481. * @returns the cloned particle system
  73482. */
  73483. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  73484. /**
  73485. * Serializes the particle system to a JSON object.
  73486. * @returns the JSON object
  73487. */
  73488. serialize(): any;
  73489. /**
  73490. * Rebuild the particle system
  73491. */
  73492. rebuild(): void;
  73493. /**
  73494. * Starts the particle system and begins to emit
  73495. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  73496. */
  73497. start(delay?: number): void;
  73498. /**
  73499. * Stops the particle system.
  73500. */
  73501. stop(): void;
  73502. /**
  73503. * Remove all active particles
  73504. */
  73505. reset(): void;
  73506. /**
  73507. * Is this system ready to be used/rendered
  73508. * @return true if the system is ready
  73509. */
  73510. isReady(): boolean;
  73511. /**
  73512. * Adds a new color gradient
  73513. * @param gradient defines the gradient to use (between 0 and 1)
  73514. * @param color1 defines the color to affect to the specified gradient
  73515. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73516. * @returns the current particle system
  73517. */
  73518. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  73519. /**
  73520. * Remove a specific color gradient
  73521. * @param gradient defines the gradient to remove
  73522. * @returns the current particle system
  73523. */
  73524. removeColorGradient(gradient: number): IParticleSystem;
  73525. /**
  73526. * Adds a new size gradient
  73527. * @param gradient defines the gradient to use (between 0 and 1)
  73528. * @param factor defines the size factor to affect to the specified gradient
  73529. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73530. * @returns the current particle system
  73531. */
  73532. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73533. /**
  73534. * Remove a specific size gradient
  73535. * @param gradient defines the gradient to remove
  73536. * @returns the current particle system
  73537. */
  73538. removeSizeGradient(gradient: number): IParticleSystem;
  73539. /**
  73540. * Gets the current list of color gradients.
  73541. * You must use addColorGradient and removeColorGradient to udpate this list
  73542. * @returns the list of color gradients
  73543. */
  73544. getColorGradients(): Nullable<Array<ColorGradient>>;
  73545. /**
  73546. * Gets the current list of size gradients.
  73547. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73548. * @returns the list of size gradients
  73549. */
  73550. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73551. /**
  73552. * Gets the current list of angular speed gradients.
  73553. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73554. * @returns the list of angular speed gradients
  73555. */
  73556. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73557. /**
  73558. * Adds a new angular speed gradient
  73559. * @param gradient defines the gradient to use (between 0 and 1)
  73560. * @param factor defines the angular speed to affect to the specified gradient
  73561. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73562. * @returns the current particle system
  73563. */
  73564. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73565. /**
  73566. * Remove a specific angular speed gradient
  73567. * @param gradient defines the gradient to remove
  73568. * @returns the current particle system
  73569. */
  73570. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73571. /**
  73572. * Gets the current list of velocity gradients.
  73573. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73574. * @returns the list of velocity gradients
  73575. */
  73576. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73577. /**
  73578. * Adds a new velocity gradient
  73579. * @param gradient defines the gradient to use (between 0 and 1)
  73580. * @param factor defines the velocity to affect to the specified gradient
  73581. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73582. * @returns the current particle system
  73583. */
  73584. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73585. /**
  73586. * Remove a specific velocity gradient
  73587. * @param gradient defines the gradient to remove
  73588. * @returns the current particle system
  73589. */
  73590. removeVelocityGradient(gradient: number): IParticleSystem;
  73591. /**
  73592. * Gets the current list of limit velocity gradients.
  73593. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73594. * @returns the list of limit velocity gradients
  73595. */
  73596. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73597. /**
  73598. * Adds a new limit velocity gradient
  73599. * @param gradient defines the gradient to use (between 0 and 1)
  73600. * @param factor defines the limit velocity to affect to the specified gradient
  73601. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73602. * @returns the current particle system
  73603. */
  73604. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73605. /**
  73606. * Remove a specific limit velocity gradient
  73607. * @param gradient defines the gradient to remove
  73608. * @returns the current particle system
  73609. */
  73610. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  73611. /**
  73612. * Adds a new drag gradient
  73613. * @param gradient defines the gradient to use (between 0 and 1)
  73614. * @param factor defines the drag to affect to the specified gradient
  73615. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73616. * @returns the current particle system
  73617. */
  73618. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73619. /**
  73620. * Remove a specific drag gradient
  73621. * @param gradient defines the gradient to remove
  73622. * @returns the current particle system
  73623. */
  73624. removeDragGradient(gradient: number): IParticleSystem;
  73625. /**
  73626. * Gets the current list of drag gradients.
  73627. * You must use addDragGradient and removeDragGradient to udpate this list
  73628. * @returns the list of drag gradients
  73629. */
  73630. getDragGradients(): Nullable<Array<FactorGradient>>;
  73631. /**
  73632. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  73633. * @param gradient defines the gradient to use (between 0 and 1)
  73634. * @param factor defines the emit rate to affect to the specified gradient
  73635. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73636. * @returns the current particle system
  73637. */
  73638. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73639. /**
  73640. * Remove a specific emit rate gradient
  73641. * @param gradient defines the gradient to remove
  73642. * @returns the current particle system
  73643. */
  73644. removeEmitRateGradient(gradient: number): IParticleSystem;
  73645. /**
  73646. * Gets the current list of emit rate gradients.
  73647. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73648. * @returns the list of emit rate gradients
  73649. */
  73650. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73651. /**
  73652. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  73653. * @param gradient defines the gradient to use (between 0 and 1)
  73654. * @param factor defines the start size to affect to the specified gradient
  73655. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73656. * @returns the current particle system
  73657. */
  73658. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73659. /**
  73660. * Remove a specific start size gradient
  73661. * @param gradient defines the gradient to remove
  73662. * @returns the current particle system
  73663. */
  73664. removeStartSizeGradient(gradient: number): IParticleSystem;
  73665. /**
  73666. * Gets the current list of start size gradients.
  73667. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73668. * @returns the list of start size gradients
  73669. */
  73670. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73671. /**
  73672. * Adds a new life time gradient
  73673. * @param gradient defines the gradient to use (between 0 and 1)
  73674. * @param factor defines the life time factor to affect to the specified gradient
  73675. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73676. * @returns the current particle system
  73677. */
  73678. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73679. /**
  73680. * Remove a specific life time gradient
  73681. * @param gradient defines the gradient to remove
  73682. * @returns the current particle system
  73683. */
  73684. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73685. /**
  73686. * Gets the current list of life time gradients.
  73687. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73688. * @returns the list of life time gradients
  73689. */
  73690. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73691. /**
  73692. * Gets the current list of color gradients.
  73693. * You must use addColorGradient and removeColorGradient to udpate this list
  73694. * @returns the list of color gradients
  73695. */
  73696. getColorGradients(): Nullable<Array<ColorGradient>>;
  73697. /**
  73698. * Adds a new ramp gradient used to remap particle colors
  73699. * @param gradient defines the gradient to use (between 0 and 1)
  73700. * @param color defines the color to affect to the specified gradient
  73701. * @returns the current particle system
  73702. */
  73703. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  73704. /**
  73705. * Gets the current list of ramp gradients.
  73706. * You must use addRampGradient and removeRampGradient to udpate this list
  73707. * @returns the list of ramp gradients
  73708. */
  73709. getRampGradients(): Nullable<Array<Color3Gradient>>;
  73710. /** Gets or sets a boolean indicating that ramp gradients must be used
  73711. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73712. */
  73713. useRampGradients: boolean;
  73714. /**
  73715. * Adds a new color remap gradient
  73716. * @param gradient defines the gradient to use (between 0 and 1)
  73717. * @param min defines the color remap minimal range
  73718. * @param max defines the color remap maximal range
  73719. * @returns the current particle system
  73720. */
  73721. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73722. /**
  73723. * Gets the current list of color remap gradients.
  73724. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73725. * @returns the list of color remap gradients
  73726. */
  73727. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73728. /**
  73729. * Adds a new alpha remap gradient
  73730. * @param gradient defines the gradient to use (between 0 and 1)
  73731. * @param min defines the alpha remap minimal range
  73732. * @param max defines the alpha remap maximal range
  73733. * @returns the current particle system
  73734. */
  73735. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73736. /**
  73737. * Gets the current list of alpha remap gradients.
  73738. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73739. * @returns the list of alpha remap gradients
  73740. */
  73741. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73742. /**
  73743. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73744. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73745. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73746. * @returns the emitter
  73747. */
  73748. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73749. /**
  73750. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73751. * @param radius The radius of the hemisphere to emit from
  73752. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73753. * @returns the emitter
  73754. */
  73755. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  73756. /**
  73757. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73758. * @param radius The radius of the sphere to emit from
  73759. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73760. * @returns the emitter
  73761. */
  73762. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  73763. /**
  73764. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73765. * @param radius The radius of the sphere to emit from
  73766. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73767. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73768. * @returns the emitter
  73769. */
  73770. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73771. /**
  73772. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73773. * @param radius The radius of the emission cylinder
  73774. * @param height The height of the emission cylinder
  73775. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73776. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73777. * @returns the emitter
  73778. */
  73779. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  73780. /**
  73781. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73782. * @param radius The radius of the cylinder to emit from
  73783. * @param height The height of the emission cylinder
  73784. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73785. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73786. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73787. * @returns the emitter
  73788. */
  73789. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73790. /**
  73791. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73792. * @param radius The radius of the cone to emit from
  73793. * @param angle The base angle of the cone
  73794. * @returns the emitter
  73795. */
  73796. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  73797. /**
  73798. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73799. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73800. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73801. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73802. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73803. * @returns the emitter
  73804. */
  73805. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73806. /**
  73807. * Get hosting scene
  73808. * @returns the scene
  73809. */
  73810. getScene(): Scene;
  73811. }
  73812. }
  73813. declare module BABYLON {
  73814. /**
  73815. * Creates an instance based on a source mesh.
  73816. */
  73817. export class InstancedMesh extends AbstractMesh {
  73818. private _sourceMesh;
  73819. private _currentLOD;
  73820. /** @hidden */
  73821. _indexInSourceMeshInstanceArray: number;
  73822. constructor(name: string, source: Mesh);
  73823. /**
  73824. * Returns the string "InstancedMesh".
  73825. */
  73826. getClassName(): string;
  73827. /**
  73828. * If the source mesh receives shadows
  73829. */
  73830. readonly receiveShadows: boolean;
  73831. /**
  73832. * The material of the source mesh
  73833. */
  73834. readonly material: Nullable<Material>;
  73835. /**
  73836. * Visibility of the source mesh
  73837. */
  73838. readonly visibility: number;
  73839. /**
  73840. * Skeleton of the source mesh
  73841. */
  73842. readonly skeleton: Nullable<Skeleton>;
  73843. /**
  73844. * Rendering ground id of the source mesh
  73845. */
  73846. renderingGroupId: number;
  73847. /**
  73848. * Returns the total number of vertices (integer).
  73849. */
  73850. getTotalVertices(): number;
  73851. /**
  73852. * Returns a positive integer : the total number of indices in this mesh geometry.
  73853. * @returns the numner of indices or zero if the mesh has no geometry.
  73854. */
  73855. getTotalIndices(): number;
  73856. /**
  73857. * The source mesh of the instance
  73858. */
  73859. readonly sourceMesh: Mesh;
  73860. /**
  73861. * Is this node ready to be used/rendered
  73862. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  73863. * @return {boolean} is it ready
  73864. */
  73865. isReady(completeCheck?: boolean): boolean;
  73866. /**
  73867. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  73868. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  73869. * @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.
  73870. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  73871. */
  73872. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  73873. /**
  73874. * Sets the vertex data of the mesh geometry for the requested `kind`.
  73875. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  73876. * The `data` are either a numeric array either a Float32Array.
  73877. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  73878. * 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).
  73879. * Note that a new underlying VertexBuffer object is created each call.
  73880. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  73881. *
  73882. * Possible `kind` values :
  73883. * - VertexBuffer.PositionKind
  73884. * - VertexBuffer.UVKind
  73885. * - VertexBuffer.UV2Kind
  73886. * - VertexBuffer.UV3Kind
  73887. * - VertexBuffer.UV4Kind
  73888. * - VertexBuffer.UV5Kind
  73889. * - VertexBuffer.UV6Kind
  73890. * - VertexBuffer.ColorKind
  73891. * - VertexBuffer.MatricesIndicesKind
  73892. * - VertexBuffer.MatricesIndicesExtraKind
  73893. * - VertexBuffer.MatricesWeightsKind
  73894. * - VertexBuffer.MatricesWeightsExtraKind
  73895. *
  73896. * Returns the Mesh.
  73897. */
  73898. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  73899. /**
  73900. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  73901. * If the mesh has no geometry, it is simply returned as it is.
  73902. * The `data` are either a numeric array either a Float32Array.
  73903. * No new underlying VertexBuffer object is created.
  73904. * 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.
  73905. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  73906. *
  73907. * Possible `kind` values :
  73908. * - VertexBuffer.PositionKind
  73909. * - VertexBuffer.UVKind
  73910. * - VertexBuffer.UV2Kind
  73911. * - VertexBuffer.UV3Kind
  73912. * - VertexBuffer.UV4Kind
  73913. * - VertexBuffer.UV5Kind
  73914. * - VertexBuffer.UV6Kind
  73915. * - VertexBuffer.ColorKind
  73916. * - VertexBuffer.MatricesIndicesKind
  73917. * - VertexBuffer.MatricesIndicesExtraKind
  73918. * - VertexBuffer.MatricesWeightsKind
  73919. * - VertexBuffer.MatricesWeightsExtraKind
  73920. *
  73921. * Returns the Mesh.
  73922. */
  73923. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  73924. /**
  73925. * Sets the mesh indices.
  73926. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  73927. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  73928. * This method creates a new index buffer each call.
  73929. * Returns the Mesh.
  73930. */
  73931. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  73932. /**
  73933. * Boolean : True if the mesh owns the requested kind of data.
  73934. */
  73935. isVerticesDataPresent(kind: string): boolean;
  73936. /**
  73937. * Returns an array of indices (IndicesArray).
  73938. */
  73939. getIndices(): Nullable<IndicesArray>;
  73940. readonly _positions: Nullable<Vector3[]>;
  73941. /**
  73942. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  73943. * This means the mesh underlying bounding box and sphere are recomputed.
  73944. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  73945. * @returns the current mesh
  73946. */
  73947. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  73948. /** @hidden */
  73949. _preActivate(): InstancedMesh;
  73950. /** @hidden */
  73951. _activate(renderId: number): InstancedMesh;
  73952. /**
  73953. * Returns the current associated LOD AbstractMesh.
  73954. */
  73955. getLOD(camera: Camera): AbstractMesh;
  73956. /** @hidden */
  73957. _syncSubMeshes(): InstancedMesh;
  73958. /** @hidden */
  73959. _generatePointsArray(): boolean;
  73960. /**
  73961. * Creates a new InstancedMesh from the current mesh.
  73962. * - name (string) : the cloned mesh name
  73963. * - newParent (optional Node) : the optional Node to parent the clone to.
  73964. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  73965. *
  73966. * Returns the clone.
  73967. */
  73968. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  73969. /**
  73970. * Disposes the InstancedMesh.
  73971. * Returns nothing.
  73972. */
  73973. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  73974. }
  73975. }
  73976. declare module BABYLON {
  73977. /**
  73978. * Defines the options associated with the creation of a shader material.
  73979. */
  73980. export interface IShaderMaterialOptions {
  73981. /**
  73982. * Does the material work in alpha blend mode
  73983. */
  73984. needAlphaBlending: boolean;
  73985. /**
  73986. * Does the material work in alpha test mode
  73987. */
  73988. needAlphaTesting: boolean;
  73989. /**
  73990. * The list of attribute names used in the shader
  73991. */
  73992. attributes: string[];
  73993. /**
  73994. * The list of unifrom names used in the shader
  73995. */
  73996. uniforms: string[];
  73997. /**
  73998. * The list of UBO names used in the shader
  73999. */
  74000. uniformBuffers: string[];
  74001. /**
  74002. * The list of sampler names used in the shader
  74003. */
  74004. samplers: string[];
  74005. /**
  74006. * The list of defines used in the shader
  74007. */
  74008. defines: string[];
  74009. }
  74010. /**
  74011. * 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.
  74012. *
  74013. * This returned material effects how the mesh will look based on the code in the shaders.
  74014. *
  74015. * @see http://doc.babylonjs.com/how_to/shader_material
  74016. */
  74017. export class ShaderMaterial extends Material {
  74018. private _shaderPath;
  74019. private _options;
  74020. private _textures;
  74021. private _textureArrays;
  74022. private _floats;
  74023. private _ints;
  74024. private _floatsArrays;
  74025. private _colors3;
  74026. private _colors3Arrays;
  74027. private _colors4;
  74028. private _vectors2;
  74029. private _vectors3;
  74030. private _vectors4;
  74031. private _matrices;
  74032. private _matrices3x3;
  74033. private _matrices2x2;
  74034. private _vectors2Arrays;
  74035. private _vectors3Arrays;
  74036. private _cachedWorldViewMatrix;
  74037. private _renderId;
  74038. /**
  74039. * Instantiate a new shader material.
  74040. * 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.
  74041. * This returned material effects how the mesh will look based on the code in the shaders.
  74042. * @see http://doc.babylonjs.com/how_to/shader_material
  74043. * @param name Define the name of the material in the scene
  74044. * @param scene Define the scene the material belongs to
  74045. * @param shaderPath Defines the route to the shader code in one of three ways:
  74046. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  74047. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  74048. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  74049. * @param options Define the options used to create the shader
  74050. */
  74051. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  74052. /**
  74053. * Gets the current class name of the material e.g. "ShaderMaterial"
  74054. * Mainly use in serialization.
  74055. * @returns the class name
  74056. */
  74057. getClassName(): string;
  74058. /**
  74059. * Specifies if the material will require alpha blending
  74060. * @returns a boolean specifying if alpha blending is needed
  74061. */
  74062. needAlphaBlending(): boolean;
  74063. /**
  74064. * Specifies if this material should be rendered in alpha test mode
  74065. * @returns a boolean specifying if an alpha test is needed.
  74066. */
  74067. needAlphaTesting(): boolean;
  74068. private _checkUniform;
  74069. /**
  74070. * Set a texture in the shader.
  74071. * @param name Define the name of the uniform samplers as defined in the shader
  74072. * @param texture Define the texture to bind to this sampler
  74073. * @return the material itself allowing "fluent" like uniform updates
  74074. */
  74075. setTexture(name: string, texture: Texture): ShaderMaterial;
  74076. /**
  74077. * Set a texture array in the shader.
  74078. * @param name Define the name of the uniform sampler array as defined in the shader
  74079. * @param textures Define the list of textures to bind to this sampler
  74080. * @return the material itself allowing "fluent" like uniform updates
  74081. */
  74082. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  74083. /**
  74084. * Set a float in the shader.
  74085. * @param name Define the name of the uniform as defined in the shader
  74086. * @param value Define the value to give to the uniform
  74087. * @return the material itself allowing "fluent" like uniform updates
  74088. */
  74089. setFloat(name: string, value: number): ShaderMaterial;
  74090. /**
  74091. * Set a int in the shader.
  74092. * @param name Define the name of the uniform as defined in the shader
  74093. * @param value Define the value to give to the uniform
  74094. * @return the material itself allowing "fluent" like uniform updates
  74095. */
  74096. setInt(name: string, value: number): ShaderMaterial;
  74097. /**
  74098. * Set an array of floats in the shader.
  74099. * @param name Define the name of the uniform as defined in the shader
  74100. * @param value Define the value to give to the uniform
  74101. * @return the material itself allowing "fluent" like uniform updates
  74102. */
  74103. setFloats(name: string, value: number[]): ShaderMaterial;
  74104. /**
  74105. * Set a vec3 in the shader from a Color3.
  74106. * @param name Define the name of the uniform as defined in the shader
  74107. * @param value Define the value to give to the uniform
  74108. * @return the material itself allowing "fluent" like uniform updates
  74109. */
  74110. setColor3(name: string, value: Color3): ShaderMaterial;
  74111. /**
  74112. * Set a vec3 array in the shader from a Color3 array.
  74113. * @param name Define the name of the uniform as defined in the shader
  74114. * @param value Define the value to give to the uniform
  74115. * @return the material itself allowing "fluent" like uniform updates
  74116. */
  74117. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  74118. /**
  74119. * Set a vec4 in the shader from a Color4.
  74120. * @param name Define the name of the uniform as defined in the shader
  74121. * @param value Define the value to give to the uniform
  74122. * @return the material itself allowing "fluent" like uniform updates
  74123. */
  74124. setColor4(name: string, value: Color4): ShaderMaterial;
  74125. /**
  74126. * Set a vec2 in the shader from a Vector2.
  74127. * @param name Define the name of the uniform as defined in the shader
  74128. * @param value Define the value to give to the uniform
  74129. * @return the material itself allowing "fluent" like uniform updates
  74130. */
  74131. setVector2(name: string, value: Vector2): ShaderMaterial;
  74132. /**
  74133. * Set a vec3 in the shader from a Vector3.
  74134. * @param name Define the name of the uniform as defined in the shader
  74135. * @param value Define the value to give to the uniform
  74136. * @return the material itself allowing "fluent" like uniform updates
  74137. */
  74138. setVector3(name: string, value: Vector3): ShaderMaterial;
  74139. /**
  74140. * Set a vec4 in the shader from a Vector4.
  74141. * @param name Define the name of the uniform as defined in the shader
  74142. * @param value Define the value to give to the uniform
  74143. * @return the material itself allowing "fluent" like uniform updates
  74144. */
  74145. setVector4(name: string, value: Vector4): ShaderMaterial;
  74146. /**
  74147. * Set a mat4 in the shader from a Matrix.
  74148. * @param name Define the name of the uniform as defined in the shader
  74149. * @param value Define the value to give to the uniform
  74150. * @return the material itself allowing "fluent" like uniform updates
  74151. */
  74152. setMatrix(name: string, value: Matrix): ShaderMaterial;
  74153. /**
  74154. * Set a mat3 in the shader from a Float32Array.
  74155. * @param name Define the name of the uniform as defined in the shader
  74156. * @param value Define the value to give to the uniform
  74157. * @return the material itself allowing "fluent" like uniform updates
  74158. */
  74159. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  74160. /**
  74161. * Set a mat2 in the shader from a Float32Array.
  74162. * @param name Define the name of the uniform as defined in the shader
  74163. * @param value Define the value to give to the uniform
  74164. * @return the material itself allowing "fluent" like uniform updates
  74165. */
  74166. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  74167. /**
  74168. * Set a vec2 array in the shader from a number array.
  74169. * @param name Define the name of the uniform as defined in the shader
  74170. * @param value Define the value to give to the uniform
  74171. * @return the material itself allowing "fluent" like uniform updates
  74172. */
  74173. setArray2(name: string, value: number[]): ShaderMaterial;
  74174. /**
  74175. * Set a vec3 array in the shader from a number array.
  74176. * @param name Define the name of the uniform as defined in the shader
  74177. * @param value Define the value to give to the uniform
  74178. * @return the material itself allowing "fluent" like uniform updates
  74179. */
  74180. setArray3(name: string, value: number[]): ShaderMaterial;
  74181. private _checkCache;
  74182. /**
  74183. * Checks if the material is ready to render the requested mesh
  74184. * @param mesh Define the mesh to render
  74185. * @param useInstances Define whether or not the material is used with instances
  74186. * @returns true if ready, otherwise false
  74187. */
  74188. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  74189. /**
  74190. * Binds the world matrix to the material
  74191. * @param world defines the world transformation matrix
  74192. */
  74193. bindOnlyWorldMatrix(world: Matrix): void;
  74194. /**
  74195. * Binds the material to the mesh
  74196. * @param world defines the world transformation matrix
  74197. * @param mesh defines the mesh to bind the material to
  74198. */
  74199. bind(world: Matrix, mesh?: Mesh): void;
  74200. /**
  74201. * Gets the active textures from the material
  74202. * @returns an array of textures
  74203. */
  74204. getActiveTextures(): BaseTexture[];
  74205. /**
  74206. * Specifies if the material uses a texture
  74207. * @param texture defines the texture to check against the material
  74208. * @returns a boolean specifying if the material uses the texture
  74209. */
  74210. hasTexture(texture: BaseTexture): boolean;
  74211. /**
  74212. * Makes a duplicate of the material, and gives it a new name
  74213. * @param name defines the new name for the duplicated material
  74214. * @returns the cloned material
  74215. */
  74216. clone(name: string): ShaderMaterial;
  74217. /**
  74218. * Disposes the material
  74219. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  74220. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  74221. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  74222. */
  74223. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  74224. /**
  74225. * Serializes this material in a JSON representation
  74226. * @returns the serialized material object
  74227. */
  74228. serialize(): any;
  74229. /**
  74230. * Creates a shader material from parsed shader material data
  74231. * @param source defines the JSON represnetation of the material
  74232. * @param scene defines the hosting scene
  74233. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  74234. * @returns a new material
  74235. */
  74236. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  74237. }
  74238. }
  74239. declare module BABYLON {
  74240. /** @hidden */
  74241. export var colorPixelShader: {
  74242. name: string;
  74243. shader: string;
  74244. };
  74245. }
  74246. declare module BABYLON {
  74247. /** @hidden */
  74248. export var colorVertexShader: {
  74249. name: string;
  74250. shader: string;
  74251. };
  74252. }
  74253. declare module BABYLON {
  74254. /**
  74255. * Line mesh
  74256. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  74257. */
  74258. export class LinesMesh extends Mesh {
  74259. /**
  74260. * If vertex color should be applied to the mesh
  74261. */
  74262. useVertexColor?: boolean | undefined;
  74263. /**
  74264. * If vertex alpha should be applied to the mesh
  74265. */
  74266. useVertexAlpha?: boolean | undefined;
  74267. /**
  74268. * Color of the line (Default: White)
  74269. */
  74270. color: Color3;
  74271. /**
  74272. * Alpha of the line (Default: 1)
  74273. */
  74274. alpha: number;
  74275. /**
  74276. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74277. * This margin is expressed in world space coordinates, so its value may vary.
  74278. * Default value is 0.1
  74279. */
  74280. intersectionThreshold: number;
  74281. private _colorShader;
  74282. /**
  74283. * Creates a new LinesMesh
  74284. * @param name defines the name
  74285. * @param scene defines the hosting scene
  74286. * @param parent defines the parent mesh if any
  74287. * @param source defines the optional source LinesMesh used to clone data from
  74288. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  74289. * When false, achieved by calling a clone(), also passing False.
  74290. * This will make creation of children, recursive.
  74291. * @param useVertexColor defines if this LinesMesh supports vertex color
  74292. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  74293. */
  74294. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  74295. /**
  74296. * If vertex color should be applied to the mesh
  74297. */
  74298. useVertexColor?: boolean | undefined,
  74299. /**
  74300. * If vertex alpha should be applied to the mesh
  74301. */
  74302. useVertexAlpha?: boolean | undefined);
  74303. /**
  74304. * Returns the string "LineMesh"
  74305. */
  74306. getClassName(): string;
  74307. /**
  74308. * @hidden
  74309. */
  74310. /**
  74311. * @hidden
  74312. */
  74313. material: Material;
  74314. /**
  74315. * @hidden
  74316. */
  74317. readonly checkCollisions: boolean;
  74318. /** @hidden */
  74319. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  74320. /** @hidden */
  74321. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  74322. /**
  74323. * Disposes of the line mesh
  74324. * @param doNotRecurse If children should be disposed
  74325. */
  74326. dispose(doNotRecurse?: boolean): void;
  74327. /**
  74328. * Returns a new LineMesh object cloned from the current one.
  74329. */
  74330. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  74331. /**
  74332. * Creates a new InstancedLinesMesh object from the mesh model.
  74333. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  74334. * @param name defines the name of the new instance
  74335. * @returns a new InstancedLinesMesh
  74336. */
  74337. createInstance(name: string): InstancedLinesMesh;
  74338. }
  74339. /**
  74340. * Creates an instance based on a source LinesMesh
  74341. */
  74342. export class InstancedLinesMesh extends InstancedMesh {
  74343. /**
  74344. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74345. * This margin is expressed in world space coordinates, so its value may vary.
  74346. * Initilized with the intersectionThreshold value of the source LinesMesh
  74347. */
  74348. intersectionThreshold: number;
  74349. constructor(name: string, source: LinesMesh);
  74350. /**
  74351. * Returns the string "InstancedLinesMesh".
  74352. */
  74353. getClassName(): string;
  74354. }
  74355. }
  74356. declare module BABYLON {
  74357. /** @hidden */
  74358. export var linePixelShader: {
  74359. name: string;
  74360. shader: string;
  74361. };
  74362. }
  74363. declare module BABYLON {
  74364. /** @hidden */
  74365. export var lineVertexShader: {
  74366. name: string;
  74367. shader: string;
  74368. };
  74369. }
  74370. declare module BABYLON {
  74371. interface AbstractMesh {
  74372. /**
  74373. * Disables the mesh edge rendering mode
  74374. * @returns the currentAbstractMesh
  74375. */
  74376. disableEdgesRendering(): AbstractMesh;
  74377. /**
  74378. * Enables the edge rendering mode on the mesh.
  74379. * This mode makes the mesh edges visible
  74380. * @param epsilon defines the maximal distance between two angles to detect a face
  74381. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74382. * @returns the currentAbstractMesh
  74383. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74384. */
  74385. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74386. /**
  74387. * Gets the edgesRenderer associated with the mesh
  74388. */
  74389. edgesRenderer: Nullable<EdgesRenderer>;
  74390. }
  74391. interface LinesMesh {
  74392. /**
  74393. * Enables the edge rendering mode on the mesh.
  74394. * This mode makes the mesh edges visible
  74395. * @param epsilon defines the maximal distance between two angles to detect a face
  74396. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74397. * @returns the currentAbstractMesh
  74398. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74399. */
  74400. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74401. }
  74402. interface InstancedLinesMesh {
  74403. /**
  74404. * Enables the edge rendering mode on the mesh.
  74405. * This mode makes the mesh edges visible
  74406. * @param epsilon defines the maximal distance between two angles to detect a face
  74407. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74408. * @returns the current InstancedLinesMesh
  74409. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74410. */
  74411. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  74412. }
  74413. /**
  74414. * Defines the minimum contract an Edges renderer should follow.
  74415. */
  74416. export interface IEdgesRenderer extends IDisposable {
  74417. /**
  74418. * Gets or sets a boolean indicating if the edgesRenderer is active
  74419. */
  74420. isEnabled: boolean;
  74421. /**
  74422. * Renders the edges of the attached mesh,
  74423. */
  74424. render(): void;
  74425. /**
  74426. * Checks wether or not the edges renderer is ready to render.
  74427. * @return true if ready, otherwise false.
  74428. */
  74429. isReady(): boolean;
  74430. }
  74431. /**
  74432. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  74433. */
  74434. export class EdgesRenderer implements IEdgesRenderer {
  74435. /**
  74436. * Define the size of the edges with an orthographic camera
  74437. */
  74438. edgesWidthScalerForOrthographic: number;
  74439. /**
  74440. * Define the size of the edges with a perspective camera
  74441. */
  74442. edgesWidthScalerForPerspective: number;
  74443. protected _source: AbstractMesh;
  74444. protected _linesPositions: number[];
  74445. protected _linesNormals: number[];
  74446. protected _linesIndices: number[];
  74447. protected _epsilon: number;
  74448. protected _indicesCount: number;
  74449. protected _lineShader: ShaderMaterial;
  74450. protected _ib: WebGLBuffer;
  74451. protected _buffers: {
  74452. [key: string]: Nullable<VertexBuffer>;
  74453. };
  74454. protected _checkVerticesInsteadOfIndices: boolean;
  74455. private _meshRebuildObserver;
  74456. private _meshDisposeObserver;
  74457. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  74458. isEnabled: boolean;
  74459. /**
  74460. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  74461. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  74462. * @param source Mesh used to create edges
  74463. * @param epsilon sum of angles in adjacency to check for edge
  74464. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  74465. * @param generateEdgesLines - should generate Lines or only prepare resources.
  74466. */
  74467. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  74468. protected _prepareRessources(): void;
  74469. /** @hidden */
  74470. _rebuild(): void;
  74471. /**
  74472. * Releases the required resources for the edges renderer
  74473. */
  74474. dispose(): void;
  74475. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  74476. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  74477. /**
  74478. * Checks if the pair of p0 and p1 is en edge
  74479. * @param faceIndex
  74480. * @param edge
  74481. * @param faceNormals
  74482. * @param p0
  74483. * @param p1
  74484. * @private
  74485. */
  74486. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  74487. /**
  74488. * push line into the position, normal and index buffer
  74489. * @protected
  74490. */
  74491. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  74492. /**
  74493. * Generates lines edges from adjacencjes
  74494. * @private
  74495. */
  74496. _generateEdgesLines(): void;
  74497. /**
  74498. * Checks wether or not the edges renderer is ready to render.
  74499. * @return true if ready, otherwise false.
  74500. */
  74501. isReady(): boolean;
  74502. /**
  74503. * Renders the edges of the attached mesh,
  74504. */
  74505. render(): void;
  74506. }
  74507. /**
  74508. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  74509. */
  74510. export class LineEdgesRenderer extends EdgesRenderer {
  74511. /**
  74512. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  74513. * @param source LineMesh used to generate edges
  74514. * @param epsilon not important (specified angle for edge detection)
  74515. * @param checkVerticesInsteadOfIndices not important for LineMesh
  74516. */
  74517. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  74518. /**
  74519. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  74520. */
  74521. _generateEdgesLines(): void;
  74522. }
  74523. }
  74524. declare module BABYLON {
  74525. /**
  74526. * This represents the object necessary to create a rendering group.
  74527. * This is exclusively used and created by the rendering manager.
  74528. * To modify the behavior, you use the available helpers in your scene or meshes.
  74529. * @hidden
  74530. */
  74531. export class RenderingGroup {
  74532. index: number;
  74533. private _scene;
  74534. private _opaqueSubMeshes;
  74535. private _transparentSubMeshes;
  74536. private _alphaTestSubMeshes;
  74537. private _depthOnlySubMeshes;
  74538. private _particleSystems;
  74539. private _spriteManagers;
  74540. private _opaqueSortCompareFn;
  74541. private _alphaTestSortCompareFn;
  74542. private _transparentSortCompareFn;
  74543. private _renderOpaque;
  74544. private _renderAlphaTest;
  74545. private _renderTransparent;
  74546. private _edgesRenderers;
  74547. onBeforeTransparentRendering: () => void;
  74548. /**
  74549. * Set the opaque sort comparison function.
  74550. * If null the sub meshes will be render in the order they were created
  74551. */
  74552. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74553. /**
  74554. * Set the alpha test sort comparison function.
  74555. * If null the sub meshes will be render in the order they were created
  74556. */
  74557. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74558. /**
  74559. * Set the transparent sort comparison function.
  74560. * If null the sub meshes will be render in the order they were created
  74561. */
  74562. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74563. /**
  74564. * Creates a new rendering group.
  74565. * @param index The rendering group index
  74566. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  74567. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  74568. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  74569. */
  74570. 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>);
  74571. /**
  74572. * Render all the sub meshes contained in the group.
  74573. * @param customRenderFunction Used to override the default render behaviour of the group.
  74574. * @returns true if rendered some submeshes.
  74575. */
  74576. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  74577. /**
  74578. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  74579. * @param subMeshes The submeshes to render
  74580. */
  74581. private renderOpaqueSorted;
  74582. /**
  74583. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  74584. * @param subMeshes The submeshes to render
  74585. */
  74586. private renderAlphaTestSorted;
  74587. /**
  74588. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  74589. * @param subMeshes The submeshes to render
  74590. */
  74591. private renderTransparentSorted;
  74592. /**
  74593. * Renders the submeshes in a specified order.
  74594. * @param subMeshes The submeshes to sort before render
  74595. * @param sortCompareFn The comparison function use to sort
  74596. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  74597. * @param transparent Specifies to activate blending if true
  74598. */
  74599. private static renderSorted;
  74600. /**
  74601. * Renders the submeshes in the order they were dispatched (no sort applied).
  74602. * @param subMeshes The submeshes to render
  74603. */
  74604. private static renderUnsorted;
  74605. /**
  74606. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74607. * are rendered back to front if in the same alpha index.
  74608. *
  74609. * @param a The first submesh
  74610. * @param b The second submesh
  74611. * @returns The result of the comparison
  74612. */
  74613. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  74614. /**
  74615. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74616. * are rendered back to front.
  74617. *
  74618. * @param a The first submesh
  74619. * @param b The second submesh
  74620. * @returns The result of the comparison
  74621. */
  74622. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  74623. /**
  74624. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74625. * are rendered front to back (prevent overdraw).
  74626. *
  74627. * @param a The first submesh
  74628. * @param b The second submesh
  74629. * @returns The result of the comparison
  74630. */
  74631. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  74632. /**
  74633. * Resets the different lists of submeshes to prepare a new frame.
  74634. */
  74635. prepare(): void;
  74636. dispose(): void;
  74637. /**
  74638. * Inserts the submesh in its correct queue depending on its material.
  74639. * @param subMesh The submesh to dispatch
  74640. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74641. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74642. */
  74643. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74644. dispatchSprites(spriteManager: ISpriteManager): void;
  74645. dispatchParticles(particleSystem: IParticleSystem): void;
  74646. private _renderParticles;
  74647. private _renderSprites;
  74648. }
  74649. }
  74650. declare module BABYLON {
  74651. /**
  74652. * Interface describing the different options available in the rendering manager
  74653. * regarding Auto Clear between groups.
  74654. */
  74655. export interface IRenderingManagerAutoClearSetup {
  74656. /**
  74657. * Defines whether or not autoclear is enable.
  74658. */
  74659. autoClear: boolean;
  74660. /**
  74661. * Defines whether or not to autoclear the depth buffer.
  74662. */
  74663. depth: boolean;
  74664. /**
  74665. * Defines whether or not to autoclear the stencil buffer.
  74666. */
  74667. stencil: boolean;
  74668. }
  74669. /**
  74670. * This class is used by the onRenderingGroupObservable
  74671. */
  74672. export class RenderingGroupInfo {
  74673. /**
  74674. * The Scene that being rendered
  74675. */
  74676. scene: Scene;
  74677. /**
  74678. * The camera currently used for the rendering pass
  74679. */
  74680. camera: Nullable<Camera>;
  74681. /**
  74682. * The ID of the renderingGroup being processed
  74683. */
  74684. renderingGroupId: number;
  74685. }
  74686. /**
  74687. * This is the manager responsible of all the rendering for meshes sprites and particles.
  74688. * It is enable to manage the different groups as well as the different necessary sort functions.
  74689. * This should not be used directly aside of the few static configurations
  74690. */
  74691. export class RenderingManager {
  74692. /**
  74693. * The max id used for rendering groups (not included)
  74694. */
  74695. static MAX_RENDERINGGROUPS: number;
  74696. /**
  74697. * The min id used for rendering groups (included)
  74698. */
  74699. static MIN_RENDERINGGROUPS: number;
  74700. /**
  74701. * Used to globally prevent autoclearing scenes.
  74702. */
  74703. static AUTOCLEAR: boolean;
  74704. /**
  74705. * @hidden
  74706. */
  74707. _useSceneAutoClearSetup: boolean;
  74708. private _scene;
  74709. private _renderingGroups;
  74710. private _depthStencilBufferAlreadyCleaned;
  74711. private _autoClearDepthStencil;
  74712. private _customOpaqueSortCompareFn;
  74713. private _customAlphaTestSortCompareFn;
  74714. private _customTransparentSortCompareFn;
  74715. private _renderingGroupInfo;
  74716. /**
  74717. * Instantiates a new rendering group for a particular scene
  74718. * @param scene Defines the scene the groups belongs to
  74719. */
  74720. constructor(scene: Scene);
  74721. private _clearDepthStencilBuffer;
  74722. /**
  74723. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  74724. * @hidden
  74725. */
  74726. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  74727. /**
  74728. * Resets the different information of the group to prepare a new frame
  74729. * @hidden
  74730. */
  74731. reset(): void;
  74732. /**
  74733. * Dispose and release the group and its associated resources.
  74734. * @hidden
  74735. */
  74736. dispose(): void;
  74737. /**
  74738. * Clear the info related to rendering groups preventing retention points during dispose.
  74739. */
  74740. freeRenderingGroups(): void;
  74741. private _prepareRenderingGroup;
  74742. /**
  74743. * Add a sprite manager to the rendering manager in order to render it this frame.
  74744. * @param spriteManager Define the sprite manager to render
  74745. */
  74746. dispatchSprites(spriteManager: ISpriteManager): void;
  74747. /**
  74748. * Add a particle system to the rendering manager in order to render it this frame.
  74749. * @param particleSystem Define the particle system to render
  74750. */
  74751. dispatchParticles(particleSystem: IParticleSystem): void;
  74752. /**
  74753. * Add a submesh to the manager in order to render it this frame
  74754. * @param subMesh The submesh to dispatch
  74755. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74756. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74757. */
  74758. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74759. /**
  74760. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  74761. * This allowed control for front to back rendering or reversly depending of the special needs.
  74762. *
  74763. * @param renderingGroupId The rendering group id corresponding to its index
  74764. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  74765. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  74766. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  74767. */
  74768. 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;
  74769. /**
  74770. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  74771. *
  74772. * @param renderingGroupId The rendering group id corresponding to its index
  74773. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  74774. * @param depth Automatically clears depth between groups if true and autoClear is true.
  74775. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  74776. */
  74777. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  74778. /**
  74779. * Gets the current auto clear configuration for one rendering group of the rendering
  74780. * manager.
  74781. * @param index the rendering group index to get the information for
  74782. * @returns The auto clear setup for the requested rendering group
  74783. */
  74784. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  74785. }
  74786. }
  74787. declare module BABYLON {
  74788. /**
  74789. * This Helps creating a texture that will be created from a camera in your scene.
  74790. * It is basically a dynamic texture that could be used to create special effects for instance.
  74791. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  74792. */
  74793. export class RenderTargetTexture extends Texture {
  74794. isCube: boolean;
  74795. /**
  74796. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  74797. */
  74798. static readonly REFRESHRATE_RENDER_ONCE: number;
  74799. /**
  74800. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  74801. */
  74802. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  74803. /**
  74804. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  74805. * the central point of your effect and can save a lot of performances.
  74806. */
  74807. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  74808. /**
  74809. * Use this predicate to dynamically define the list of mesh you want to render.
  74810. * If set, the renderList property will be overwritten.
  74811. */
  74812. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  74813. private _renderList;
  74814. /**
  74815. * Use this list to define the list of mesh you want to render.
  74816. */
  74817. renderList: Nullable<Array<AbstractMesh>>;
  74818. private _hookArray;
  74819. /**
  74820. * Define if particles should be rendered in your texture.
  74821. */
  74822. renderParticles: boolean;
  74823. /**
  74824. * Define if sprites should be rendered in your texture.
  74825. */
  74826. renderSprites: boolean;
  74827. /**
  74828. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  74829. */
  74830. coordinatesMode: number;
  74831. /**
  74832. * Define the camera used to render the texture.
  74833. */
  74834. activeCamera: Nullable<Camera>;
  74835. /**
  74836. * Override the render function of the texture with your own one.
  74837. */
  74838. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  74839. /**
  74840. * Define if camera post processes should be use while rendering the texture.
  74841. */
  74842. useCameraPostProcesses: boolean;
  74843. /**
  74844. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  74845. */
  74846. ignoreCameraViewport: boolean;
  74847. private _postProcessManager;
  74848. private _postProcesses;
  74849. private _resizeObserver;
  74850. /**
  74851. * An event triggered when the texture is unbind.
  74852. */
  74853. onBeforeBindObservable: Observable<RenderTargetTexture>;
  74854. /**
  74855. * An event triggered when the texture is unbind.
  74856. */
  74857. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  74858. private _onAfterUnbindObserver;
  74859. /**
  74860. * Set a after unbind callback in the texture.
  74861. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  74862. */
  74863. onAfterUnbind: () => void;
  74864. /**
  74865. * An event triggered before rendering the texture
  74866. */
  74867. onBeforeRenderObservable: Observable<number>;
  74868. private _onBeforeRenderObserver;
  74869. /**
  74870. * Set a before render callback in the texture.
  74871. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  74872. */
  74873. onBeforeRender: (faceIndex: number) => void;
  74874. /**
  74875. * An event triggered after rendering the texture
  74876. */
  74877. onAfterRenderObservable: Observable<number>;
  74878. private _onAfterRenderObserver;
  74879. /**
  74880. * Set a after render callback in the texture.
  74881. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  74882. */
  74883. onAfterRender: (faceIndex: number) => void;
  74884. /**
  74885. * An event triggered after the texture clear
  74886. */
  74887. onClearObservable: Observable<Engine>;
  74888. private _onClearObserver;
  74889. /**
  74890. * Set a clear callback in the texture.
  74891. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  74892. */
  74893. onClear: (Engine: Engine) => void;
  74894. /**
  74895. * Define the clear color of the Render Target if it should be different from the scene.
  74896. */
  74897. clearColor: Color4;
  74898. protected _size: number | {
  74899. width: number;
  74900. height: number;
  74901. };
  74902. protected _initialSizeParameter: number | {
  74903. width: number;
  74904. height: number;
  74905. } | {
  74906. ratio: number;
  74907. };
  74908. protected _sizeRatio: Nullable<number>;
  74909. /** @hidden */
  74910. _generateMipMaps: boolean;
  74911. protected _renderingManager: RenderingManager;
  74912. /** @hidden */
  74913. _waitingRenderList: string[];
  74914. protected _doNotChangeAspectRatio: boolean;
  74915. protected _currentRefreshId: number;
  74916. protected _refreshRate: number;
  74917. protected _textureMatrix: Matrix;
  74918. protected _samples: number;
  74919. protected _renderTargetOptions: RenderTargetCreationOptions;
  74920. /**
  74921. * Gets render target creation options that were used.
  74922. */
  74923. readonly renderTargetOptions: RenderTargetCreationOptions;
  74924. protected _engine: Engine;
  74925. protected _onRatioRescale(): void;
  74926. /**
  74927. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  74928. * It must define where the camera used to render the texture is set
  74929. */
  74930. boundingBoxPosition: Vector3;
  74931. private _boundingBoxSize;
  74932. /**
  74933. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  74934. * When defined, the cubemap will switch to local mode
  74935. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74936. * @example https://www.babylonjs-playground.com/#RNASML
  74937. */
  74938. boundingBoxSize: Vector3;
  74939. /**
  74940. * In case the RTT has been created with a depth texture, get the associated
  74941. * depth texture.
  74942. * Otherwise, return null.
  74943. */
  74944. depthStencilTexture: Nullable<InternalTexture>;
  74945. /**
  74946. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  74947. * or used a shadow, depth texture...
  74948. * @param name The friendly name of the texture
  74949. * @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)
  74950. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  74951. * @param generateMipMaps True if mip maps need to be generated after render.
  74952. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  74953. * @param type The type of the buffer in the RTT (int, half float, float...)
  74954. * @param isCube True if a cube texture needs to be created
  74955. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  74956. * @param generateDepthBuffer True to generate a depth buffer
  74957. * @param generateStencilBuffer True to generate a stencil buffer
  74958. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  74959. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  74960. * @param delayAllocation if the texture allocation should be delayed (default: false)
  74961. */
  74962. constructor(name: string, size: number | {
  74963. width: number;
  74964. height: number;
  74965. } | {
  74966. ratio: number;
  74967. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  74968. /**
  74969. * Creates a depth stencil texture.
  74970. * This is only available in WebGL 2 or with the depth texture extension available.
  74971. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  74972. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  74973. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  74974. */
  74975. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  74976. private _processSizeParameter;
  74977. /**
  74978. * Define the number of samples to use in case of MSAA.
  74979. * It defaults to one meaning no MSAA has been enabled.
  74980. */
  74981. samples: number;
  74982. /**
  74983. * Resets the refresh counter of the texture and start bak from scratch.
  74984. * Could be useful to regenerate the texture if it is setup to render only once.
  74985. */
  74986. resetRefreshCounter(): void;
  74987. /**
  74988. * Define the refresh rate of the texture or the rendering frequency.
  74989. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  74990. */
  74991. refreshRate: number;
  74992. /**
  74993. * Adds a post process to the render target rendering passes.
  74994. * @param postProcess define the post process to add
  74995. */
  74996. addPostProcess(postProcess: PostProcess): void;
  74997. /**
  74998. * Clear all the post processes attached to the render target
  74999. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  75000. */
  75001. clearPostProcesses(dispose?: boolean): void;
  75002. /**
  75003. * Remove one of the post process from the list of attached post processes to the texture
  75004. * @param postProcess define the post process to remove from the list
  75005. */
  75006. removePostProcess(postProcess: PostProcess): void;
  75007. /** @hidden */
  75008. _shouldRender(): boolean;
  75009. /**
  75010. * Gets the actual render size of the texture.
  75011. * @returns the width of the render size
  75012. */
  75013. getRenderSize(): number;
  75014. /**
  75015. * Gets the actual render width of the texture.
  75016. * @returns the width of the render size
  75017. */
  75018. getRenderWidth(): number;
  75019. /**
  75020. * Gets the actual render height of the texture.
  75021. * @returns the height of the render size
  75022. */
  75023. getRenderHeight(): number;
  75024. /**
  75025. * Get if the texture can be rescaled or not.
  75026. */
  75027. readonly canRescale: boolean;
  75028. /**
  75029. * Resize the texture using a ratio.
  75030. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  75031. */
  75032. scale(ratio: number): void;
  75033. /**
  75034. * Get the texture reflection matrix used to rotate/transform the reflection.
  75035. * @returns the reflection matrix
  75036. */
  75037. getReflectionTextureMatrix(): Matrix;
  75038. /**
  75039. * Resize the texture to a new desired size.
  75040. * Be carrefull as it will recreate all the data in the new texture.
  75041. * @param size Define the new size. It can be:
  75042. * - a number for squared texture,
  75043. * - an object containing { width: number, height: number }
  75044. * - or an object containing a ratio { ratio: number }
  75045. */
  75046. resize(size: number | {
  75047. width: number;
  75048. height: number;
  75049. } | {
  75050. ratio: number;
  75051. }): void;
  75052. /**
  75053. * Renders all the objects from the render list into the texture.
  75054. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  75055. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  75056. */
  75057. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  75058. private _bestReflectionRenderTargetDimension;
  75059. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  75060. private renderToTarget;
  75061. /**
  75062. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  75063. * This allowed control for front to back rendering or reversly depending of the special needs.
  75064. *
  75065. * @param renderingGroupId The rendering group id corresponding to its index
  75066. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  75067. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  75068. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  75069. */
  75070. 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;
  75071. /**
  75072. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  75073. *
  75074. * @param renderingGroupId The rendering group id corresponding to its index
  75075. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  75076. */
  75077. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  75078. /**
  75079. * Clones the texture.
  75080. * @returns the cloned texture
  75081. */
  75082. clone(): RenderTargetTexture;
  75083. /**
  75084. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75085. * @returns The JSON representation of the texture
  75086. */
  75087. serialize(): any;
  75088. /**
  75089. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  75090. */
  75091. disposeFramebufferObjects(): void;
  75092. /**
  75093. * Dispose the texture and release its associated resources.
  75094. */
  75095. dispose(): void;
  75096. /** @hidden */
  75097. _rebuild(): void;
  75098. /**
  75099. * Clear the info related to rendering groups preventing retention point in material dispose.
  75100. */
  75101. freeRenderingGroups(): void;
  75102. }
  75103. }
  75104. declare module BABYLON {
  75105. /**
  75106. * Mirror texture can be used to simulate the view from a mirror in a scene.
  75107. * It will dynamically be rendered every frame to adapt to the camera point of view.
  75108. * You can then easily use it as a reflectionTexture on a flat surface.
  75109. * In case the surface is not a plane, please consider relying on reflection probes.
  75110. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75111. */
  75112. export class MirrorTexture extends RenderTargetTexture {
  75113. private scene;
  75114. /**
  75115. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  75116. * 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.
  75117. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75118. */
  75119. mirrorPlane: Plane;
  75120. /**
  75121. * Define the blur ratio used to blur the reflection if needed.
  75122. */
  75123. blurRatio: number;
  75124. /**
  75125. * Define the adaptive blur kernel used to blur the reflection if needed.
  75126. * This will autocompute the closest best match for the `blurKernel`
  75127. */
  75128. adaptiveBlurKernel: number;
  75129. /**
  75130. * Define the blur kernel used to blur the reflection if needed.
  75131. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75132. */
  75133. blurKernel: number;
  75134. /**
  75135. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  75136. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75137. */
  75138. blurKernelX: number;
  75139. /**
  75140. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  75141. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75142. */
  75143. blurKernelY: number;
  75144. private _autoComputeBlurKernel;
  75145. protected _onRatioRescale(): void;
  75146. private _updateGammaSpace;
  75147. private _imageProcessingConfigChangeObserver;
  75148. private _transformMatrix;
  75149. private _mirrorMatrix;
  75150. private _savedViewMatrix;
  75151. private _blurX;
  75152. private _blurY;
  75153. private _adaptiveBlurKernel;
  75154. private _blurKernelX;
  75155. private _blurKernelY;
  75156. private _blurRatio;
  75157. /**
  75158. * Instantiates a Mirror Texture.
  75159. * Mirror texture can be used to simulate the view from a mirror in a scene.
  75160. * It will dynamically be rendered every frame to adapt to the camera point of view.
  75161. * You can then easily use it as a reflectionTexture on a flat surface.
  75162. * In case the surface is not a plane, please consider relying on reflection probes.
  75163. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75164. * @param name
  75165. * @param size
  75166. * @param scene
  75167. * @param generateMipMaps
  75168. * @param type
  75169. * @param samplingMode
  75170. * @param generateDepthBuffer
  75171. */
  75172. constructor(name: string, size: number | {
  75173. width: number;
  75174. height: number;
  75175. } | {
  75176. ratio: number;
  75177. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  75178. private _preparePostProcesses;
  75179. /**
  75180. * Clone the mirror texture.
  75181. * @returns the cloned texture
  75182. */
  75183. clone(): MirrorTexture;
  75184. /**
  75185. * Serialize the texture to a JSON representation you could use in Parse later on
  75186. * @returns the serialized JSON representation
  75187. */
  75188. serialize(): any;
  75189. /**
  75190. * Dispose the texture and release its associated resources.
  75191. */
  75192. dispose(): void;
  75193. }
  75194. }
  75195. declare module BABYLON {
  75196. /**
  75197. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  75198. * @see http://doc.babylonjs.com/babylon101/materials#texture
  75199. */
  75200. export class Texture extends BaseTexture {
  75201. /** @hidden */
  75202. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  75203. /** @hidden */
  75204. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  75205. /** @hidden */
  75206. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  75207. /** nearest is mag = nearest and min = nearest and mip = linear */
  75208. static readonly NEAREST_SAMPLINGMODE: number;
  75209. /** nearest is mag = nearest and min = nearest and mip = linear */
  75210. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  75211. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75212. static readonly BILINEAR_SAMPLINGMODE: number;
  75213. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75214. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  75215. /** Trilinear is mag = linear and min = linear and mip = linear */
  75216. static readonly TRILINEAR_SAMPLINGMODE: number;
  75217. /** Trilinear is mag = linear and min = linear and mip = linear */
  75218. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  75219. /** mag = nearest and min = nearest and mip = nearest */
  75220. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  75221. /** mag = nearest and min = linear and mip = nearest */
  75222. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  75223. /** mag = nearest and min = linear and mip = linear */
  75224. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  75225. /** mag = nearest and min = linear and mip = none */
  75226. static readonly NEAREST_LINEAR: number;
  75227. /** mag = nearest and min = nearest and mip = none */
  75228. static readonly NEAREST_NEAREST: number;
  75229. /** mag = linear and min = nearest and mip = nearest */
  75230. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  75231. /** mag = linear and min = nearest and mip = linear */
  75232. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  75233. /** mag = linear and min = linear and mip = none */
  75234. static readonly LINEAR_LINEAR: number;
  75235. /** mag = linear and min = nearest and mip = none */
  75236. static readonly LINEAR_NEAREST: number;
  75237. /** Explicit coordinates mode */
  75238. static readonly EXPLICIT_MODE: number;
  75239. /** Spherical coordinates mode */
  75240. static readonly SPHERICAL_MODE: number;
  75241. /** Planar coordinates mode */
  75242. static readonly PLANAR_MODE: number;
  75243. /** Cubic coordinates mode */
  75244. static readonly CUBIC_MODE: number;
  75245. /** Projection coordinates mode */
  75246. static readonly PROJECTION_MODE: number;
  75247. /** Inverse Cubic coordinates mode */
  75248. static readonly SKYBOX_MODE: number;
  75249. /** Inverse Cubic coordinates mode */
  75250. static readonly INVCUBIC_MODE: number;
  75251. /** Equirectangular coordinates mode */
  75252. static readonly EQUIRECTANGULAR_MODE: number;
  75253. /** Equirectangular Fixed coordinates mode */
  75254. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  75255. /** Equirectangular Fixed Mirrored coordinates mode */
  75256. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  75257. /** Texture is not repeating outside of 0..1 UVs */
  75258. static readonly CLAMP_ADDRESSMODE: number;
  75259. /** Texture is repeating outside of 0..1 UVs */
  75260. static readonly WRAP_ADDRESSMODE: number;
  75261. /** Texture is repeating and mirrored */
  75262. static readonly MIRROR_ADDRESSMODE: number;
  75263. /**
  75264. * 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
  75265. */
  75266. static UseSerializedUrlIfAny: boolean;
  75267. /**
  75268. * Define the url of the texture.
  75269. */
  75270. url: Nullable<string>;
  75271. /**
  75272. * Define an offset on the texture to offset the u coordinates of the UVs
  75273. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75274. */
  75275. uOffset: number;
  75276. /**
  75277. * Define an offset on the texture to offset the v coordinates of the UVs
  75278. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75279. */
  75280. vOffset: number;
  75281. /**
  75282. * Define an offset on the texture to scale the u coordinates of the UVs
  75283. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75284. */
  75285. uScale: number;
  75286. /**
  75287. * Define an offset on the texture to scale the v coordinates of the UVs
  75288. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75289. */
  75290. vScale: number;
  75291. /**
  75292. * Define an offset on the texture to rotate around the u coordinates of the UVs
  75293. * @see http://doc.babylonjs.com/how_to/more_materials
  75294. */
  75295. uAng: number;
  75296. /**
  75297. * Define an offset on the texture to rotate around the v coordinates of the UVs
  75298. * @see http://doc.babylonjs.com/how_to/more_materials
  75299. */
  75300. vAng: number;
  75301. /**
  75302. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  75303. * @see http://doc.babylonjs.com/how_to/more_materials
  75304. */
  75305. wAng: number;
  75306. /**
  75307. * Defines the center of rotation (U)
  75308. */
  75309. uRotationCenter: number;
  75310. /**
  75311. * Defines the center of rotation (V)
  75312. */
  75313. vRotationCenter: number;
  75314. /**
  75315. * Defines the center of rotation (W)
  75316. */
  75317. wRotationCenter: number;
  75318. /**
  75319. * Are mip maps generated for this texture or not.
  75320. */
  75321. readonly noMipmap: boolean;
  75322. private _noMipmap;
  75323. /** @hidden */
  75324. _invertY: boolean;
  75325. private _rowGenerationMatrix;
  75326. private _cachedTextureMatrix;
  75327. private _projectionModeMatrix;
  75328. private _t0;
  75329. private _t1;
  75330. private _t2;
  75331. private _cachedUOffset;
  75332. private _cachedVOffset;
  75333. private _cachedUScale;
  75334. private _cachedVScale;
  75335. private _cachedUAng;
  75336. private _cachedVAng;
  75337. private _cachedWAng;
  75338. private _cachedProjectionMatrixId;
  75339. private _cachedCoordinatesMode;
  75340. /** @hidden */
  75341. protected _initialSamplingMode: number;
  75342. /** @hidden */
  75343. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  75344. private _deleteBuffer;
  75345. protected _format: Nullable<number>;
  75346. private _delayedOnLoad;
  75347. private _delayedOnError;
  75348. /**
  75349. * Observable triggered once the texture has been loaded.
  75350. */
  75351. onLoadObservable: Observable<Texture>;
  75352. protected _isBlocking: boolean;
  75353. /**
  75354. * Is the texture preventing material to render while loading.
  75355. * If false, a default texture will be used instead of the loading one during the preparation step.
  75356. */
  75357. isBlocking: boolean;
  75358. /**
  75359. * Get the current sampling mode associated with the texture.
  75360. */
  75361. readonly samplingMode: number;
  75362. /**
  75363. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  75364. */
  75365. readonly invertY: boolean;
  75366. /**
  75367. * Instantiates a new texture.
  75368. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  75369. * @see http://doc.babylonjs.com/babylon101/materials#texture
  75370. * @param url define the url of the picture to load as a texture
  75371. * @param scene define the scene the texture will belong to
  75372. * @param noMipmap define if the texture will require mip maps or not
  75373. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75374. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75375. * @param onLoad define a callback triggered when the texture has been loaded
  75376. * @param onError define a callback triggered when an error occurred during the loading session
  75377. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75378. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75379. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75380. */
  75381. 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);
  75382. /**
  75383. * Update the url (and optional buffer) of this texture if url was null during construction.
  75384. * @param url the url of the texture
  75385. * @param buffer the buffer of the texture (defaults to null)
  75386. * @param onLoad callback called when the texture is loaded (defaults to null)
  75387. */
  75388. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  75389. /**
  75390. * Finish the loading sequence of a texture flagged as delayed load.
  75391. * @hidden
  75392. */
  75393. delayLoad(): void;
  75394. private _prepareRowForTextureGeneration;
  75395. /**
  75396. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  75397. * @returns the transform matrix of the texture.
  75398. */
  75399. getTextureMatrix(): Matrix;
  75400. /**
  75401. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  75402. * @returns The reflection texture transform
  75403. */
  75404. getReflectionTextureMatrix(): Matrix;
  75405. /**
  75406. * Clones the texture.
  75407. * @returns the cloned texture
  75408. */
  75409. clone(): Texture;
  75410. /**
  75411. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75412. * @returns The JSON representation of the texture
  75413. */
  75414. serialize(): any;
  75415. /**
  75416. * Get the current class name of the texture useful for serialization or dynamic coding.
  75417. * @returns "Texture"
  75418. */
  75419. getClassName(): string;
  75420. /**
  75421. * Dispose the texture and release its associated resources.
  75422. */
  75423. dispose(): void;
  75424. /**
  75425. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  75426. * @param parsedTexture Define the JSON representation of the texture
  75427. * @param scene Define the scene the parsed texture should be instantiated in
  75428. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  75429. * @returns The parsed texture if successful
  75430. */
  75431. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  75432. /**
  75433. * Creates a texture from its base 64 representation.
  75434. * @param data Define the base64 payload without the data: prefix
  75435. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75436. * @param scene Define the scene the texture should belong to
  75437. * @param noMipmap Forces the texture to not create mip map information if true
  75438. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75439. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75440. * @param onLoad define a callback triggered when the texture has been loaded
  75441. * @param onError define a callback triggered when an error occurred during the loading session
  75442. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75443. * @returns the created texture
  75444. */
  75445. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  75446. /**
  75447. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  75448. * @param data Define the base64 payload without the data: prefix
  75449. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75450. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75451. * @param scene Define the scene the texture should belong to
  75452. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75453. * @param noMipmap Forces the texture to not create mip map information if true
  75454. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75455. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75456. * @param onLoad define a callback triggered when the texture has been loaded
  75457. * @param onError define a callback triggered when an error occurred during the loading session
  75458. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75459. * @returns the created texture
  75460. */
  75461. 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;
  75462. }
  75463. }
  75464. declare module BABYLON {
  75465. /**
  75466. * Raw texture can help creating a texture directly from an array of data.
  75467. * This can be super useful if you either get the data from an uncompressed source or
  75468. * if you wish to create your texture pixel by pixel.
  75469. */
  75470. export class RawTexture extends Texture {
  75471. /**
  75472. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75473. */
  75474. format: number;
  75475. private _engine;
  75476. /**
  75477. * Instantiates a new RawTexture.
  75478. * Raw texture can help creating a texture directly from an array of data.
  75479. * This can be super useful if you either get the data from an uncompressed source or
  75480. * if you wish to create your texture pixel by pixel.
  75481. * @param data define the array of data to use to create the texture
  75482. * @param width define the width of the texture
  75483. * @param height define the height of the texture
  75484. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75485. * @param scene define the scene the texture belongs to
  75486. * @param generateMipMaps define whether mip maps should be generated or not
  75487. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75488. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75489. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75490. */
  75491. constructor(data: ArrayBufferView, width: number, height: number,
  75492. /**
  75493. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75494. */
  75495. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  75496. /**
  75497. * Updates the texture underlying data.
  75498. * @param data Define the new data of the texture
  75499. */
  75500. update(data: ArrayBufferView): void;
  75501. /**
  75502. * Creates a luminance texture from some data.
  75503. * @param data Define the texture data
  75504. * @param width Define the width of the texture
  75505. * @param height Define the height of the texture
  75506. * @param scene Define the scene the texture belongs to
  75507. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75508. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75509. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75510. * @returns the luminance texture
  75511. */
  75512. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75513. /**
  75514. * Creates a luminance alpha texture from some data.
  75515. * @param data Define the texture data
  75516. * @param width Define the width of the texture
  75517. * @param height Define the height of the texture
  75518. * @param scene Define the scene the texture belongs to
  75519. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75520. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75521. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75522. * @returns the luminance alpha texture
  75523. */
  75524. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75525. /**
  75526. * Creates an alpha texture from some data.
  75527. * @param data Define the texture data
  75528. * @param width Define the width of the texture
  75529. * @param height Define the height of the texture
  75530. * @param scene Define the scene the texture belongs to
  75531. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75532. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75533. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75534. * @returns the alpha texture
  75535. */
  75536. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75537. /**
  75538. * Creates a RGB texture from some data.
  75539. * @param data Define the texture data
  75540. * @param width Define the width of the texture
  75541. * @param height Define the height of the texture
  75542. * @param scene Define the scene the texture belongs to
  75543. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75544. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75545. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75546. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75547. * @returns the RGB alpha texture
  75548. */
  75549. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75550. /**
  75551. * Creates a RGBA texture from some data.
  75552. * @param data Define the texture data
  75553. * @param width Define the width of the texture
  75554. * @param height Define the height of the texture
  75555. * @param scene Define the scene the texture belongs to
  75556. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75557. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75558. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75559. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75560. * @returns the RGBA texture
  75561. */
  75562. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75563. /**
  75564. * Creates a R texture from some data.
  75565. * @param data Define the texture data
  75566. * @param width Define the width of the texture
  75567. * @param height Define the height of the texture
  75568. * @param scene Define the scene the texture belongs to
  75569. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75570. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75571. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75572. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75573. * @returns the R texture
  75574. */
  75575. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75576. }
  75577. }
  75578. declare module BABYLON {
  75579. /**
  75580. * Defines a runtime animation
  75581. */
  75582. export class RuntimeAnimation {
  75583. private _events;
  75584. /**
  75585. * The current frame of the runtime animation
  75586. */
  75587. private _currentFrame;
  75588. /**
  75589. * The animation used by the runtime animation
  75590. */
  75591. private _animation;
  75592. /**
  75593. * The target of the runtime animation
  75594. */
  75595. private _target;
  75596. /**
  75597. * The initiating animatable
  75598. */
  75599. private _host;
  75600. /**
  75601. * The original value of the runtime animation
  75602. */
  75603. private _originalValue;
  75604. /**
  75605. * The original blend value of the runtime animation
  75606. */
  75607. private _originalBlendValue;
  75608. /**
  75609. * The offsets cache of the runtime animation
  75610. */
  75611. private _offsetsCache;
  75612. /**
  75613. * The high limits cache of the runtime animation
  75614. */
  75615. private _highLimitsCache;
  75616. /**
  75617. * Specifies if the runtime animation has been stopped
  75618. */
  75619. private _stopped;
  75620. /**
  75621. * The blending factor of the runtime animation
  75622. */
  75623. private _blendingFactor;
  75624. /**
  75625. * The BabylonJS scene
  75626. */
  75627. private _scene;
  75628. /**
  75629. * The current value of the runtime animation
  75630. */
  75631. private _currentValue;
  75632. /** @hidden */
  75633. _workValue: any;
  75634. /**
  75635. * The active target of the runtime animation
  75636. */
  75637. private _activeTarget;
  75638. /**
  75639. * The target path of the runtime animation
  75640. */
  75641. private _targetPath;
  75642. /**
  75643. * The weight of the runtime animation
  75644. */
  75645. private _weight;
  75646. /**
  75647. * The ratio offset of the runtime animation
  75648. */
  75649. private _ratioOffset;
  75650. /**
  75651. * The previous delay of the runtime animation
  75652. */
  75653. private _previousDelay;
  75654. /**
  75655. * The previous ratio of the runtime animation
  75656. */
  75657. private _previousRatio;
  75658. /**
  75659. * Gets the current frame of the runtime animation
  75660. */
  75661. readonly currentFrame: number;
  75662. /**
  75663. * Gets the weight of the runtime animation
  75664. */
  75665. readonly weight: number;
  75666. /**
  75667. * Gets the current value of the runtime animation
  75668. */
  75669. readonly currentValue: any;
  75670. /**
  75671. * Gets the target path of the runtime animation
  75672. */
  75673. readonly targetPath: string;
  75674. /**
  75675. * Gets the actual target of the runtime animation
  75676. */
  75677. readonly target: any;
  75678. /**
  75679. * Create a new RuntimeAnimation object
  75680. * @param target defines the target of the animation
  75681. * @param animation defines the source animation object
  75682. * @param scene defines the hosting scene
  75683. * @param host defines the initiating Animatable
  75684. */
  75685. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  75686. /**
  75687. * Gets the animation from the runtime animation
  75688. */
  75689. readonly animation: Animation;
  75690. /**
  75691. * Resets the runtime animation to the beginning
  75692. * @param restoreOriginal defines whether to restore the target property to the original value
  75693. */
  75694. reset(restoreOriginal?: boolean): void;
  75695. /**
  75696. * Specifies if the runtime animation is stopped
  75697. * @returns Boolean specifying if the runtime animation is stopped
  75698. */
  75699. isStopped(): boolean;
  75700. /**
  75701. * Disposes of the runtime animation
  75702. */
  75703. dispose(): void;
  75704. /**
  75705. * Interpolates the animation from the current frame
  75706. * @param currentFrame The frame to interpolate the animation to
  75707. * @param repeatCount The number of times that the animation should loop
  75708. * @param loopMode The type of looping mode to use
  75709. * @param offsetValue Animation offset value
  75710. * @param highLimitValue The high limit value
  75711. * @returns The interpolated value
  75712. */
  75713. private _interpolate;
  75714. /**
  75715. * Apply the interpolated value to the target
  75716. * @param currentValue defines the value computed by the animation
  75717. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  75718. */
  75719. setValue(currentValue: any, weight?: number): void;
  75720. private _setValue;
  75721. /**
  75722. * Gets the loop pmode of the runtime animation
  75723. * @returns Loop Mode
  75724. */
  75725. private _getCorrectLoopMode;
  75726. /**
  75727. * Move the current animation to a given frame
  75728. * @param frame defines the frame to move to
  75729. */
  75730. goToFrame(frame: number): void;
  75731. /**
  75732. * @hidden Internal use only
  75733. */
  75734. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  75735. /**
  75736. * Execute the current animation
  75737. * @param delay defines the delay to add to the current frame
  75738. * @param from defines the lower bound of the animation range
  75739. * @param to defines the upper bound of the animation range
  75740. * @param loop defines if the current animation must loop
  75741. * @param speedRatio defines the current speed ratio
  75742. * @param weight defines the weight of the animation (default is -1 so no weight)
  75743. * @param onLoop optional callback called when animation loops
  75744. * @returns a boolean indicating if the animation is running
  75745. */
  75746. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  75747. }
  75748. }
  75749. declare module BABYLON {
  75750. /**
  75751. * Class used to store an actual running animation
  75752. */
  75753. export class Animatable {
  75754. /** defines the target object */
  75755. target: any;
  75756. /** defines the starting frame number (default is 0) */
  75757. fromFrame: number;
  75758. /** defines the ending frame number (default is 100) */
  75759. toFrame: number;
  75760. /** defines if the animation must loop (default is false) */
  75761. loopAnimation: boolean;
  75762. /** defines a callback to call when animation ends if it is not looping */
  75763. onAnimationEnd?: (() => void) | null | undefined;
  75764. /** defines a callback to call when animation loops */
  75765. onAnimationLoop?: (() => void) | null | undefined;
  75766. private _localDelayOffset;
  75767. private _pausedDelay;
  75768. private _runtimeAnimations;
  75769. private _paused;
  75770. private _scene;
  75771. private _speedRatio;
  75772. private _weight;
  75773. private _syncRoot;
  75774. /**
  75775. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  75776. * This will only apply for non looping animation (default is true)
  75777. */
  75778. disposeOnEnd: boolean;
  75779. /**
  75780. * Gets a boolean indicating if the animation has started
  75781. */
  75782. animationStarted: boolean;
  75783. /**
  75784. * Observer raised when the animation ends
  75785. */
  75786. onAnimationEndObservable: Observable<Animatable>;
  75787. /**
  75788. * Observer raised when the animation loops
  75789. */
  75790. onAnimationLoopObservable: Observable<Animatable>;
  75791. /**
  75792. * Gets the root Animatable used to synchronize and normalize animations
  75793. */
  75794. readonly syncRoot: Animatable;
  75795. /**
  75796. * Gets the current frame of the first RuntimeAnimation
  75797. * Used to synchronize Animatables
  75798. */
  75799. readonly masterFrame: number;
  75800. /**
  75801. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  75802. */
  75803. weight: number;
  75804. /**
  75805. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  75806. */
  75807. speedRatio: number;
  75808. /**
  75809. * Creates a new Animatable
  75810. * @param scene defines the hosting scene
  75811. * @param target defines the target object
  75812. * @param fromFrame defines the starting frame number (default is 0)
  75813. * @param toFrame defines the ending frame number (default is 100)
  75814. * @param loopAnimation defines if the animation must loop (default is false)
  75815. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  75816. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  75817. * @param animations defines a group of animation to add to the new Animatable
  75818. * @param onAnimationLoop defines a callback to call when animation loops
  75819. */
  75820. constructor(scene: Scene,
  75821. /** defines the target object */
  75822. target: any,
  75823. /** defines the starting frame number (default is 0) */
  75824. fromFrame?: number,
  75825. /** defines the ending frame number (default is 100) */
  75826. toFrame?: number,
  75827. /** defines if the animation must loop (default is false) */
  75828. loopAnimation?: boolean, speedRatio?: number,
  75829. /** defines a callback to call when animation ends if it is not looping */
  75830. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  75831. /** defines a callback to call when animation loops */
  75832. onAnimationLoop?: (() => void) | null | undefined);
  75833. /**
  75834. * Synchronize and normalize current Animatable with a source Animatable
  75835. * This is useful when using animation weights and when animations are not of the same length
  75836. * @param root defines the root Animatable to synchronize with
  75837. * @returns the current Animatable
  75838. */
  75839. syncWith(root: Animatable): Animatable;
  75840. /**
  75841. * Gets the list of runtime animations
  75842. * @returns an array of RuntimeAnimation
  75843. */
  75844. getAnimations(): RuntimeAnimation[];
  75845. /**
  75846. * Adds more animations to the current animatable
  75847. * @param target defines the target of the animations
  75848. * @param animations defines the new animations to add
  75849. */
  75850. appendAnimations(target: any, animations: Animation[]): void;
  75851. /**
  75852. * Gets the source animation for a specific property
  75853. * @param property defines the propertyu to look for
  75854. * @returns null or the source animation for the given property
  75855. */
  75856. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  75857. /**
  75858. * Gets the runtime animation for a specific property
  75859. * @param property defines the propertyu to look for
  75860. * @returns null or the runtime animation for the given property
  75861. */
  75862. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  75863. /**
  75864. * Resets the animatable to its original state
  75865. */
  75866. reset(): void;
  75867. /**
  75868. * Allows the animatable to blend with current running animations
  75869. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75870. * @param blendingSpeed defines the blending speed to use
  75871. */
  75872. enableBlending(blendingSpeed: number): void;
  75873. /**
  75874. * Disable animation blending
  75875. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75876. */
  75877. disableBlending(): void;
  75878. /**
  75879. * Jump directly to a given frame
  75880. * @param frame defines the frame to jump to
  75881. */
  75882. goToFrame(frame: number): void;
  75883. /**
  75884. * Pause the animation
  75885. */
  75886. pause(): void;
  75887. /**
  75888. * Restart the animation
  75889. */
  75890. restart(): void;
  75891. private _raiseOnAnimationEnd;
  75892. /**
  75893. * Stop and delete the current animation
  75894. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  75895. * @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)
  75896. */
  75897. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  75898. /**
  75899. * Wait asynchronously for the animation to end
  75900. * @returns a promise which will be fullfilled when the animation ends
  75901. */
  75902. waitAsync(): Promise<Animatable>;
  75903. /** @hidden */
  75904. _animate(delay: number): boolean;
  75905. }
  75906. interface Scene {
  75907. /** @hidden */
  75908. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  75909. /** @hidden */
  75910. _processLateAnimationBindingsForMatrices(holder: {
  75911. totalWeight: number;
  75912. animations: RuntimeAnimation[];
  75913. originalValue: Matrix;
  75914. }): any;
  75915. /** @hidden */
  75916. _processLateAnimationBindingsForQuaternions(holder: {
  75917. totalWeight: number;
  75918. animations: RuntimeAnimation[];
  75919. originalValue: Quaternion;
  75920. }, refQuaternion: Quaternion): Quaternion;
  75921. /** @hidden */
  75922. _processLateAnimationBindings(): void;
  75923. /**
  75924. * Will start the animation sequence of a given target
  75925. * @param target defines the target
  75926. * @param from defines from which frame should animation start
  75927. * @param to defines until which frame should animation run.
  75928. * @param weight defines the weight to apply to the animation (1.0 by default)
  75929. * @param loop defines if the animation loops
  75930. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75931. * @param onAnimationEnd defines the function to be executed when the animation ends
  75932. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75933. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75934. * @param onAnimationLoop defines the callback to call when an animation loops
  75935. * @returns the animatable object created for this animation
  75936. */
  75937. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75938. /**
  75939. * Will start the animation sequence of a given target
  75940. * @param target defines the target
  75941. * @param from defines from which frame should animation start
  75942. * @param to defines until which frame should animation run.
  75943. * @param loop defines if the animation loops
  75944. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75945. * @param onAnimationEnd defines the function to be executed when the animation ends
  75946. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75947. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75948. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  75949. * @param onAnimationLoop defines the callback to call when an animation loops
  75950. * @returns the animatable object created for this animation
  75951. */
  75952. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75953. /**
  75954. * Will start the animation sequence of a given target and its hierarchy
  75955. * @param target defines the target
  75956. * @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.
  75957. * @param from defines from which frame should animation start
  75958. * @param to defines until which frame should animation run.
  75959. * @param loop defines if the animation loops
  75960. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75961. * @param onAnimationEnd defines the function to be executed when the animation ends
  75962. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75963. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75964. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75965. * @param onAnimationLoop defines the callback to call when an animation loops
  75966. * @returns the list of created animatables
  75967. */
  75968. 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[];
  75969. /**
  75970. * Begin a new animation on a given node
  75971. * @param target defines the target where the animation will take place
  75972. * @param animations defines the list of animations to start
  75973. * @param from defines the initial value
  75974. * @param to defines the final value
  75975. * @param loop defines if you want animation to loop (off by default)
  75976. * @param speedRatio defines the speed ratio to apply to all animations
  75977. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  75978. * @param onAnimationLoop defines the callback to call when an animation loops
  75979. * @returns the list of created animatables
  75980. */
  75981. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  75982. /**
  75983. * Begin a new animation on a given node and its hierarchy
  75984. * @param target defines the root node where the animation will take place
  75985. * @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.
  75986. * @param animations defines the list of animations to start
  75987. * @param from defines the initial value
  75988. * @param to defines the final value
  75989. * @param loop defines if you want animation to loop (off by default)
  75990. * @param speedRatio defines the speed ratio to apply to all animations
  75991. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  75992. * @param onAnimationLoop defines the callback to call when an animation loops
  75993. * @returns the list of animatables created for all nodes
  75994. */
  75995. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  75996. /**
  75997. * Gets the animatable associated with a specific target
  75998. * @param target defines the target of the animatable
  75999. * @returns the required animatable if found
  76000. */
  76001. getAnimatableByTarget(target: any): Nullable<Animatable>;
  76002. /**
  76003. * Gets all animatables associated with a given target
  76004. * @param target defines the target to look animatables for
  76005. * @returns an array of Animatables
  76006. */
  76007. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  76008. /**
  76009. * Will stop the animation of the given target
  76010. * @param target - the target
  76011. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  76012. * @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)
  76013. */
  76014. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  76015. /**
  76016. * Stops and removes all animations that have been applied to the scene
  76017. */
  76018. stopAllAnimations(): void;
  76019. }
  76020. interface Bone {
  76021. /**
  76022. * Copy an animation range from another bone
  76023. * @param source defines the source bone
  76024. * @param rangeName defines the range name to copy
  76025. * @param frameOffset defines the frame offset
  76026. * @param rescaleAsRequired defines if rescaling must be applied if required
  76027. * @param skelDimensionsRatio defines the scaling ratio
  76028. * @returns true if operation was successful
  76029. */
  76030. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  76031. }
  76032. }
  76033. declare module BABYLON {
  76034. /**
  76035. * Class used to handle skinning animations
  76036. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  76037. */
  76038. export class Skeleton implements IAnimatable {
  76039. /** defines the skeleton name */
  76040. name: string;
  76041. /** defines the skeleton Id */
  76042. id: string;
  76043. /**
  76044. * Defines the list of child bones
  76045. */
  76046. bones: Bone[];
  76047. /**
  76048. * Defines an estimate of the dimension of the skeleton at rest
  76049. */
  76050. dimensionsAtRest: Vector3;
  76051. /**
  76052. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  76053. */
  76054. needInitialSkinMatrix: boolean;
  76055. /**
  76056. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  76057. */
  76058. overrideMesh: Nullable<AbstractMesh>;
  76059. /**
  76060. * Gets the list of animations attached to this skeleton
  76061. */
  76062. animations: Array<Animation>;
  76063. private _scene;
  76064. private _isDirty;
  76065. private _transformMatrices;
  76066. private _transformMatrixTexture;
  76067. private _meshesWithPoseMatrix;
  76068. private _animatables;
  76069. private _identity;
  76070. private _synchronizedWithMesh;
  76071. private _ranges;
  76072. private _lastAbsoluteTransformsUpdateId;
  76073. private _canUseTextureForBones;
  76074. /** @hidden */
  76075. _numBonesWithLinkedTransformNode: number;
  76076. /**
  76077. * Specifies if the skeleton should be serialized
  76078. */
  76079. doNotSerialize: boolean;
  76080. /**
  76081. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  76082. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  76083. */
  76084. useTextureToStoreBoneMatrices: boolean;
  76085. private _animationPropertiesOverride;
  76086. /**
  76087. * Gets or sets the animation properties override
  76088. */
  76089. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76090. /**
  76091. * An observable triggered before computing the skeleton's matrices
  76092. */
  76093. onBeforeComputeObservable: Observable<Skeleton>;
  76094. /**
  76095. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  76096. */
  76097. readonly isUsingTextureForMatrices: boolean;
  76098. /**
  76099. * Creates a new skeleton
  76100. * @param name defines the skeleton name
  76101. * @param id defines the skeleton Id
  76102. * @param scene defines the hosting scene
  76103. */
  76104. constructor(
  76105. /** defines the skeleton name */
  76106. name: string,
  76107. /** defines the skeleton Id */
  76108. id: string, scene: Scene);
  76109. /**
  76110. * Gets the current object class name.
  76111. * @return the class name
  76112. */
  76113. getClassName(): string;
  76114. /**
  76115. * Returns an array containing the root bones
  76116. * @returns an array containing the root bones
  76117. */
  76118. getChildren(): Array<Bone>;
  76119. /**
  76120. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  76121. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  76122. * @returns a Float32Array containing matrices data
  76123. */
  76124. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  76125. /**
  76126. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  76127. * @returns a raw texture containing the data
  76128. */
  76129. getTransformMatrixTexture(): Nullable<RawTexture>;
  76130. /**
  76131. * Gets the current hosting scene
  76132. * @returns a scene object
  76133. */
  76134. getScene(): Scene;
  76135. /**
  76136. * Gets a string representing the current skeleton data
  76137. * @param fullDetails defines a boolean indicating if we want a verbose version
  76138. * @returns a string representing the current skeleton data
  76139. */
  76140. toString(fullDetails?: boolean): string;
  76141. /**
  76142. * Get bone's index searching by name
  76143. * @param name defines bone's name to search for
  76144. * @return the indice of the bone. Returns -1 if not found
  76145. */
  76146. getBoneIndexByName(name: string): number;
  76147. /**
  76148. * Creater a new animation range
  76149. * @param name defines the name of the range
  76150. * @param from defines the start key
  76151. * @param to defines the end key
  76152. */
  76153. createAnimationRange(name: string, from: number, to: number): void;
  76154. /**
  76155. * Delete a specific animation range
  76156. * @param name defines the name of the range
  76157. * @param deleteFrames defines if frames must be removed as well
  76158. */
  76159. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  76160. /**
  76161. * Gets a specific animation range
  76162. * @param name defines the name of the range to look for
  76163. * @returns the requested animation range or null if not found
  76164. */
  76165. getAnimationRange(name: string): Nullable<AnimationRange>;
  76166. /**
  76167. * Gets the list of all animation ranges defined on this skeleton
  76168. * @returns an array
  76169. */
  76170. getAnimationRanges(): Nullable<AnimationRange>[];
  76171. /**
  76172. * Copy animation range from a source skeleton.
  76173. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  76174. * @param source defines the source skeleton
  76175. * @param name defines the name of the range to copy
  76176. * @param rescaleAsRequired defines if rescaling must be applied if required
  76177. * @returns true if operation was successful
  76178. */
  76179. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  76180. /**
  76181. * Forces the skeleton to go to rest pose
  76182. */
  76183. returnToRest(): void;
  76184. private _getHighestAnimationFrame;
  76185. /**
  76186. * Begin a specific animation range
  76187. * @param name defines the name of the range to start
  76188. * @param loop defines if looping must be turned on (false by default)
  76189. * @param speedRatio defines the speed ratio to apply (1 by default)
  76190. * @param onAnimationEnd defines a callback which will be called when animation will end
  76191. * @returns a new animatable
  76192. */
  76193. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  76194. /** @hidden */
  76195. _markAsDirty(): void;
  76196. /** @hidden */
  76197. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76198. /** @hidden */
  76199. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76200. private _computeTransformMatrices;
  76201. /**
  76202. * Build all resources required to render a skeleton
  76203. */
  76204. prepare(): void;
  76205. /**
  76206. * Gets the list of animatables currently running for this skeleton
  76207. * @returns an array of animatables
  76208. */
  76209. getAnimatables(): IAnimatable[];
  76210. /**
  76211. * Clone the current skeleton
  76212. * @param name defines the name of the new skeleton
  76213. * @param id defines the id of the enw skeleton
  76214. * @returns the new skeleton
  76215. */
  76216. clone(name: string, id: string): Skeleton;
  76217. /**
  76218. * Enable animation blending for this skeleton
  76219. * @param blendingSpeed defines the blending speed to apply
  76220. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76221. */
  76222. enableBlending(blendingSpeed?: number): void;
  76223. /**
  76224. * Releases all resources associated with the current skeleton
  76225. */
  76226. dispose(): void;
  76227. /**
  76228. * Serialize the skeleton in a JSON object
  76229. * @returns a JSON object
  76230. */
  76231. serialize(): any;
  76232. /**
  76233. * Creates a new skeleton from serialized data
  76234. * @param parsedSkeleton defines the serialized data
  76235. * @param scene defines the hosting scene
  76236. * @returns a new skeleton
  76237. */
  76238. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  76239. /**
  76240. * Compute all node absolute transforms
  76241. * @param forceUpdate defines if computation must be done even if cache is up to date
  76242. */
  76243. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  76244. /**
  76245. * Gets the root pose matrix
  76246. * @returns a matrix
  76247. */
  76248. getPoseMatrix(): Nullable<Matrix>;
  76249. /**
  76250. * Sorts bones per internal index
  76251. */
  76252. sortBones(): void;
  76253. private _sortBones;
  76254. }
  76255. }
  76256. declare module BABYLON {
  76257. /**
  76258. * Defines a target to use with MorphTargetManager
  76259. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76260. */
  76261. export class MorphTarget implements IAnimatable {
  76262. /** defines the name of the target */
  76263. name: string;
  76264. /**
  76265. * Gets or sets the list of animations
  76266. */
  76267. animations: Animation[];
  76268. private _scene;
  76269. private _positions;
  76270. private _normals;
  76271. private _tangents;
  76272. private _influence;
  76273. /**
  76274. * Observable raised when the influence changes
  76275. */
  76276. onInfluenceChanged: Observable<boolean>;
  76277. /** @hidden */
  76278. _onDataLayoutChanged: Observable<void>;
  76279. /**
  76280. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  76281. */
  76282. influence: number;
  76283. /**
  76284. * Gets or sets the id of the morph Target
  76285. */
  76286. id: string;
  76287. private _animationPropertiesOverride;
  76288. /**
  76289. * Gets or sets the animation properties override
  76290. */
  76291. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76292. /**
  76293. * Creates a new MorphTarget
  76294. * @param name defines the name of the target
  76295. * @param influence defines the influence to use
  76296. * @param scene defines the scene the morphtarget belongs to
  76297. */
  76298. constructor(
  76299. /** defines the name of the target */
  76300. name: string, influence?: number, scene?: Nullable<Scene>);
  76301. /**
  76302. * Gets a boolean defining if the target contains position data
  76303. */
  76304. readonly hasPositions: boolean;
  76305. /**
  76306. * Gets a boolean defining if the target contains normal data
  76307. */
  76308. readonly hasNormals: boolean;
  76309. /**
  76310. * Gets a boolean defining if the target contains tangent data
  76311. */
  76312. readonly hasTangents: boolean;
  76313. /**
  76314. * Affects position data to this target
  76315. * @param data defines the position data to use
  76316. */
  76317. setPositions(data: Nullable<FloatArray>): void;
  76318. /**
  76319. * Gets the position data stored in this target
  76320. * @returns a FloatArray containing the position data (or null if not present)
  76321. */
  76322. getPositions(): Nullable<FloatArray>;
  76323. /**
  76324. * Affects normal data to this target
  76325. * @param data defines the normal data to use
  76326. */
  76327. setNormals(data: Nullable<FloatArray>): void;
  76328. /**
  76329. * Gets the normal data stored in this target
  76330. * @returns a FloatArray containing the normal data (or null if not present)
  76331. */
  76332. getNormals(): Nullable<FloatArray>;
  76333. /**
  76334. * Affects tangent data to this target
  76335. * @param data defines the tangent data to use
  76336. */
  76337. setTangents(data: Nullable<FloatArray>): void;
  76338. /**
  76339. * Gets the tangent data stored in this target
  76340. * @returns a FloatArray containing the tangent data (or null if not present)
  76341. */
  76342. getTangents(): Nullable<FloatArray>;
  76343. /**
  76344. * Serializes the current target into a Serialization object
  76345. * @returns the serialized object
  76346. */
  76347. serialize(): any;
  76348. /**
  76349. * Returns the string "MorphTarget"
  76350. * @returns "MorphTarget"
  76351. */
  76352. getClassName(): string;
  76353. /**
  76354. * Creates a new target from serialized data
  76355. * @param serializationObject defines the serialized data to use
  76356. * @returns a new MorphTarget
  76357. */
  76358. static Parse(serializationObject: any): MorphTarget;
  76359. /**
  76360. * Creates a MorphTarget from mesh data
  76361. * @param mesh defines the source mesh
  76362. * @param name defines the name to use for the new target
  76363. * @param influence defines the influence to attach to the target
  76364. * @returns a new MorphTarget
  76365. */
  76366. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  76367. }
  76368. }
  76369. declare module BABYLON {
  76370. /**
  76371. * This class is used to deform meshes using morphing between different targets
  76372. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76373. */
  76374. export class MorphTargetManager {
  76375. private _targets;
  76376. private _targetInfluenceChangedObservers;
  76377. private _targetDataLayoutChangedObservers;
  76378. private _activeTargets;
  76379. private _scene;
  76380. private _influences;
  76381. private _supportsNormals;
  76382. private _supportsTangents;
  76383. private _vertexCount;
  76384. private _uniqueId;
  76385. private _tempInfluences;
  76386. /**
  76387. * Creates a new MorphTargetManager
  76388. * @param scene defines the current scene
  76389. */
  76390. constructor(scene?: Nullable<Scene>);
  76391. /**
  76392. * Gets the unique ID of this manager
  76393. */
  76394. readonly uniqueId: number;
  76395. /**
  76396. * Gets the number of vertices handled by this manager
  76397. */
  76398. readonly vertexCount: number;
  76399. /**
  76400. * Gets a boolean indicating if this manager supports morphing of normals
  76401. */
  76402. readonly supportsNormals: boolean;
  76403. /**
  76404. * Gets a boolean indicating if this manager supports morphing of tangents
  76405. */
  76406. readonly supportsTangents: boolean;
  76407. /**
  76408. * Gets the number of targets stored in this manager
  76409. */
  76410. readonly numTargets: number;
  76411. /**
  76412. * Gets the number of influencers (ie. the number of targets with influences > 0)
  76413. */
  76414. readonly numInfluencers: number;
  76415. /**
  76416. * Gets the list of influences (one per target)
  76417. */
  76418. readonly influences: Float32Array;
  76419. /**
  76420. * Gets the active target at specified index. An active target is a target with an influence > 0
  76421. * @param index defines the index to check
  76422. * @returns the requested target
  76423. */
  76424. getActiveTarget(index: number): MorphTarget;
  76425. /**
  76426. * Gets the target at specified index
  76427. * @param index defines the index to check
  76428. * @returns the requested target
  76429. */
  76430. getTarget(index: number): MorphTarget;
  76431. /**
  76432. * Add a new target to this manager
  76433. * @param target defines the target to add
  76434. */
  76435. addTarget(target: MorphTarget): void;
  76436. /**
  76437. * Removes a target from the manager
  76438. * @param target defines the target to remove
  76439. */
  76440. removeTarget(target: MorphTarget): void;
  76441. /**
  76442. * Serializes the current manager into a Serialization object
  76443. * @returns the serialized object
  76444. */
  76445. serialize(): any;
  76446. private _syncActiveTargets;
  76447. /**
  76448. * Syncrhonize the targets with all the meshes using this morph target manager
  76449. */
  76450. synchronize(): void;
  76451. /**
  76452. * Creates a new MorphTargetManager from serialized data
  76453. * @param serializationObject defines the serialized data
  76454. * @param scene defines the hosting scene
  76455. * @returns the new MorphTargetManager
  76456. */
  76457. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  76458. }
  76459. }
  76460. declare module BABYLON {
  76461. /**
  76462. * Mesh representing the gorund
  76463. */
  76464. export class GroundMesh extends Mesh {
  76465. /** If octree should be generated */
  76466. generateOctree: boolean;
  76467. private _heightQuads;
  76468. /** @hidden */
  76469. _subdivisionsX: number;
  76470. /** @hidden */
  76471. _subdivisionsY: number;
  76472. /** @hidden */
  76473. _width: number;
  76474. /** @hidden */
  76475. _height: number;
  76476. /** @hidden */
  76477. _minX: number;
  76478. /** @hidden */
  76479. _maxX: number;
  76480. /** @hidden */
  76481. _minZ: number;
  76482. /** @hidden */
  76483. _maxZ: number;
  76484. constructor(name: string, scene: Scene);
  76485. /**
  76486. * "GroundMesh"
  76487. * @returns "GroundMesh"
  76488. */
  76489. getClassName(): string;
  76490. /**
  76491. * The minimum of x and y subdivisions
  76492. */
  76493. readonly subdivisions: number;
  76494. /**
  76495. * X subdivisions
  76496. */
  76497. readonly subdivisionsX: number;
  76498. /**
  76499. * Y subdivisions
  76500. */
  76501. readonly subdivisionsY: number;
  76502. /**
  76503. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  76504. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  76505. * @param chunksCount the number of subdivisions for x and y
  76506. * @param octreeBlocksSize (Default: 32)
  76507. */
  76508. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  76509. /**
  76510. * Returns a height (y) value in the Worl system :
  76511. * the ground altitude at the coordinates (x, z) expressed in the World system.
  76512. * @param x x coordinate
  76513. * @param z z coordinate
  76514. * @returns the ground y position if (x, z) are outside the ground surface.
  76515. */
  76516. getHeightAtCoordinates(x: number, z: number): number;
  76517. /**
  76518. * Returns a normalized vector (Vector3) orthogonal to the ground
  76519. * at the ground coordinates (x, z) expressed in the World system.
  76520. * @param x x coordinate
  76521. * @param z z coordinate
  76522. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  76523. */
  76524. getNormalAtCoordinates(x: number, z: number): Vector3;
  76525. /**
  76526. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  76527. * at the ground coordinates (x, z) expressed in the World system.
  76528. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  76529. * @param x x coordinate
  76530. * @param z z coordinate
  76531. * @param ref vector to store the result
  76532. * @returns the GroundMesh.
  76533. */
  76534. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  76535. /**
  76536. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  76537. * if the ground has been updated.
  76538. * This can be used in the render loop.
  76539. * @returns the GroundMesh.
  76540. */
  76541. updateCoordinateHeights(): GroundMesh;
  76542. private _getFacetAt;
  76543. private _initHeightQuads;
  76544. private _computeHeightQuads;
  76545. /**
  76546. * Serializes this ground mesh
  76547. * @param serializationObject object to write serialization to
  76548. */
  76549. serialize(serializationObject: any): void;
  76550. /**
  76551. * Parses a serialized ground mesh
  76552. * @param parsedMesh the serialized mesh
  76553. * @param scene the scene to create the ground mesh in
  76554. * @returns the created ground mesh
  76555. */
  76556. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  76557. }
  76558. }
  76559. declare module BABYLON {
  76560. /**
  76561. * Interface for Physics-Joint data
  76562. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76563. */
  76564. export interface PhysicsJointData {
  76565. /**
  76566. * The main pivot of the joint
  76567. */
  76568. mainPivot?: Vector3;
  76569. /**
  76570. * The connected pivot of the joint
  76571. */
  76572. connectedPivot?: Vector3;
  76573. /**
  76574. * The main axis of the joint
  76575. */
  76576. mainAxis?: Vector3;
  76577. /**
  76578. * The connected axis of the joint
  76579. */
  76580. connectedAxis?: Vector3;
  76581. /**
  76582. * The collision of the joint
  76583. */
  76584. collision?: boolean;
  76585. /**
  76586. * Native Oimo/Cannon/Energy data
  76587. */
  76588. nativeParams?: any;
  76589. }
  76590. /**
  76591. * This is a holder class for the physics joint created by the physics plugin
  76592. * It holds a set of functions to control the underlying joint
  76593. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76594. */
  76595. export class PhysicsJoint {
  76596. /**
  76597. * The type of the physics joint
  76598. */
  76599. type: number;
  76600. /**
  76601. * The data for the physics joint
  76602. */
  76603. jointData: PhysicsJointData;
  76604. private _physicsJoint;
  76605. protected _physicsPlugin: IPhysicsEnginePlugin;
  76606. /**
  76607. * Initializes the physics joint
  76608. * @param type The type of the physics joint
  76609. * @param jointData The data for the physics joint
  76610. */
  76611. constructor(
  76612. /**
  76613. * The type of the physics joint
  76614. */
  76615. type: number,
  76616. /**
  76617. * The data for the physics joint
  76618. */
  76619. jointData: PhysicsJointData);
  76620. /**
  76621. * Gets the physics joint
  76622. */
  76623. /**
  76624. * Sets the physics joint
  76625. */
  76626. physicsJoint: any;
  76627. /**
  76628. * Sets the physics plugin
  76629. */
  76630. physicsPlugin: IPhysicsEnginePlugin;
  76631. /**
  76632. * Execute a function that is physics-plugin specific.
  76633. * @param {Function} func the function that will be executed.
  76634. * It accepts two parameters: the physics world and the physics joint
  76635. */
  76636. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  76637. /**
  76638. * Distance-Joint type
  76639. */
  76640. static DistanceJoint: number;
  76641. /**
  76642. * Hinge-Joint type
  76643. */
  76644. static HingeJoint: number;
  76645. /**
  76646. * Ball-and-Socket joint type
  76647. */
  76648. static BallAndSocketJoint: number;
  76649. /**
  76650. * Wheel-Joint type
  76651. */
  76652. static WheelJoint: number;
  76653. /**
  76654. * Slider-Joint type
  76655. */
  76656. static SliderJoint: number;
  76657. /**
  76658. * Prismatic-Joint type
  76659. */
  76660. static PrismaticJoint: number;
  76661. /**
  76662. * Universal-Joint type
  76663. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  76664. */
  76665. static UniversalJoint: number;
  76666. /**
  76667. * Hinge-Joint 2 type
  76668. */
  76669. static Hinge2Joint: number;
  76670. /**
  76671. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  76672. */
  76673. static PointToPointJoint: number;
  76674. /**
  76675. * Spring-Joint type
  76676. */
  76677. static SpringJoint: number;
  76678. /**
  76679. * Lock-Joint type
  76680. */
  76681. static LockJoint: number;
  76682. }
  76683. /**
  76684. * A class representing a physics distance joint
  76685. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76686. */
  76687. export class DistanceJoint extends PhysicsJoint {
  76688. /**
  76689. *
  76690. * @param jointData The data for the Distance-Joint
  76691. */
  76692. constructor(jointData: DistanceJointData);
  76693. /**
  76694. * Update the predefined distance.
  76695. * @param maxDistance The maximum preferred distance
  76696. * @param minDistance The minimum preferred distance
  76697. */
  76698. updateDistance(maxDistance: number, minDistance?: number): void;
  76699. }
  76700. /**
  76701. * Represents a Motor-Enabled Joint
  76702. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76703. */
  76704. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  76705. /**
  76706. * Initializes the Motor-Enabled Joint
  76707. * @param type The type of the joint
  76708. * @param jointData The physica joint data for the joint
  76709. */
  76710. constructor(type: number, jointData: PhysicsJointData);
  76711. /**
  76712. * Set the motor values.
  76713. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76714. * @param force the force to apply
  76715. * @param maxForce max force for this motor.
  76716. */
  76717. setMotor(force?: number, maxForce?: number): void;
  76718. /**
  76719. * Set the motor's limits.
  76720. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76721. * @param upperLimit The upper limit of the motor
  76722. * @param lowerLimit The lower limit of the motor
  76723. */
  76724. setLimit(upperLimit: number, lowerLimit?: number): void;
  76725. }
  76726. /**
  76727. * This class represents a single physics Hinge-Joint
  76728. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76729. */
  76730. export class HingeJoint extends MotorEnabledJoint {
  76731. /**
  76732. * Initializes the Hinge-Joint
  76733. * @param jointData The joint data for the Hinge-Joint
  76734. */
  76735. constructor(jointData: PhysicsJointData);
  76736. /**
  76737. * Set the motor values.
  76738. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76739. * @param {number} force the force to apply
  76740. * @param {number} maxForce max force for this motor.
  76741. */
  76742. setMotor(force?: number, maxForce?: number): void;
  76743. /**
  76744. * Set the motor's limits.
  76745. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76746. * @param upperLimit The upper limit of the motor
  76747. * @param lowerLimit The lower limit of the motor
  76748. */
  76749. setLimit(upperLimit: number, lowerLimit?: number): void;
  76750. }
  76751. /**
  76752. * This class represents a dual hinge physics joint (same as wheel joint)
  76753. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76754. */
  76755. export class Hinge2Joint extends MotorEnabledJoint {
  76756. /**
  76757. * Initializes the Hinge2-Joint
  76758. * @param jointData The joint data for the Hinge2-Joint
  76759. */
  76760. constructor(jointData: PhysicsJointData);
  76761. /**
  76762. * Set the motor values.
  76763. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76764. * @param {number} targetSpeed the speed the motor is to reach
  76765. * @param {number} maxForce max force for this motor.
  76766. * @param {motorIndex} the motor's index, 0 or 1.
  76767. */
  76768. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  76769. /**
  76770. * Set the motor limits.
  76771. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76772. * @param {number} upperLimit the upper limit
  76773. * @param {number} lowerLimit lower limit
  76774. * @param {motorIndex} the motor's index, 0 or 1.
  76775. */
  76776. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76777. }
  76778. /**
  76779. * Interface for a motor enabled joint
  76780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76781. */
  76782. export interface IMotorEnabledJoint {
  76783. /**
  76784. * Physics joint
  76785. */
  76786. physicsJoint: any;
  76787. /**
  76788. * Sets the motor of the motor-enabled joint
  76789. * @param force The force of the motor
  76790. * @param maxForce The maximum force of the motor
  76791. * @param motorIndex The index of the motor
  76792. */
  76793. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  76794. /**
  76795. * Sets the limit of the motor
  76796. * @param upperLimit The upper limit of the motor
  76797. * @param lowerLimit The lower limit of the motor
  76798. * @param motorIndex The index of the motor
  76799. */
  76800. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76801. }
  76802. /**
  76803. * Joint data for a Distance-Joint
  76804. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76805. */
  76806. export interface DistanceJointData extends PhysicsJointData {
  76807. /**
  76808. * Max distance the 2 joint objects can be apart
  76809. */
  76810. maxDistance: number;
  76811. }
  76812. /**
  76813. * Joint data from a spring joint
  76814. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76815. */
  76816. export interface SpringJointData extends PhysicsJointData {
  76817. /**
  76818. * Length of the spring
  76819. */
  76820. length: number;
  76821. /**
  76822. * Stiffness of the spring
  76823. */
  76824. stiffness: number;
  76825. /**
  76826. * Damping of the spring
  76827. */
  76828. damping: number;
  76829. /** this callback will be called when applying the force to the impostors. */
  76830. forceApplicationCallback: () => void;
  76831. }
  76832. }
  76833. declare module BABYLON {
  76834. /**
  76835. * Interface used to describe a physics joint
  76836. */
  76837. export interface PhysicsImpostorJoint {
  76838. /** Defines the main impostor to which the joint is linked */
  76839. mainImpostor: PhysicsImpostor;
  76840. /** Defines the impostor that is connected to the main impostor using this joint */
  76841. connectedImpostor: PhysicsImpostor;
  76842. /** Defines the joint itself */
  76843. joint: PhysicsJoint;
  76844. }
  76845. /** @hidden */
  76846. export interface IPhysicsEnginePlugin {
  76847. world: any;
  76848. name: string;
  76849. setGravity(gravity: Vector3): void;
  76850. setTimeStep(timeStep: number): void;
  76851. getTimeStep(): number;
  76852. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  76853. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76854. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76855. generatePhysicsBody(impostor: PhysicsImpostor): void;
  76856. removePhysicsBody(impostor: PhysicsImpostor): void;
  76857. generateJoint(joint: PhysicsImpostorJoint): void;
  76858. removeJoint(joint: PhysicsImpostorJoint): void;
  76859. isSupported(): boolean;
  76860. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  76861. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  76862. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76863. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76864. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76865. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76866. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  76867. getBodyMass(impostor: PhysicsImpostor): number;
  76868. getBodyFriction(impostor: PhysicsImpostor): number;
  76869. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  76870. getBodyRestitution(impostor: PhysicsImpostor): number;
  76871. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  76872. sleepBody(impostor: PhysicsImpostor): void;
  76873. wakeUpBody(impostor: PhysicsImpostor): void;
  76874. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  76875. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  76876. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76877. getRadius(impostor: PhysicsImpostor): number;
  76878. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  76879. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  76880. dispose(): void;
  76881. }
  76882. /**
  76883. * Interface used to define a physics engine
  76884. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  76885. */
  76886. export interface IPhysicsEngine {
  76887. /**
  76888. * Gets the gravity vector used by the simulation
  76889. */
  76890. gravity: Vector3;
  76891. /**
  76892. * Sets the gravity vector used by the simulation
  76893. * @param gravity defines the gravity vector to use
  76894. */
  76895. setGravity(gravity: Vector3): void;
  76896. /**
  76897. * Set the time step of the physics engine.
  76898. * Default is 1/60.
  76899. * To slow it down, enter 1/600 for example.
  76900. * To speed it up, 1/30
  76901. * @param newTimeStep the new timestep to apply to this world.
  76902. */
  76903. setTimeStep(newTimeStep: number): void;
  76904. /**
  76905. * Get the time step of the physics engine.
  76906. * @returns the current time step
  76907. */
  76908. getTimeStep(): number;
  76909. /**
  76910. * Release all resources
  76911. */
  76912. dispose(): void;
  76913. /**
  76914. * Gets the name of the current physics plugin
  76915. * @returns the name of the plugin
  76916. */
  76917. getPhysicsPluginName(): string;
  76918. /**
  76919. * Adding a new impostor for the impostor tracking.
  76920. * This will be done by the impostor itself.
  76921. * @param impostor the impostor to add
  76922. */
  76923. addImpostor(impostor: PhysicsImpostor): void;
  76924. /**
  76925. * Remove an impostor from the engine.
  76926. * This impostor and its mesh will not longer be updated by the physics engine.
  76927. * @param impostor the impostor to remove
  76928. */
  76929. removeImpostor(impostor: PhysicsImpostor): void;
  76930. /**
  76931. * Add a joint to the physics engine
  76932. * @param mainImpostor defines the main impostor to which the joint is added.
  76933. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  76934. * @param joint defines the joint that will connect both impostors.
  76935. */
  76936. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76937. /**
  76938. * Removes a joint from the simulation
  76939. * @param mainImpostor defines the impostor used with the joint
  76940. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  76941. * @param joint defines the joint to remove
  76942. */
  76943. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76944. /**
  76945. * Gets the current plugin used to run the simulation
  76946. * @returns current plugin
  76947. */
  76948. getPhysicsPlugin(): IPhysicsEnginePlugin;
  76949. /**
  76950. * Gets the list of physic impostors
  76951. * @returns an array of PhysicsImpostor
  76952. */
  76953. getImpostors(): Array<PhysicsImpostor>;
  76954. /**
  76955. * Gets the impostor for a physics enabled object
  76956. * @param object defines the object impersonated by the impostor
  76957. * @returns the PhysicsImpostor or null if not found
  76958. */
  76959. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76960. /**
  76961. * Gets the impostor for a physics body object
  76962. * @param body defines physics body used by the impostor
  76963. * @returns the PhysicsImpostor or null if not found
  76964. */
  76965. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  76966. /**
  76967. * Called by the scene. No need to call it.
  76968. * @param delta defines the timespam between frames
  76969. */
  76970. _step(delta: number): void;
  76971. }
  76972. }
  76973. declare module BABYLON {
  76974. /**
  76975. * The interface for the physics imposter parameters
  76976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76977. */
  76978. export interface PhysicsImpostorParameters {
  76979. /**
  76980. * The mass of the physics imposter
  76981. */
  76982. mass: number;
  76983. /**
  76984. * The friction of the physics imposter
  76985. */
  76986. friction?: number;
  76987. /**
  76988. * The coefficient of restitution of the physics imposter
  76989. */
  76990. restitution?: number;
  76991. /**
  76992. * The native options of the physics imposter
  76993. */
  76994. nativeOptions?: any;
  76995. /**
  76996. * Specifies if the parent should be ignored
  76997. */
  76998. ignoreParent?: boolean;
  76999. /**
  77000. * Specifies if bi-directional transformations should be disabled
  77001. */
  77002. disableBidirectionalTransformation?: boolean;
  77003. }
  77004. /**
  77005. * Interface for a physics-enabled object
  77006. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77007. */
  77008. export interface IPhysicsEnabledObject {
  77009. /**
  77010. * The position of the physics-enabled object
  77011. */
  77012. position: Vector3;
  77013. /**
  77014. * The rotation of the physics-enabled object
  77015. */
  77016. rotationQuaternion: Nullable<Quaternion>;
  77017. /**
  77018. * The scale of the physics-enabled object
  77019. */
  77020. scaling: Vector3;
  77021. /**
  77022. * The rotation of the physics-enabled object
  77023. */
  77024. rotation?: Vector3;
  77025. /**
  77026. * The parent of the physics-enabled object
  77027. */
  77028. parent?: any;
  77029. /**
  77030. * The bounding info of the physics-enabled object
  77031. * @returns The bounding info of the physics-enabled object
  77032. */
  77033. getBoundingInfo(): BoundingInfo;
  77034. /**
  77035. * Computes the world matrix
  77036. * @param force Specifies if the world matrix should be computed by force
  77037. * @returns A world matrix
  77038. */
  77039. computeWorldMatrix(force: boolean): Matrix;
  77040. /**
  77041. * Gets the world matrix
  77042. * @returns A world matrix
  77043. */
  77044. getWorldMatrix?(): Matrix;
  77045. /**
  77046. * Gets the child meshes
  77047. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  77048. * @returns An array of abstract meshes
  77049. */
  77050. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  77051. /**
  77052. * Gets the vertex data
  77053. * @param kind The type of vertex data
  77054. * @returns A nullable array of numbers, or a float32 array
  77055. */
  77056. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  77057. /**
  77058. * Gets the indices from the mesh
  77059. * @returns A nullable array of index arrays
  77060. */
  77061. getIndices?(): Nullable<IndicesArray>;
  77062. /**
  77063. * Gets the scene from the mesh
  77064. * @returns the indices array or null
  77065. */
  77066. getScene?(): Scene;
  77067. /**
  77068. * Gets the absolute position from the mesh
  77069. * @returns the absolute position
  77070. */
  77071. getAbsolutePosition(): Vector3;
  77072. /**
  77073. * Gets the absolute pivot point from the mesh
  77074. * @returns the absolute pivot point
  77075. */
  77076. getAbsolutePivotPoint(): Vector3;
  77077. /**
  77078. * Rotates the mesh
  77079. * @param axis The axis of rotation
  77080. * @param amount The amount of rotation
  77081. * @param space The space of the rotation
  77082. * @returns The rotation transform node
  77083. */
  77084. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  77085. /**
  77086. * Translates the mesh
  77087. * @param axis The axis of translation
  77088. * @param distance The distance of translation
  77089. * @param space The space of the translation
  77090. * @returns The transform node
  77091. */
  77092. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  77093. /**
  77094. * Sets the absolute position of the mesh
  77095. * @param absolutePosition The absolute position of the mesh
  77096. * @returns The transform node
  77097. */
  77098. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  77099. /**
  77100. * Gets the class name of the mesh
  77101. * @returns The class name
  77102. */
  77103. getClassName(): string;
  77104. }
  77105. /**
  77106. * Represents a physics imposter
  77107. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77108. */
  77109. export class PhysicsImpostor {
  77110. /**
  77111. * The physics-enabled object used as the physics imposter
  77112. */
  77113. object: IPhysicsEnabledObject;
  77114. /**
  77115. * The type of the physics imposter
  77116. */
  77117. type: number;
  77118. private _options;
  77119. private _scene?;
  77120. /**
  77121. * The default object size of the imposter
  77122. */
  77123. static DEFAULT_OBJECT_SIZE: Vector3;
  77124. /**
  77125. * The identity quaternion of the imposter
  77126. */
  77127. static IDENTITY_QUATERNION: Quaternion;
  77128. /** @hidden */
  77129. _pluginData: any;
  77130. private _physicsEngine;
  77131. private _physicsBody;
  77132. private _bodyUpdateRequired;
  77133. private _onBeforePhysicsStepCallbacks;
  77134. private _onAfterPhysicsStepCallbacks;
  77135. /** @hidden */
  77136. _onPhysicsCollideCallbacks: Array<{
  77137. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  77138. otherImpostors: Array<PhysicsImpostor>;
  77139. }>;
  77140. private _deltaPosition;
  77141. private _deltaRotation;
  77142. private _deltaRotationConjugated;
  77143. private _parent;
  77144. private _isDisposed;
  77145. private static _tmpVecs;
  77146. private static _tmpQuat;
  77147. /**
  77148. * Specifies if the physics imposter is disposed
  77149. */
  77150. readonly isDisposed: boolean;
  77151. /**
  77152. * Gets the mass of the physics imposter
  77153. */
  77154. mass: number;
  77155. /**
  77156. * Gets the coefficient of friction
  77157. */
  77158. /**
  77159. * Sets the coefficient of friction
  77160. */
  77161. friction: number;
  77162. /**
  77163. * Gets the coefficient of restitution
  77164. */
  77165. /**
  77166. * Sets the coefficient of restitution
  77167. */
  77168. restitution: number;
  77169. /**
  77170. * The unique id of the physics imposter
  77171. * set by the physics engine when adding this impostor to the array
  77172. */
  77173. uniqueId: number;
  77174. private _joints;
  77175. /**
  77176. * Initializes the physics imposter
  77177. * @param object The physics-enabled object used as the physics imposter
  77178. * @param type The type of the physics imposter
  77179. * @param _options The options for the physics imposter
  77180. * @param _scene The Babylon scene
  77181. */
  77182. constructor(
  77183. /**
  77184. * The physics-enabled object used as the physics imposter
  77185. */
  77186. object: IPhysicsEnabledObject,
  77187. /**
  77188. * The type of the physics imposter
  77189. */
  77190. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  77191. /**
  77192. * This function will completly initialize this impostor.
  77193. * It will create a new body - but only if this mesh has no parent.
  77194. * If it has, this impostor will not be used other than to define the impostor
  77195. * of the child mesh.
  77196. * @hidden
  77197. */
  77198. _init(): void;
  77199. private _getPhysicsParent;
  77200. /**
  77201. * Should a new body be generated.
  77202. * @returns boolean specifying if body initialization is required
  77203. */
  77204. isBodyInitRequired(): boolean;
  77205. /**
  77206. * Sets the updated scaling
  77207. * @param updated Specifies if the scaling is updated
  77208. */
  77209. setScalingUpdated(): void;
  77210. /**
  77211. * Force a regeneration of this or the parent's impostor's body.
  77212. * Use under cautious - This will remove all joints already implemented.
  77213. */
  77214. forceUpdate(): void;
  77215. /**
  77216. * Gets the body that holds this impostor. Either its own, or its parent.
  77217. */
  77218. /**
  77219. * Set the physics body. Used mainly by the physics engine/plugin
  77220. */
  77221. physicsBody: any;
  77222. /**
  77223. * Get the parent of the physics imposter
  77224. * @returns Physics imposter or null
  77225. */
  77226. /**
  77227. * Sets the parent of the physics imposter
  77228. */
  77229. parent: Nullable<PhysicsImpostor>;
  77230. /**
  77231. * Resets the update flags
  77232. */
  77233. resetUpdateFlags(): void;
  77234. /**
  77235. * Gets the object extend size
  77236. * @returns the object extend size
  77237. */
  77238. getObjectExtendSize(): Vector3;
  77239. /**
  77240. * Gets the object center
  77241. * @returns The object center
  77242. */
  77243. getObjectCenter(): Vector3;
  77244. /**
  77245. * Get a specific parametes from the options parameter
  77246. * @param paramName The object parameter name
  77247. * @returns The object parameter
  77248. */
  77249. getParam(paramName: string): any;
  77250. /**
  77251. * Sets a specific parameter in the options given to the physics plugin
  77252. * @param paramName The parameter name
  77253. * @param value The value of the parameter
  77254. */
  77255. setParam(paramName: string, value: number): void;
  77256. /**
  77257. * Specifically change the body's mass option. Won't recreate the physics body object
  77258. * @param mass The mass of the physics imposter
  77259. */
  77260. setMass(mass: number): void;
  77261. /**
  77262. * Gets the linear velocity
  77263. * @returns linear velocity or null
  77264. */
  77265. getLinearVelocity(): Nullable<Vector3>;
  77266. /**
  77267. * Sets the linear velocity
  77268. * @param velocity linear velocity or null
  77269. */
  77270. setLinearVelocity(velocity: Nullable<Vector3>): void;
  77271. /**
  77272. * Gets the angular velocity
  77273. * @returns angular velocity or null
  77274. */
  77275. getAngularVelocity(): Nullable<Vector3>;
  77276. /**
  77277. * Sets the angular velocity
  77278. * @param velocity The velocity or null
  77279. */
  77280. setAngularVelocity(velocity: Nullable<Vector3>): void;
  77281. /**
  77282. * Execute a function with the physics plugin native code
  77283. * Provide a function the will have two variables - the world object and the physics body object
  77284. * @param func The function to execute with the physics plugin native code
  77285. */
  77286. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  77287. /**
  77288. * Register a function that will be executed before the physics world is stepping forward
  77289. * @param func The function to execute before the physics world is stepped forward
  77290. */
  77291. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77292. /**
  77293. * Unregister a function that will be executed before the physics world is stepping forward
  77294. * @param func The function to execute before the physics world is stepped forward
  77295. */
  77296. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77297. /**
  77298. * Register a function that will be executed after the physics step
  77299. * @param func The function to execute after physics step
  77300. */
  77301. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77302. /**
  77303. * Unregisters a function that will be executed after the physics step
  77304. * @param func The function to execute after physics step
  77305. */
  77306. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77307. /**
  77308. * register a function that will be executed when this impostor collides against a different body
  77309. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  77310. * @param func Callback that is executed on collision
  77311. */
  77312. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  77313. /**
  77314. * Unregisters the physics imposter on contact
  77315. * @param collideAgainst The physics object to collide against
  77316. * @param func Callback to execute on collision
  77317. */
  77318. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  77319. private _tmpQuat;
  77320. private _tmpQuat2;
  77321. /**
  77322. * Get the parent rotation
  77323. * @returns The parent rotation
  77324. */
  77325. getParentsRotation(): Quaternion;
  77326. /**
  77327. * this function is executed by the physics engine.
  77328. */
  77329. beforeStep: () => void;
  77330. /**
  77331. * this function is executed by the physics engine
  77332. */
  77333. afterStep: () => void;
  77334. /**
  77335. * Legacy collision detection event support
  77336. */
  77337. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  77338. /**
  77339. * event and body object due to cannon's event-based architecture.
  77340. */
  77341. onCollide: (e: {
  77342. body: any;
  77343. }) => void;
  77344. /**
  77345. * Apply a force
  77346. * @param force The force to apply
  77347. * @param contactPoint The contact point for the force
  77348. * @returns The physics imposter
  77349. */
  77350. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77351. /**
  77352. * Apply an impulse
  77353. * @param force The impulse force
  77354. * @param contactPoint The contact point for the impulse force
  77355. * @returns The physics imposter
  77356. */
  77357. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77358. /**
  77359. * A help function to create a joint
  77360. * @param otherImpostor A physics imposter used to create a joint
  77361. * @param jointType The type of joint
  77362. * @param jointData The data for the joint
  77363. * @returns The physics imposter
  77364. */
  77365. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  77366. /**
  77367. * Add a joint to this impostor with a different impostor
  77368. * @param otherImpostor A physics imposter used to add a joint
  77369. * @param joint The joint to add
  77370. * @returns The physics imposter
  77371. */
  77372. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  77373. /**
  77374. * Will keep this body still, in a sleep mode.
  77375. * @returns the physics imposter
  77376. */
  77377. sleep(): PhysicsImpostor;
  77378. /**
  77379. * Wake the body up.
  77380. * @returns The physics imposter
  77381. */
  77382. wakeUp(): PhysicsImpostor;
  77383. /**
  77384. * Clones the physics imposter
  77385. * @param newObject The physics imposter clones to this physics-enabled object
  77386. * @returns A nullable physics imposter
  77387. */
  77388. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  77389. /**
  77390. * Disposes the physics imposter
  77391. */
  77392. dispose(): void;
  77393. /**
  77394. * Sets the delta position
  77395. * @param position The delta position amount
  77396. */
  77397. setDeltaPosition(position: Vector3): void;
  77398. /**
  77399. * Sets the delta rotation
  77400. * @param rotation The delta rotation amount
  77401. */
  77402. setDeltaRotation(rotation: Quaternion): void;
  77403. /**
  77404. * Gets the box size of the physics imposter and stores the result in the input parameter
  77405. * @param result Stores the box size
  77406. * @returns The physics imposter
  77407. */
  77408. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  77409. /**
  77410. * Gets the radius of the physics imposter
  77411. * @returns Radius of the physics imposter
  77412. */
  77413. getRadius(): number;
  77414. /**
  77415. * Sync a bone with this impostor
  77416. * @param bone The bone to sync to the impostor.
  77417. * @param boneMesh The mesh that the bone is influencing.
  77418. * @param jointPivot The pivot of the joint / bone in local space.
  77419. * @param distToJoint Optional distance from the impostor to the joint.
  77420. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77421. */
  77422. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  77423. /**
  77424. * Sync impostor to a bone
  77425. * @param bone The bone that the impostor will be synced to.
  77426. * @param boneMesh The mesh that the bone is influencing.
  77427. * @param jointPivot The pivot of the joint / bone in local space.
  77428. * @param distToJoint Optional distance from the impostor to the joint.
  77429. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77430. * @param boneAxis Optional vector3 axis the bone is aligned with
  77431. */
  77432. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  77433. /**
  77434. * No-Imposter type
  77435. */
  77436. static NoImpostor: number;
  77437. /**
  77438. * Sphere-Imposter type
  77439. */
  77440. static SphereImpostor: number;
  77441. /**
  77442. * Box-Imposter type
  77443. */
  77444. static BoxImpostor: number;
  77445. /**
  77446. * Plane-Imposter type
  77447. */
  77448. static PlaneImpostor: number;
  77449. /**
  77450. * Mesh-imposter type
  77451. */
  77452. static MeshImpostor: number;
  77453. /**
  77454. * Cylinder-Imposter type
  77455. */
  77456. static CylinderImpostor: number;
  77457. /**
  77458. * Particle-Imposter type
  77459. */
  77460. static ParticleImpostor: number;
  77461. /**
  77462. * Heightmap-Imposter type
  77463. */
  77464. static HeightmapImpostor: number;
  77465. }
  77466. }
  77467. declare module BABYLON {
  77468. /**
  77469. * Class used to represent a specific level of detail of a mesh
  77470. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77471. */
  77472. export class MeshLODLevel {
  77473. /** Defines the distance where this level should star being displayed */
  77474. distance: number;
  77475. /** Defines the mesh to use to render this level */
  77476. mesh: Nullable<Mesh>;
  77477. /**
  77478. * Creates a new LOD level
  77479. * @param distance defines the distance where this level should star being displayed
  77480. * @param mesh defines the mesh to use to render this level
  77481. */
  77482. constructor(
  77483. /** Defines the distance where this level should star being displayed */
  77484. distance: number,
  77485. /** Defines the mesh to use to render this level */
  77486. mesh: Nullable<Mesh>);
  77487. }
  77488. /**
  77489. * @hidden
  77490. **/
  77491. export class _CreationDataStorage {
  77492. closePath?: boolean;
  77493. closeArray?: boolean;
  77494. idx: number[];
  77495. dashSize: number;
  77496. gapSize: number;
  77497. path3D: Path3D;
  77498. pathArray: Vector3[][];
  77499. arc: number;
  77500. radius: number;
  77501. cap: number;
  77502. tessellation: number;
  77503. }
  77504. /**
  77505. * @hidden
  77506. **/
  77507. class _InstanceDataStorage {
  77508. visibleInstances: any;
  77509. renderIdForInstances: number[];
  77510. batchCache: _InstancesBatch;
  77511. instancesBufferSize: number;
  77512. instancesBuffer: Nullable<Buffer>;
  77513. instancesData: Float32Array;
  77514. overridenInstanceCount: number;
  77515. }
  77516. /**
  77517. * @hidden
  77518. **/
  77519. export class _InstancesBatch {
  77520. mustReturn: boolean;
  77521. visibleInstances: Nullable<InstancedMesh[]>[];
  77522. renderSelf: boolean[];
  77523. }
  77524. /**
  77525. * Class used to represent renderable models
  77526. */
  77527. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  77528. /**
  77529. * Mesh side orientation : usually the external or front surface
  77530. */
  77531. static readonly FRONTSIDE: number;
  77532. /**
  77533. * Mesh side orientation : usually the internal or back surface
  77534. */
  77535. static readonly BACKSIDE: number;
  77536. /**
  77537. * Mesh side orientation : both internal and external or front and back surfaces
  77538. */
  77539. static readonly DOUBLESIDE: number;
  77540. /**
  77541. * Mesh side orientation : by default, `FRONTSIDE`
  77542. */
  77543. static readonly DEFAULTSIDE: number;
  77544. /**
  77545. * Mesh cap setting : no cap
  77546. */
  77547. static readonly NO_CAP: number;
  77548. /**
  77549. * Mesh cap setting : one cap at the beginning of the mesh
  77550. */
  77551. static readonly CAP_START: number;
  77552. /**
  77553. * Mesh cap setting : one cap at the end of the mesh
  77554. */
  77555. static readonly CAP_END: number;
  77556. /**
  77557. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  77558. */
  77559. static readonly CAP_ALL: number;
  77560. /**
  77561. * Gets the default side orientation.
  77562. * @param orientation the orientation to value to attempt to get
  77563. * @returns the default orientation
  77564. * @hidden
  77565. */
  77566. static _GetDefaultSideOrientation(orientation?: number): number;
  77567. private _onBeforeRenderObservable;
  77568. private _onBeforeBindObservable;
  77569. private _onAfterRenderObservable;
  77570. private _onBeforeDrawObservable;
  77571. /**
  77572. * An event triggered before rendering the mesh
  77573. */
  77574. readonly onBeforeRenderObservable: Observable<Mesh>;
  77575. /**
  77576. * An event triggered before binding the mesh
  77577. */
  77578. readonly onBeforeBindObservable: Observable<Mesh>;
  77579. /**
  77580. * An event triggered after rendering the mesh
  77581. */
  77582. readonly onAfterRenderObservable: Observable<Mesh>;
  77583. /**
  77584. * An event triggered before drawing the mesh
  77585. */
  77586. readonly onBeforeDrawObservable: Observable<Mesh>;
  77587. private _onBeforeDrawObserver;
  77588. /**
  77589. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  77590. */
  77591. onBeforeDraw: () => void;
  77592. /**
  77593. * Gets the delay loading state of the mesh (when delay loading is turned on)
  77594. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  77595. */
  77596. delayLoadState: number;
  77597. /**
  77598. * Gets the list of instances created from this mesh
  77599. * it is not supposed to be modified manually.
  77600. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  77601. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77602. */
  77603. instances: InstancedMesh[];
  77604. /**
  77605. * Gets the file containing delay loading data for this mesh
  77606. */
  77607. delayLoadingFile: string;
  77608. /** @hidden */
  77609. _binaryInfo: any;
  77610. private _LODLevels;
  77611. /**
  77612. * User defined function used to change how LOD level selection is done
  77613. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77614. */
  77615. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  77616. private _morphTargetManager;
  77617. /**
  77618. * Gets or sets the morph target manager
  77619. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77620. */
  77621. morphTargetManager: Nullable<MorphTargetManager>;
  77622. /** @hidden */
  77623. _creationDataStorage: Nullable<_CreationDataStorage>;
  77624. /** @hidden */
  77625. _geometry: Nullable<Geometry>;
  77626. /** @hidden */
  77627. _delayInfo: Array<string>;
  77628. /** @hidden */
  77629. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  77630. /** @hidden */
  77631. _instanceDataStorage: _InstanceDataStorage;
  77632. private _effectiveMaterial;
  77633. /** @hidden */
  77634. _shouldGenerateFlatShading: boolean;
  77635. private _preActivateId;
  77636. /** @hidden */
  77637. _originalBuilderSideOrientation: number;
  77638. /**
  77639. * Use this property to change the original side orientation defined at construction time
  77640. */
  77641. overrideMaterialSideOrientation: Nullable<number>;
  77642. private _areNormalsFrozen;
  77643. private _sourcePositions;
  77644. private _sourceNormals;
  77645. private _source;
  77646. private meshMap;
  77647. /**
  77648. * Gets the source mesh (the one used to clone this one from)
  77649. */
  77650. readonly source: Nullable<Mesh>;
  77651. /**
  77652. * Gets or sets a boolean indicating that this mesh does not use index buffer
  77653. */
  77654. isUnIndexed: boolean;
  77655. /**
  77656. * @constructor
  77657. * @param name The value used by scene.getMeshByName() to do a lookup.
  77658. * @param scene The scene to add this mesh to.
  77659. * @param parent The parent of this mesh, if it has one
  77660. * @param source An optional Mesh from which geometry is shared, cloned.
  77661. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77662. * When false, achieved by calling a clone(), also passing False.
  77663. * This will make creation of children, recursive.
  77664. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  77665. */
  77666. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  77667. /**
  77668. * Gets the class name
  77669. * @returns the string "Mesh".
  77670. */
  77671. getClassName(): string;
  77672. /** @hidden */
  77673. readonly _isMesh: boolean;
  77674. /**
  77675. * Returns a description of this mesh
  77676. * @param fullDetails define if full details about this mesh must be used
  77677. * @returns a descriptive string representing this mesh
  77678. */
  77679. toString(fullDetails?: boolean): string;
  77680. /** @hidden */
  77681. _unBindEffect(): void;
  77682. /**
  77683. * Gets a boolean indicating if this mesh has LOD
  77684. */
  77685. readonly hasLODLevels: boolean;
  77686. /**
  77687. * Gets the list of MeshLODLevel associated with the current mesh
  77688. * @returns an array of MeshLODLevel
  77689. */
  77690. getLODLevels(): MeshLODLevel[];
  77691. private _sortLODLevels;
  77692. /**
  77693. * Add a mesh as LOD level triggered at the given distance.
  77694. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77695. * @param distance The distance from the center of the object to show this level
  77696. * @param mesh The mesh to be added as LOD level (can be null)
  77697. * @return This mesh (for chaining)
  77698. */
  77699. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  77700. /**
  77701. * Returns the LOD level mesh at the passed distance or null if not found.
  77702. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77703. * @param distance The distance from the center of the object to show this level
  77704. * @returns a Mesh or `null`
  77705. */
  77706. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  77707. /**
  77708. * Remove a mesh from the LOD array
  77709. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77710. * @param mesh defines the mesh to be removed
  77711. * @return This mesh (for chaining)
  77712. */
  77713. removeLODLevel(mesh: Mesh): Mesh;
  77714. /**
  77715. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  77716. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77717. * @param camera defines the camera to use to compute distance
  77718. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  77719. * @return This mesh (for chaining)
  77720. */
  77721. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  77722. /**
  77723. * Gets the mesh internal Geometry object
  77724. */
  77725. readonly geometry: Nullable<Geometry>;
  77726. /**
  77727. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  77728. * @returns the total number of vertices
  77729. */
  77730. getTotalVertices(): number;
  77731. /**
  77732. * Returns the content of an associated vertex buffer
  77733. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77734. * - VertexBuffer.PositionKind
  77735. * - VertexBuffer.UVKind
  77736. * - VertexBuffer.UV2Kind
  77737. * - VertexBuffer.UV3Kind
  77738. * - VertexBuffer.UV4Kind
  77739. * - VertexBuffer.UV5Kind
  77740. * - VertexBuffer.UV6Kind
  77741. * - VertexBuffer.ColorKind
  77742. * - VertexBuffer.MatricesIndicesKind
  77743. * - VertexBuffer.MatricesIndicesExtraKind
  77744. * - VertexBuffer.MatricesWeightsKind
  77745. * - VertexBuffer.MatricesWeightsExtraKind
  77746. * @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
  77747. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  77748. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  77749. */
  77750. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77751. /**
  77752. * Returns the mesh VertexBuffer object from the requested `kind`
  77753. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77754. * - VertexBuffer.PositionKind
  77755. * - VertexBuffer.UVKind
  77756. * - VertexBuffer.UV2Kind
  77757. * - VertexBuffer.UV3Kind
  77758. * - VertexBuffer.UV4Kind
  77759. * - VertexBuffer.UV5Kind
  77760. * - VertexBuffer.UV6Kind
  77761. * - VertexBuffer.ColorKind
  77762. * - VertexBuffer.MatricesIndicesKind
  77763. * - VertexBuffer.MatricesIndicesExtraKind
  77764. * - VertexBuffer.MatricesWeightsKind
  77765. * - VertexBuffer.MatricesWeightsExtraKind
  77766. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  77767. */
  77768. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77769. /**
  77770. * Tests if a specific vertex buffer is associated with this mesh
  77771. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77772. * - VertexBuffer.PositionKind
  77773. * - VertexBuffer.UVKind
  77774. * - VertexBuffer.UV2Kind
  77775. * - VertexBuffer.UV3Kind
  77776. * - VertexBuffer.UV4Kind
  77777. * - VertexBuffer.UV5Kind
  77778. * - VertexBuffer.UV6Kind
  77779. * - VertexBuffer.ColorKind
  77780. * - VertexBuffer.MatricesIndicesKind
  77781. * - VertexBuffer.MatricesIndicesExtraKind
  77782. * - VertexBuffer.MatricesWeightsKind
  77783. * - VertexBuffer.MatricesWeightsExtraKind
  77784. * @returns a boolean
  77785. */
  77786. isVerticesDataPresent(kind: string): boolean;
  77787. /**
  77788. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  77789. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77790. * - VertexBuffer.PositionKind
  77791. * - VertexBuffer.UVKind
  77792. * - VertexBuffer.UV2Kind
  77793. * - VertexBuffer.UV3Kind
  77794. * - VertexBuffer.UV4Kind
  77795. * - VertexBuffer.UV5Kind
  77796. * - VertexBuffer.UV6Kind
  77797. * - VertexBuffer.ColorKind
  77798. * - VertexBuffer.MatricesIndicesKind
  77799. * - VertexBuffer.MatricesIndicesExtraKind
  77800. * - VertexBuffer.MatricesWeightsKind
  77801. * - VertexBuffer.MatricesWeightsExtraKind
  77802. * @returns a boolean
  77803. */
  77804. isVertexBufferUpdatable(kind: string): boolean;
  77805. /**
  77806. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  77807. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77808. * - VertexBuffer.PositionKind
  77809. * - VertexBuffer.UVKind
  77810. * - VertexBuffer.UV2Kind
  77811. * - VertexBuffer.UV3Kind
  77812. * - VertexBuffer.UV4Kind
  77813. * - VertexBuffer.UV5Kind
  77814. * - VertexBuffer.UV6Kind
  77815. * - VertexBuffer.ColorKind
  77816. * - VertexBuffer.MatricesIndicesKind
  77817. * - VertexBuffer.MatricesIndicesExtraKind
  77818. * - VertexBuffer.MatricesWeightsKind
  77819. * - VertexBuffer.MatricesWeightsExtraKind
  77820. * @returns an array of strings
  77821. */
  77822. getVerticesDataKinds(): string[];
  77823. /**
  77824. * Returns a positive integer : the total number of indices in this mesh geometry.
  77825. * @returns the numner of indices or zero if the mesh has no geometry.
  77826. */
  77827. getTotalIndices(): number;
  77828. /**
  77829. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  77830. * @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.
  77831. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77832. * @returns the indices array or an empty array if the mesh has no geometry
  77833. */
  77834. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77835. readonly isBlocked: boolean;
  77836. /**
  77837. * Determine if the current mesh is ready to be rendered
  77838. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  77839. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  77840. * @returns true if all associated assets are ready (material, textures, shaders)
  77841. */
  77842. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  77843. /**
  77844. * 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.
  77845. */
  77846. readonly areNormalsFrozen: boolean;
  77847. /**
  77848. * 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.
  77849. * @returns the current mesh
  77850. */
  77851. freezeNormals(): Mesh;
  77852. /**
  77853. * 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
  77854. * @returns the current mesh
  77855. */
  77856. unfreezeNormals(): Mesh;
  77857. /**
  77858. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  77859. */
  77860. overridenInstanceCount: number;
  77861. /** @hidden */
  77862. _preActivate(): Mesh;
  77863. /** @hidden */
  77864. _preActivateForIntermediateRendering(renderId: number): Mesh;
  77865. /** @hidden */
  77866. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  77867. /**
  77868. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  77869. * This means the mesh underlying bounding box and sphere are recomputed.
  77870. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  77871. * @returns the current mesh
  77872. */
  77873. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  77874. /** @hidden */
  77875. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  77876. /**
  77877. * This function will subdivide the mesh into multiple submeshes
  77878. * @param count defines the expected number of submeshes
  77879. */
  77880. subdivide(count: number): void;
  77881. /**
  77882. * Copy a FloatArray into a specific associated vertex buffer
  77883. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77884. * - VertexBuffer.PositionKind
  77885. * - VertexBuffer.UVKind
  77886. * - VertexBuffer.UV2Kind
  77887. * - VertexBuffer.UV3Kind
  77888. * - VertexBuffer.UV4Kind
  77889. * - VertexBuffer.UV5Kind
  77890. * - VertexBuffer.UV6Kind
  77891. * - VertexBuffer.ColorKind
  77892. * - VertexBuffer.MatricesIndicesKind
  77893. * - VertexBuffer.MatricesIndicesExtraKind
  77894. * - VertexBuffer.MatricesWeightsKind
  77895. * - VertexBuffer.MatricesWeightsExtraKind
  77896. * @param data defines the data source
  77897. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77898. * @param stride defines the data stride size (can be null)
  77899. * @returns the current mesh
  77900. */
  77901. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  77902. /**
  77903. * Flags an associated vertex buffer as updatable
  77904. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  77905. * - VertexBuffer.PositionKind
  77906. * - VertexBuffer.UVKind
  77907. * - VertexBuffer.UV2Kind
  77908. * - VertexBuffer.UV3Kind
  77909. * - VertexBuffer.UV4Kind
  77910. * - VertexBuffer.UV5Kind
  77911. * - VertexBuffer.UV6Kind
  77912. * - VertexBuffer.ColorKind
  77913. * - VertexBuffer.MatricesIndicesKind
  77914. * - VertexBuffer.MatricesIndicesExtraKind
  77915. * - VertexBuffer.MatricesWeightsKind
  77916. * - VertexBuffer.MatricesWeightsExtraKind
  77917. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77918. */
  77919. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  77920. /**
  77921. * Sets the mesh global Vertex Buffer
  77922. * @param buffer defines the buffer to use
  77923. * @returns the current mesh
  77924. */
  77925. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  77926. /**
  77927. * Update a specific associated vertex buffer
  77928. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77929. * - VertexBuffer.PositionKind
  77930. * - VertexBuffer.UVKind
  77931. * - VertexBuffer.UV2Kind
  77932. * - VertexBuffer.UV3Kind
  77933. * - VertexBuffer.UV4Kind
  77934. * - VertexBuffer.UV5Kind
  77935. * - VertexBuffer.UV6Kind
  77936. * - VertexBuffer.ColorKind
  77937. * - VertexBuffer.MatricesIndicesKind
  77938. * - VertexBuffer.MatricesIndicesExtraKind
  77939. * - VertexBuffer.MatricesWeightsKind
  77940. * - VertexBuffer.MatricesWeightsExtraKind
  77941. * @param data defines the data source
  77942. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77943. * @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)
  77944. * @returns the current mesh
  77945. */
  77946. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  77947. /**
  77948. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  77949. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  77950. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  77951. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  77952. * @returns the current mesh
  77953. */
  77954. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  77955. /**
  77956. * Creates a un-shared specific occurence of the geometry for the mesh.
  77957. * @returns the current mesh
  77958. */
  77959. makeGeometryUnique(): Mesh;
  77960. /**
  77961. * Set the index buffer of this mesh
  77962. * @param indices defines the source data
  77963. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  77964. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  77965. * @returns the current mesh
  77966. */
  77967. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  77968. /**
  77969. * Update the current index buffer
  77970. * @param indices defines the source data
  77971. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  77972. * @returns the current mesh
  77973. */
  77974. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  77975. /**
  77976. * Invert the geometry to move from a right handed system to a left handed one.
  77977. * @returns the current mesh
  77978. */
  77979. toLeftHanded(): Mesh;
  77980. /** @hidden */
  77981. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  77982. /** @hidden */
  77983. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  77984. /**
  77985. * Registers for this mesh a javascript function called just before the rendering process
  77986. * @param func defines the function to call before rendering this mesh
  77987. * @returns the current mesh
  77988. */
  77989. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77990. /**
  77991. * Disposes a previously registered javascript function called before the rendering
  77992. * @param func defines the function to remove
  77993. * @returns the current mesh
  77994. */
  77995. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77996. /**
  77997. * Registers for this mesh a javascript function called just after the rendering is complete
  77998. * @param func defines the function to call after rendering this mesh
  77999. * @returns the current mesh
  78000. */
  78001. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  78002. /**
  78003. * Disposes a previously registered javascript function called after the rendering.
  78004. * @param func defines the function to remove
  78005. * @returns the current mesh
  78006. */
  78007. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  78008. /** @hidden */
  78009. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  78010. /** @hidden */
  78011. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  78012. /** @hidden */
  78013. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  78014. /**
  78015. * 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
  78016. * @param subMesh defines the subMesh to render
  78017. * @param enableAlphaMode defines if alpha mode can be changed
  78018. * @returns the current mesh
  78019. */
  78020. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  78021. private _onBeforeDraw;
  78022. /**
  78023. * Renormalize the mesh and patch it up if there are no weights
  78024. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  78025. * However in the case of zero weights then we set just a single influence to 1.
  78026. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  78027. */
  78028. cleanMatrixWeights(): void;
  78029. private normalizeSkinFourWeights;
  78030. private normalizeSkinWeightsAndExtra;
  78031. /**
  78032. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  78033. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  78034. * the user know there was an issue with importing the mesh
  78035. * @returns a validation object with skinned, valid and report string
  78036. */
  78037. validateSkinning(): {
  78038. skinned: boolean;
  78039. valid: boolean;
  78040. report: string;
  78041. };
  78042. /** @hidden */
  78043. _checkDelayState(): Mesh;
  78044. private _queueLoad;
  78045. /**
  78046. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  78047. * A mesh is in the frustum if its bounding box intersects the frustum
  78048. * @param frustumPlanes defines the frustum to test
  78049. * @returns true if the mesh is in the frustum planes
  78050. */
  78051. isInFrustum(frustumPlanes: Plane[]): boolean;
  78052. /**
  78053. * Sets the mesh material by the material or multiMaterial `id` property
  78054. * @param id is a string identifying the material or the multiMaterial
  78055. * @returns the current mesh
  78056. */
  78057. setMaterialByID(id: string): Mesh;
  78058. /**
  78059. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  78060. * @returns an array of IAnimatable
  78061. */
  78062. getAnimatables(): IAnimatable[];
  78063. /**
  78064. * Modifies the mesh geometry according to the passed transformation matrix.
  78065. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  78066. * The mesh normals are modified using the same transformation.
  78067. * Note that, under the hood, this method sets a new VertexBuffer each call.
  78068. * @param transform defines the transform matrix to use
  78069. * @see http://doc.babylonjs.com/resources/baking_transformations
  78070. * @returns the current mesh
  78071. */
  78072. bakeTransformIntoVertices(transform: Matrix): Mesh;
  78073. /**
  78074. * Modifies the mesh geometry according to its own current World Matrix.
  78075. * The mesh World Matrix is then reset.
  78076. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  78077. * Note that, under the hood, this method sets a new VertexBuffer each call.
  78078. * @see http://doc.babylonjs.com/resources/baking_transformations
  78079. * @returns the current mesh
  78080. */
  78081. bakeCurrentTransformIntoVertices(): Mesh;
  78082. /** @hidden */
  78083. readonly _positions: Nullable<Vector3[]>;
  78084. /** @hidden */
  78085. _resetPointsArrayCache(): Mesh;
  78086. /** @hidden */
  78087. _generatePointsArray(): boolean;
  78088. /**
  78089. * Returns a new Mesh object generated from the current mesh properties.
  78090. * This method must not get confused with createInstance()
  78091. * @param name is a string, the name given to the new mesh
  78092. * @param newParent can be any Node object (default `null`)
  78093. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  78094. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  78095. * @returns a new mesh
  78096. */
  78097. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  78098. /**
  78099. * Releases resources associated with this mesh.
  78100. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78101. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78102. */
  78103. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78104. /**
  78105. * Modifies the mesh geometry according to a displacement map.
  78106. * 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.
  78107. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  78108. * @param url is a string, the URL from the image file is to be downloaded.
  78109. * @param minHeight is the lower limit of the displacement.
  78110. * @param maxHeight is the upper limit of the displacement.
  78111. * @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.
  78112. * @param uvOffset is an optional vector2 used to offset UV.
  78113. * @param uvScale is an optional vector2 used to scale UV.
  78114. * @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.
  78115. * @returns the Mesh.
  78116. */
  78117. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  78118. /**
  78119. * Modifies the mesh geometry according to a displacementMap buffer.
  78120. * 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.
  78121. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  78122. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  78123. * @param heightMapWidth is the width of the buffer image.
  78124. * @param heightMapHeight is the height of the buffer image.
  78125. * @param minHeight is the lower limit of the displacement.
  78126. * @param maxHeight is the upper limit of the displacement.
  78127. * @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.
  78128. * @param uvOffset is an optional vector2 used to offset UV.
  78129. * @param uvScale is an optional vector2 used to scale UV.
  78130. * @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.
  78131. * @returns the Mesh.
  78132. */
  78133. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  78134. /**
  78135. * Modify the mesh to get a flat shading rendering.
  78136. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  78137. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  78138. * @returns current mesh
  78139. */
  78140. convertToFlatShadedMesh(): Mesh;
  78141. /**
  78142. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  78143. * In other words, more vertices, no more indices and a single bigger VBO.
  78144. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  78145. * @returns current mesh
  78146. */
  78147. convertToUnIndexedMesh(): Mesh;
  78148. /**
  78149. * Inverses facet orientations.
  78150. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  78151. * @param flipNormals will also inverts the normals
  78152. * @returns current mesh
  78153. */
  78154. flipFaces(flipNormals?: boolean): Mesh;
  78155. /** @hidden */
  78156. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  78157. /** @hidden */
  78158. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  78159. /**
  78160. * Creates a new InstancedMesh object from the mesh model.
  78161. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  78162. * @param name defines the name of the new instance
  78163. * @returns a new InstancedMesh
  78164. */
  78165. createInstance(name: string): InstancedMesh;
  78166. /**
  78167. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  78168. * After this call, all the mesh instances have the same submeshes than the current mesh.
  78169. * @returns the current mesh
  78170. */
  78171. synchronizeInstances(): Mesh;
  78172. /**
  78173. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  78174. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  78175. * This should be used together with the simplification to avoid disappearing triangles.
  78176. * @param successCallback an optional success callback to be called after the optimization finished.
  78177. * @returns the current mesh
  78178. */
  78179. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  78180. /**
  78181. * Serialize current mesh
  78182. * @param serializationObject defines the object which will receive the serialization data
  78183. */
  78184. serialize(serializationObject: any): void;
  78185. /** @hidden */
  78186. _syncGeometryWithMorphTargetManager(): void;
  78187. /** @hidden */
  78188. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  78189. /**
  78190. * Returns a new Mesh object parsed from the source provided.
  78191. * @param parsedMesh is the source
  78192. * @param scene defines the hosting scene
  78193. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  78194. * @returns a new Mesh
  78195. */
  78196. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  78197. /**
  78198. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  78199. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78200. * @param name defines the name of the mesh to create
  78201. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  78202. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  78203. * @param closePath creates a seam between the first and the last points of each path of the path array
  78204. * @param offset is taken in account only if the `pathArray` is containing a single path
  78205. * @param scene defines the hosting scene
  78206. * @param updatable defines if the mesh must be flagged as updatable
  78207. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78208. * @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)
  78209. * @returns a new Mesh
  78210. */
  78211. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78212. /**
  78213. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  78214. * @param name defines the name of the mesh to create
  78215. * @param radius sets the radius size (float) of the polygon (default 0.5)
  78216. * @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
  78217. * @param scene defines the hosting scene
  78218. * @param updatable defines if the mesh must be flagged as updatable
  78219. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78220. * @returns a new Mesh
  78221. */
  78222. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  78223. /**
  78224. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  78225. * @param name defines the name of the mesh to create
  78226. * @param size sets the size (float) of each box side (default 1)
  78227. * @param scene defines the hosting scene
  78228. * @param updatable defines if the mesh must be flagged as updatable
  78229. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78230. * @returns a new Mesh
  78231. */
  78232. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  78233. /**
  78234. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  78235. * @param name defines the name of the mesh to create
  78236. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  78237. * @param diameter sets the diameter size (float) of the sphere (default 1)
  78238. * @param scene defines the hosting scene
  78239. * @param updatable defines if the mesh must be flagged as updatable
  78240. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78241. * @returns a new Mesh
  78242. */
  78243. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78244. /**
  78245. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  78246. * @param name defines the name of the mesh to create
  78247. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  78248. * @param diameterTop set the top cap diameter (floats, default 1)
  78249. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  78250. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  78251. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  78252. * @param scene defines the hosting scene
  78253. * @param updatable defines if the mesh must be flagged as updatable
  78254. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78255. * @returns a new Mesh
  78256. */
  78257. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  78258. /**
  78259. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  78260. * @param name defines the name of the mesh to create
  78261. * @param diameter sets the diameter size (float) of the torus (default 1)
  78262. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  78263. * @param tessellation sets the number of torus sides (postive integer, default 16)
  78264. * @param scene defines the hosting scene
  78265. * @param updatable defines if the mesh must be flagged as updatable
  78266. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78267. * @returns a new Mesh
  78268. */
  78269. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78270. /**
  78271. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  78272. * @param name defines the name of the mesh to create
  78273. * @param radius sets the global radius size (float) of the torus knot (default 2)
  78274. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  78275. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  78276. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  78277. * @param p the number of windings on X axis (positive integers, default 2)
  78278. * @param q the number of windings on Y axis (positive integers, default 3)
  78279. * @param scene defines the hosting scene
  78280. * @param updatable defines if the mesh must be flagged as updatable
  78281. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78282. * @returns a new Mesh
  78283. */
  78284. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78285. /**
  78286. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  78287. * @param name defines the name of the mesh to create
  78288. * @param points is an array successive Vector3
  78289. * @param scene defines the hosting scene
  78290. * @param updatable defines if the mesh must be flagged as updatable
  78291. * @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).
  78292. * @returns a new Mesh
  78293. */
  78294. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  78295. /**
  78296. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  78297. * @param name defines the name of the mesh to create
  78298. * @param points is an array successive Vector3
  78299. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  78300. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  78301. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  78302. * @param scene defines the hosting scene
  78303. * @param updatable defines if the mesh must be flagged as updatable
  78304. * @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)
  78305. * @returns a new Mesh
  78306. */
  78307. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  78308. /**
  78309. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  78310. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  78311. * 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.
  78312. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78313. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  78314. * Remember you can only change the shape positions, not their number when updating a polygon.
  78315. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  78316. * @param name defines the name of the mesh to create
  78317. * @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
  78318. * @param scene defines the hosting scene
  78319. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78320. * @param updatable defines if the mesh must be flagged as updatable
  78321. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78322. * @param earcutInjection can be used to inject your own earcut reference
  78323. * @returns a new Mesh
  78324. */
  78325. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78326. /**
  78327. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  78328. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  78329. * @param name defines the name of the mesh to create
  78330. * @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
  78331. * @param depth defines the height of extrusion
  78332. * @param scene defines the hosting scene
  78333. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78334. * @param updatable defines if the mesh must be flagged as updatable
  78335. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78336. * @param earcutInjection can be used to inject your own earcut reference
  78337. * @returns a new Mesh
  78338. */
  78339. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78340. /**
  78341. * Creates an extruded shape mesh.
  78342. * 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
  78343. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78344. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78345. * @param name defines the name of the mesh to create
  78346. * @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
  78347. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78348. * @param scale is the value to scale the shape
  78349. * @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
  78350. * @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
  78351. * @param scene defines the hosting scene
  78352. * @param updatable defines if the mesh must be flagged as updatable
  78353. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78354. * @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)
  78355. * @returns a new Mesh
  78356. */
  78357. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78358. /**
  78359. * Creates an custom extruded shape mesh.
  78360. * The custom extrusion is a parametric shape.
  78361. * It has no predefined shape. Its final shape will depend on the input parameters.
  78362. * Please consider using the same method from the MeshBuilder class instead
  78363. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78364. * @param name defines the name of the mesh to create
  78365. * @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
  78366. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78367. * @param scaleFunction is a custom Javascript function called on each path point
  78368. * @param rotationFunction is a custom Javascript function called on each path point
  78369. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  78370. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  78371. * @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
  78372. * @param scene defines the hosting scene
  78373. * @param updatable defines if the mesh must be flagged as updatable
  78374. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78375. * @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)
  78376. * @returns a new Mesh
  78377. */
  78378. 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;
  78379. /**
  78380. * Creates lathe mesh.
  78381. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  78382. * Please consider using the same method from the MeshBuilder class instead
  78383. * @param name defines the name of the mesh to create
  78384. * @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
  78385. * @param radius is the radius value of the lathe
  78386. * @param tessellation is the side number of the lathe.
  78387. * @param scene defines the hosting scene
  78388. * @param updatable defines if the mesh must be flagged as updatable
  78389. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78390. * @returns a new Mesh
  78391. */
  78392. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78393. /**
  78394. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  78395. * @param name defines the name of the mesh to create
  78396. * @param size sets the size (float) of both sides of the plane at once (default 1)
  78397. * @param scene defines the hosting scene
  78398. * @param updatable defines if the mesh must be flagged as updatable
  78399. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78400. * @returns a new Mesh
  78401. */
  78402. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78403. /**
  78404. * Creates a ground mesh.
  78405. * Please consider using the same method from the MeshBuilder class instead
  78406. * @param name defines the name of the mesh to create
  78407. * @param width set the width of the ground
  78408. * @param height set the height of the ground
  78409. * @param subdivisions sets the number of subdivisions per side
  78410. * @param scene defines the hosting scene
  78411. * @param updatable defines if the mesh must be flagged as updatable
  78412. * @returns a new Mesh
  78413. */
  78414. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  78415. /**
  78416. * Creates a tiled ground mesh.
  78417. * Please consider using the same method from the MeshBuilder class instead
  78418. * @param name defines the name of the mesh to create
  78419. * @param xmin set the ground minimum X coordinate
  78420. * @param zmin set the ground minimum Y coordinate
  78421. * @param xmax set the ground maximum X coordinate
  78422. * @param zmax set the ground maximum Z coordinate
  78423. * @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
  78424. * @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
  78425. * @param scene defines the hosting scene
  78426. * @param updatable defines if the mesh must be flagged as updatable
  78427. * @returns a new Mesh
  78428. */
  78429. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  78430. w: number;
  78431. h: number;
  78432. }, precision: {
  78433. w: number;
  78434. h: number;
  78435. }, scene: Scene, updatable?: boolean): Mesh;
  78436. /**
  78437. * Creates a ground mesh from a height map.
  78438. * Please consider using the same method from the MeshBuilder class instead
  78439. * @see http://doc.babylonjs.com/babylon101/height_map
  78440. * @param name defines the name of the mesh to create
  78441. * @param url sets the URL of the height map image resource
  78442. * @param width set the ground width size
  78443. * @param height set the ground height size
  78444. * @param subdivisions sets the number of subdivision per side
  78445. * @param minHeight is the minimum altitude on the ground
  78446. * @param maxHeight is the maximum altitude on the ground
  78447. * @param scene defines the hosting scene
  78448. * @param updatable defines if the mesh must be flagged as updatable
  78449. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  78450. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  78451. * @returns a new Mesh
  78452. */
  78453. 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;
  78454. /**
  78455. * Creates a tube mesh.
  78456. * The tube is a parametric shape.
  78457. * It has no predefined shape. Its final shape will depend on the input parameters.
  78458. * Please consider using the same method from the MeshBuilder class instead
  78459. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78460. * @param name defines the name of the mesh to create
  78461. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  78462. * @param radius sets the tube radius size
  78463. * @param tessellation is the number of sides on the tubular surface
  78464. * @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
  78465. * @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
  78466. * @param scene defines the hosting scene
  78467. * @param updatable defines if the mesh must be flagged as updatable
  78468. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78469. * @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)
  78470. * @returns a new Mesh
  78471. */
  78472. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  78473. (i: number, distance: number): number;
  78474. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78475. /**
  78476. * Creates a polyhedron mesh.
  78477. * Please consider using the same method from the MeshBuilder class instead.
  78478. * * 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
  78479. * * The parameter `size` (positive float, default 1) sets the polygon size
  78480. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  78481. * * 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`
  78482. * * 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
  78483. * * 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)`)
  78484. * * 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
  78485. * * 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
  78486. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78487. * * If you create a double-sided mesh, you can choose what parts of 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
  78488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78489. * @param name defines the name of the mesh to create
  78490. * @param options defines the options used to create the mesh
  78491. * @param scene defines the hosting scene
  78492. * @returns a new Mesh
  78493. */
  78494. static CreatePolyhedron(name: string, options: {
  78495. type?: number;
  78496. size?: number;
  78497. sizeX?: number;
  78498. sizeY?: number;
  78499. sizeZ?: number;
  78500. custom?: any;
  78501. faceUV?: Vector4[];
  78502. faceColors?: Color4[];
  78503. updatable?: boolean;
  78504. sideOrientation?: number;
  78505. }, scene: Scene): Mesh;
  78506. /**
  78507. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  78508. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  78509. * * 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`)
  78510. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  78511. * * 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
  78512. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78513. * * If you create a double-sided mesh, you can choose what parts of 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
  78514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78515. * @param name defines the name of the mesh
  78516. * @param options defines the options used to create the mesh
  78517. * @param scene defines the hosting scene
  78518. * @returns a new Mesh
  78519. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  78520. */
  78521. static CreateIcoSphere(name: string, options: {
  78522. radius?: number;
  78523. flat?: boolean;
  78524. subdivisions?: number;
  78525. sideOrientation?: number;
  78526. updatable?: boolean;
  78527. }, scene: Scene): Mesh;
  78528. /**
  78529. * Creates a decal mesh.
  78530. * Please consider using the same method from the MeshBuilder class instead.
  78531. * A decal is a mesh usually applied as a model onto the surface of another mesh
  78532. * @param name defines the name of the mesh
  78533. * @param sourceMesh defines the mesh receiving the decal
  78534. * @param position sets the position of the decal in world coordinates
  78535. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  78536. * @param size sets the decal scaling
  78537. * @param angle sets the angle to rotate the decal
  78538. * @returns a new Mesh
  78539. */
  78540. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  78541. /**
  78542. * Prepare internal position array for software CPU skinning
  78543. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  78544. */
  78545. setPositionsForCPUSkinning(): Float32Array;
  78546. /**
  78547. * Prepare internal normal array for software CPU skinning
  78548. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  78549. */
  78550. setNormalsForCPUSkinning(): Float32Array;
  78551. /**
  78552. * Updates the vertex buffer by applying transformation from the bones
  78553. * @param skeleton defines the skeleton to apply to current mesh
  78554. * @returns the current mesh
  78555. */
  78556. applySkeleton(skeleton: Skeleton): Mesh;
  78557. /**
  78558. * 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
  78559. * @param meshes defines the list of meshes to scan
  78560. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  78561. */
  78562. static MinMax(meshes: AbstractMesh[]): {
  78563. min: Vector3;
  78564. max: Vector3;
  78565. };
  78566. /**
  78567. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  78568. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  78569. * @returns a vector3
  78570. */
  78571. static Center(meshesOrMinMaxVector: {
  78572. min: Vector3;
  78573. max: Vector3;
  78574. } | AbstractMesh[]): Vector3;
  78575. /**
  78576. * Merge the array of meshes into a single mesh for performance reasons.
  78577. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  78578. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  78579. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  78580. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  78581. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  78582. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  78583. * @returns a new mesh
  78584. */
  78585. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  78586. /** @hidden */
  78587. addInstance(instance: InstancedMesh): void;
  78588. /** @hidden */
  78589. removeInstance(instance: InstancedMesh): void;
  78590. }
  78591. }
  78592. declare module BABYLON {
  78593. /**
  78594. * Base class for the main features of a material in Babylon.js
  78595. */
  78596. export class Material implements IAnimatable {
  78597. /**
  78598. * Returns the triangle fill mode
  78599. */
  78600. static readonly TriangleFillMode: number;
  78601. /**
  78602. * Returns the wireframe mode
  78603. */
  78604. static readonly WireFrameFillMode: number;
  78605. /**
  78606. * Returns the point fill mode
  78607. */
  78608. static readonly PointFillMode: number;
  78609. /**
  78610. * Returns the point list draw mode
  78611. */
  78612. static readonly PointListDrawMode: number;
  78613. /**
  78614. * Returns the line list draw mode
  78615. */
  78616. static readonly LineListDrawMode: number;
  78617. /**
  78618. * Returns the line loop draw mode
  78619. */
  78620. static readonly LineLoopDrawMode: number;
  78621. /**
  78622. * Returns the line strip draw mode
  78623. */
  78624. static readonly LineStripDrawMode: number;
  78625. /**
  78626. * Returns the triangle strip draw mode
  78627. */
  78628. static readonly TriangleStripDrawMode: number;
  78629. /**
  78630. * Returns the triangle fan draw mode
  78631. */
  78632. static readonly TriangleFanDrawMode: number;
  78633. /**
  78634. * Stores the clock-wise side orientation
  78635. */
  78636. static readonly ClockWiseSideOrientation: number;
  78637. /**
  78638. * Stores the counter clock-wise side orientation
  78639. */
  78640. static readonly CounterClockWiseSideOrientation: number;
  78641. /**
  78642. * The dirty texture flag value
  78643. */
  78644. static readonly TextureDirtyFlag: number;
  78645. /**
  78646. * The dirty light flag value
  78647. */
  78648. static readonly LightDirtyFlag: number;
  78649. /**
  78650. * The dirty fresnel flag value
  78651. */
  78652. static readonly FresnelDirtyFlag: number;
  78653. /**
  78654. * The dirty attribute flag value
  78655. */
  78656. static readonly AttributesDirtyFlag: number;
  78657. /**
  78658. * The dirty misc flag value
  78659. */
  78660. static readonly MiscDirtyFlag: number;
  78661. /**
  78662. * The all dirty flag value
  78663. */
  78664. static readonly AllDirtyFlag: number;
  78665. /**
  78666. * The ID of the material
  78667. */
  78668. id: string;
  78669. /**
  78670. * Gets or sets the unique id of the material
  78671. */
  78672. uniqueId: number;
  78673. /**
  78674. * The name of the material
  78675. */
  78676. name: string;
  78677. /**
  78678. * Gets or sets user defined metadata
  78679. */
  78680. metadata: any;
  78681. /**
  78682. * For internal use only. Please do not use.
  78683. */
  78684. reservedDataStore: any;
  78685. /**
  78686. * Specifies if the ready state should be checked on each call
  78687. */
  78688. checkReadyOnEveryCall: boolean;
  78689. /**
  78690. * Specifies if the ready state should be checked once
  78691. */
  78692. checkReadyOnlyOnce: boolean;
  78693. /**
  78694. * The state of the material
  78695. */
  78696. state: string;
  78697. /**
  78698. * The alpha value of the material
  78699. */
  78700. protected _alpha: number;
  78701. /**
  78702. * Sets the alpha value of the material
  78703. */
  78704. /**
  78705. * Gets the alpha value of the material
  78706. */
  78707. alpha: number;
  78708. /**
  78709. * Specifies if back face culling is enabled
  78710. */
  78711. protected _backFaceCulling: boolean;
  78712. /**
  78713. * Sets the back-face culling state
  78714. */
  78715. /**
  78716. * Gets the back-face culling state
  78717. */
  78718. backFaceCulling: boolean;
  78719. /**
  78720. * Stores the value for side orientation
  78721. */
  78722. sideOrientation: number;
  78723. /**
  78724. * Callback triggered when the material is compiled
  78725. */
  78726. onCompiled: (effect: Effect) => void;
  78727. /**
  78728. * Callback triggered when an error occurs
  78729. */
  78730. onError: (effect: Effect, errors: string) => void;
  78731. /**
  78732. * Callback triggered to get the render target textures
  78733. */
  78734. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  78735. /**
  78736. * Gets a boolean indicating that current material needs to register RTT
  78737. */
  78738. readonly hasRenderTargetTextures: boolean;
  78739. /**
  78740. * Specifies if the material should be serialized
  78741. */
  78742. doNotSerialize: boolean;
  78743. /**
  78744. * @hidden
  78745. */
  78746. _storeEffectOnSubMeshes: boolean;
  78747. /**
  78748. * Stores the animations for the material
  78749. */
  78750. animations: Array<Animation>;
  78751. /**
  78752. * An event triggered when the material is disposed
  78753. */
  78754. onDisposeObservable: Observable<Material>;
  78755. /**
  78756. * An observer which watches for dispose events
  78757. */
  78758. private _onDisposeObserver;
  78759. private _onUnBindObservable;
  78760. /**
  78761. * Called during a dispose event
  78762. */
  78763. onDispose: () => void;
  78764. private _onBindObservable;
  78765. /**
  78766. * An event triggered when the material is bound
  78767. */
  78768. readonly onBindObservable: Observable<AbstractMesh>;
  78769. /**
  78770. * An observer which watches for bind events
  78771. */
  78772. private _onBindObserver;
  78773. /**
  78774. * Called during a bind event
  78775. */
  78776. onBind: (Mesh: AbstractMesh) => void;
  78777. /**
  78778. * An event triggered when the material is unbound
  78779. */
  78780. readonly onUnBindObservable: Observable<Material>;
  78781. /**
  78782. * Stores the value of the alpha mode
  78783. */
  78784. private _alphaMode;
  78785. /**
  78786. * Sets the value of the alpha mode.
  78787. *
  78788. * | Value | Type | Description |
  78789. * | --- | --- | --- |
  78790. * | 0 | ALPHA_DISABLE | |
  78791. * | 1 | ALPHA_ADD | |
  78792. * | 2 | ALPHA_COMBINE | |
  78793. * | 3 | ALPHA_SUBTRACT | |
  78794. * | 4 | ALPHA_MULTIPLY | |
  78795. * | 5 | ALPHA_MAXIMIZED | |
  78796. * | 6 | ALPHA_ONEONE | |
  78797. * | 7 | ALPHA_PREMULTIPLIED | |
  78798. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  78799. * | 9 | ALPHA_INTERPOLATE | |
  78800. * | 10 | ALPHA_SCREENMODE | |
  78801. *
  78802. */
  78803. /**
  78804. * Gets the value of the alpha mode
  78805. */
  78806. alphaMode: number;
  78807. /**
  78808. * Stores the state of the need depth pre-pass value
  78809. */
  78810. private _needDepthPrePass;
  78811. /**
  78812. * Sets the need depth pre-pass value
  78813. */
  78814. /**
  78815. * Gets the depth pre-pass value
  78816. */
  78817. needDepthPrePass: boolean;
  78818. /**
  78819. * Specifies if depth writing should be disabled
  78820. */
  78821. disableDepthWrite: boolean;
  78822. /**
  78823. * Specifies if depth writing should be forced
  78824. */
  78825. forceDepthWrite: boolean;
  78826. /**
  78827. * Specifies if there should be a separate pass for culling
  78828. */
  78829. separateCullingPass: boolean;
  78830. /**
  78831. * Stores the state specifing if fog should be enabled
  78832. */
  78833. private _fogEnabled;
  78834. /**
  78835. * Sets the state for enabling fog
  78836. */
  78837. /**
  78838. * Gets the value of the fog enabled state
  78839. */
  78840. fogEnabled: boolean;
  78841. /**
  78842. * Stores the size of points
  78843. */
  78844. pointSize: number;
  78845. /**
  78846. * Stores the z offset value
  78847. */
  78848. zOffset: number;
  78849. /**
  78850. * Gets a value specifying if wireframe mode is enabled
  78851. */
  78852. /**
  78853. * Sets the state of wireframe mode
  78854. */
  78855. wireframe: boolean;
  78856. /**
  78857. * Gets the value specifying if point clouds are enabled
  78858. */
  78859. /**
  78860. * Sets the state of point cloud mode
  78861. */
  78862. pointsCloud: boolean;
  78863. /**
  78864. * Gets the material fill mode
  78865. */
  78866. /**
  78867. * Sets the material fill mode
  78868. */
  78869. fillMode: number;
  78870. /**
  78871. * @hidden
  78872. * Stores the effects for the material
  78873. */
  78874. _effect: Nullable<Effect>;
  78875. /**
  78876. * @hidden
  78877. * Specifies if the material was previously ready
  78878. */
  78879. _wasPreviouslyReady: boolean;
  78880. /**
  78881. * Specifies if uniform buffers should be used
  78882. */
  78883. private _useUBO;
  78884. /**
  78885. * Stores a reference to the scene
  78886. */
  78887. private _scene;
  78888. /**
  78889. * Stores the fill mode state
  78890. */
  78891. private _fillMode;
  78892. /**
  78893. * Specifies if the depth write state should be cached
  78894. */
  78895. private _cachedDepthWriteState;
  78896. /**
  78897. * Stores the uniform buffer
  78898. */
  78899. protected _uniformBuffer: UniformBuffer;
  78900. /** @hidden */
  78901. _indexInSceneMaterialArray: number;
  78902. /** @hidden */
  78903. meshMap: Nullable<{
  78904. [id: string]: AbstractMesh | undefined;
  78905. }>;
  78906. /**
  78907. * Creates a material instance
  78908. * @param name defines the name of the material
  78909. * @param scene defines the scene to reference
  78910. * @param doNotAdd specifies if the material should be added to the scene
  78911. */
  78912. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  78913. /**
  78914. * Returns a string representation of the current material
  78915. * @param fullDetails defines a boolean indicating which levels of logging is desired
  78916. * @returns a string with material information
  78917. */
  78918. toString(fullDetails?: boolean): string;
  78919. /**
  78920. * Gets the class name of the material
  78921. * @returns a string with the class name of the material
  78922. */
  78923. getClassName(): string;
  78924. /**
  78925. * Specifies if updates for the material been locked
  78926. */
  78927. readonly isFrozen: boolean;
  78928. /**
  78929. * Locks updates for the material
  78930. */
  78931. freeze(): void;
  78932. /**
  78933. * Unlocks updates for the material
  78934. */
  78935. unfreeze(): void;
  78936. /**
  78937. * Specifies if the material is ready to be used
  78938. * @param mesh defines the mesh to check
  78939. * @param useInstances specifies if instances should be used
  78940. * @returns a boolean indicating if the material is ready to be used
  78941. */
  78942. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  78943. /**
  78944. * Specifies that the submesh is ready to be used
  78945. * @param mesh defines the mesh to check
  78946. * @param subMesh defines which submesh to check
  78947. * @param useInstances specifies that instances should be used
  78948. * @returns a boolean indicating that the submesh is ready or not
  78949. */
  78950. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  78951. /**
  78952. * Returns the material effect
  78953. * @returns the effect associated with the material
  78954. */
  78955. getEffect(): Nullable<Effect>;
  78956. /**
  78957. * Returns the current scene
  78958. * @returns a Scene
  78959. */
  78960. getScene(): Scene;
  78961. /**
  78962. * Specifies if the material will require alpha blending
  78963. * @returns a boolean specifying if alpha blending is needed
  78964. */
  78965. needAlphaBlending(): boolean;
  78966. /**
  78967. * Specifies if the mesh will require alpha blending
  78968. * @param mesh defines the mesh to check
  78969. * @returns a boolean specifying if alpha blending is needed for the mesh
  78970. */
  78971. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  78972. /**
  78973. * Specifies if this material should be rendered in alpha test mode
  78974. * @returns a boolean specifying if an alpha test is needed.
  78975. */
  78976. needAlphaTesting(): boolean;
  78977. /**
  78978. * Gets the texture used for the alpha test
  78979. * @returns the texture to use for alpha testing
  78980. */
  78981. getAlphaTestTexture(): Nullable<BaseTexture>;
  78982. /**
  78983. * Marks the material to indicate that it needs to be re-calculated
  78984. */
  78985. markDirty(): void;
  78986. /** @hidden */
  78987. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  78988. /**
  78989. * Binds the material to the mesh
  78990. * @param world defines the world transformation matrix
  78991. * @param mesh defines the mesh to bind the material to
  78992. */
  78993. bind(world: Matrix, mesh?: Mesh): void;
  78994. /**
  78995. * Binds the submesh to the material
  78996. * @param world defines the world transformation matrix
  78997. * @param mesh defines the mesh containing the submesh
  78998. * @param subMesh defines the submesh to bind the material to
  78999. */
  79000. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  79001. /**
  79002. * Binds the world matrix to the material
  79003. * @param world defines the world transformation matrix
  79004. */
  79005. bindOnlyWorldMatrix(world: Matrix): void;
  79006. /**
  79007. * Binds the scene's uniform buffer to the effect.
  79008. * @param effect defines the effect to bind to the scene uniform buffer
  79009. * @param sceneUbo defines the uniform buffer storing scene data
  79010. */
  79011. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  79012. /**
  79013. * Binds the view matrix to the effect
  79014. * @param effect defines the effect to bind the view matrix to
  79015. */
  79016. bindView(effect: Effect): void;
  79017. /**
  79018. * Binds the view projection matrix to the effect
  79019. * @param effect defines the effect to bind the view projection matrix to
  79020. */
  79021. bindViewProjection(effect: Effect): void;
  79022. /**
  79023. * Specifies if material alpha testing should be turned on for the mesh
  79024. * @param mesh defines the mesh to check
  79025. */
  79026. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  79027. /**
  79028. * Processes to execute after binding the material to a mesh
  79029. * @param mesh defines the rendered mesh
  79030. */
  79031. protected _afterBind(mesh?: Mesh): void;
  79032. /**
  79033. * Unbinds the material from the mesh
  79034. */
  79035. unbind(): void;
  79036. /**
  79037. * Gets the active textures from the material
  79038. * @returns an array of textures
  79039. */
  79040. getActiveTextures(): BaseTexture[];
  79041. /**
  79042. * Specifies if the material uses a texture
  79043. * @param texture defines the texture to check against the material
  79044. * @returns a boolean specifying if the material uses the texture
  79045. */
  79046. hasTexture(texture: BaseTexture): boolean;
  79047. /**
  79048. * Makes a duplicate of the material, and gives it a new name
  79049. * @param name defines the new name for the duplicated material
  79050. * @returns the cloned material
  79051. */
  79052. clone(name: string): Nullable<Material>;
  79053. /**
  79054. * Gets the meshes bound to the material
  79055. * @returns an array of meshes bound to the material
  79056. */
  79057. getBindedMeshes(): AbstractMesh[];
  79058. /**
  79059. * Force shader compilation
  79060. * @param mesh defines the mesh associated with this material
  79061. * @param onCompiled defines a function to execute once the material is compiled
  79062. * @param options defines the options to configure the compilation
  79063. */
  79064. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  79065. clipPlane: boolean;
  79066. }>): void;
  79067. /**
  79068. * Force shader compilation
  79069. * @param mesh defines the mesh that will use this material
  79070. * @param options defines additional options for compiling the shaders
  79071. * @returns a promise that resolves when the compilation completes
  79072. */
  79073. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  79074. clipPlane: boolean;
  79075. }>): Promise<void>;
  79076. private static readonly _ImageProcessingDirtyCallBack;
  79077. private static readonly _TextureDirtyCallBack;
  79078. private static readonly _FresnelDirtyCallBack;
  79079. private static readonly _MiscDirtyCallBack;
  79080. private static readonly _LightsDirtyCallBack;
  79081. private static readonly _AttributeDirtyCallBack;
  79082. private static _FresnelAndMiscDirtyCallBack;
  79083. private static _TextureAndMiscDirtyCallBack;
  79084. private static readonly _DirtyCallbackArray;
  79085. private static readonly _RunDirtyCallBacks;
  79086. /**
  79087. * Marks a define in the material to indicate that it needs to be re-computed
  79088. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  79089. */
  79090. markAsDirty(flag: number): void;
  79091. /**
  79092. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  79093. * @param func defines a function which checks material defines against the submeshes
  79094. */
  79095. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  79096. /**
  79097. * Indicates that image processing needs to be re-calculated for all submeshes
  79098. */
  79099. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  79100. /**
  79101. * Indicates that textures need to be re-calculated for all submeshes
  79102. */
  79103. protected _markAllSubMeshesAsTexturesDirty(): void;
  79104. /**
  79105. * Indicates that fresnel needs to be re-calculated for all submeshes
  79106. */
  79107. protected _markAllSubMeshesAsFresnelDirty(): void;
  79108. /**
  79109. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  79110. */
  79111. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  79112. /**
  79113. * Indicates that lights need to be re-calculated for all submeshes
  79114. */
  79115. protected _markAllSubMeshesAsLightsDirty(): void;
  79116. /**
  79117. * Indicates that attributes need to be re-calculated for all submeshes
  79118. */
  79119. protected _markAllSubMeshesAsAttributesDirty(): void;
  79120. /**
  79121. * Indicates that misc needs to be re-calculated for all submeshes
  79122. */
  79123. protected _markAllSubMeshesAsMiscDirty(): void;
  79124. /**
  79125. * Indicates that textures and misc need to be re-calculated for all submeshes
  79126. */
  79127. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  79128. /**
  79129. * Disposes the material
  79130. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79131. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  79132. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  79133. */
  79134. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  79135. /** @hidden */
  79136. private releaseVertexArrayObject;
  79137. /**
  79138. * Serializes this material
  79139. * @returns the serialized material object
  79140. */
  79141. serialize(): any;
  79142. /**
  79143. * Creates a material from parsed material data
  79144. * @param parsedMaterial defines parsed material data
  79145. * @param scene defines the hosting scene
  79146. * @param rootUrl defines the root URL to use to load textures
  79147. * @returns a new material
  79148. */
  79149. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  79150. }
  79151. }
  79152. declare module BABYLON {
  79153. /**
  79154. * Base class for submeshes
  79155. */
  79156. export class BaseSubMesh {
  79157. /** @hidden */
  79158. _materialDefines: Nullable<MaterialDefines>;
  79159. /** @hidden */
  79160. _materialEffect: Nullable<Effect>;
  79161. /**
  79162. * Gets associated effect
  79163. */
  79164. readonly effect: Nullable<Effect>;
  79165. /**
  79166. * Sets associated effect (effect used to render this submesh)
  79167. * @param effect defines the effect to associate with
  79168. * @param defines defines the set of defines used to compile this effect
  79169. */
  79170. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  79171. }
  79172. /**
  79173. * Defines a subdivision inside a mesh
  79174. */
  79175. export class SubMesh extends BaseSubMesh implements ICullable {
  79176. /** the material index to use */
  79177. materialIndex: number;
  79178. /** vertex index start */
  79179. verticesStart: number;
  79180. /** vertices count */
  79181. verticesCount: number;
  79182. /** index start */
  79183. indexStart: number;
  79184. /** indices count */
  79185. indexCount: number;
  79186. /** @hidden */
  79187. _linesIndexCount: number;
  79188. private _mesh;
  79189. private _renderingMesh;
  79190. private _boundingInfo;
  79191. private _linesIndexBuffer;
  79192. /** @hidden */
  79193. _lastColliderWorldVertices: Nullable<Vector3[]>;
  79194. /** @hidden */
  79195. _trianglePlanes: Plane[];
  79196. /** @hidden */
  79197. _lastColliderTransformMatrix: Matrix;
  79198. /** @hidden */
  79199. _renderId: number;
  79200. /** @hidden */
  79201. _alphaIndex: number;
  79202. /** @hidden */
  79203. _distanceToCamera: number;
  79204. /** @hidden */
  79205. _id: number;
  79206. private _currentMaterial;
  79207. /**
  79208. * Add a new submesh to a mesh
  79209. * @param materialIndex defines the material index to use
  79210. * @param verticesStart defines vertex index start
  79211. * @param verticesCount defines vertices count
  79212. * @param indexStart defines index start
  79213. * @param indexCount defines indices count
  79214. * @param mesh defines the parent mesh
  79215. * @param renderingMesh defines an optional rendering mesh
  79216. * @param createBoundingBox defines if bounding box should be created for this submesh
  79217. * @returns the new submesh
  79218. */
  79219. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  79220. /**
  79221. * Creates a new submesh
  79222. * @param materialIndex defines the material index to use
  79223. * @param verticesStart defines vertex index start
  79224. * @param verticesCount defines vertices count
  79225. * @param indexStart defines index start
  79226. * @param indexCount defines indices count
  79227. * @param mesh defines the parent mesh
  79228. * @param renderingMesh defines an optional rendering mesh
  79229. * @param createBoundingBox defines if bounding box should be created for this submesh
  79230. */
  79231. constructor(
  79232. /** the material index to use */
  79233. materialIndex: number,
  79234. /** vertex index start */
  79235. verticesStart: number,
  79236. /** vertices count */
  79237. verticesCount: number,
  79238. /** index start */
  79239. indexStart: number,
  79240. /** indices count */
  79241. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  79242. /**
  79243. * Returns true if this submesh covers the entire parent mesh
  79244. * @ignorenaming
  79245. */
  79246. readonly IsGlobal: boolean;
  79247. /**
  79248. * Returns the submesh BoudingInfo object
  79249. * @returns current bounding info (or mesh's one if the submesh is global)
  79250. */
  79251. getBoundingInfo(): BoundingInfo;
  79252. /**
  79253. * Sets the submesh BoundingInfo
  79254. * @param boundingInfo defines the new bounding info to use
  79255. * @returns the SubMesh
  79256. */
  79257. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  79258. /**
  79259. * Returns the mesh of the current submesh
  79260. * @return the parent mesh
  79261. */
  79262. getMesh(): AbstractMesh;
  79263. /**
  79264. * Returns the rendering mesh of the submesh
  79265. * @returns the rendering mesh (could be different from parent mesh)
  79266. */
  79267. getRenderingMesh(): Mesh;
  79268. /**
  79269. * Returns the submesh material
  79270. * @returns null or the current material
  79271. */
  79272. getMaterial(): Nullable<Material>;
  79273. /**
  79274. * Sets a new updated BoundingInfo object to the submesh
  79275. * @returns the SubMesh
  79276. */
  79277. refreshBoundingInfo(): SubMesh;
  79278. /** @hidden */
  79279. _checkCollision(collider: Collider): boolean;
  79280. /**
  79281. * Updates the submesh BoundingInfo
  79282. * @param world defines the world matrix to use to update the bounding info
  79283. * @returns the submesh
  79284. */
  79285. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  79286. /**
  79287. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  79288. * @param frustumPlanes defines the frustum planes
  79289. * @returns true if the submesh is intersecting with the frustum
  79290. */
  79291. isInFrustum(frustumPlanes: Plane[]): boolean;
  79292. /**
  79293. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  79294. * @param frustumPlanes defines the frustum planes
  79295. * @returns true if the submesh is inside the frustum
  79296. */
  79297. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79298. /**
  79299. * Renders the submesh
  79300. * @param enableAlphaMode defines if alpha needs to be used
  79301. * @returns the submesh
  79302. */
  79303. render(enableAlphaMode: boolean): SubMesh;
  79304. /**
  79305. * @hidden
  79306. */
  79307. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  79308. /**
  79309. * Checks if the submesh intersects with a ray
  79310. * @param ray defines the ray to test
  79311. * @returns true is the passed ray intersects the submesh bounding box
  79312. */
  79313. canIntersects(ray: Ray): boolean;
  79314. /**
  79315. * Intersects current submesh with a ray
  79316. * @param ray defines the ray to test
  79317. * @param positions defines mesh's positions array
  79318. * @param indices defines mesh's indices array
  79319. * @param fastCheck defines if only bounding info should be used
  79320. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  79321. * @returns intersection info or null if no intersection
  79322. */
  79323. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  79324. /** @hidden */
  79325. private _intersectLines;
  79326. /** @hidden */
  79327. private _intersectTriangles;
  79328. /** @hidden */
  79329. _rebuild(): void;
  79330. /**
  79331. * Creates a new submesh from the passed mesh
  79332. * @param newMesh defines the new hosting mesh
  79333. * @param newRenderingMesh defines an optional rendering mesh
  79334. * @returns the new submesh
  79335. */
  79336. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  79337. /**
  79338. * Release associated resources
  79339. */
  79340. dispose(): void;
  79341. /**
  79342. * Gets the class name
  79343. * @returns the string "SubMesh".
  79344. */
  79345. getClassName(): string;
  79346. /**
  79347. * Creates a new submesh from indices data
  79348. * @param materialIndex the index of the main mesh material
  79349. * @param startIndex the index where to start the copy in the mesh indices array
  79350. * @param indexCount the number of indices to copy then from the startIndex
  79351. * @param mesh the main mesh to create the submesh from
  79352. * @param renderingMesh the optional rendering mesh
  79353. * @returns a new submesh
  79354. */
  79355. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  79356. }
  79357. }
  79358. declare module BABYLON {
  79359. /**
  79360. * Class used to store geometry data (vertex buffers + index buffer)
  79361. */
  79362. export class Geometry implements IGetSetVerticesData {
  79363. /**
  79364. * Gets or sets the ID of the geometry
  79365. */
  79366. id: string;
  79367. /**
  79368. * Gets or sets the unique ID of the geometry
  79369. */
  79370. uniqueId: number;
  79371. /**
  79372. * Gets the delay loading state of the geometry (none by default which means not delayed)
  79373. */
  79374. delayLoadState: number;
  79375. /**
  79376. * Gets the file containing the data to load when running in delay load state
  79377. */
  79378. delayLoadingFile: Nullable<string>;
  79379. /**
  79380. * Callback called when the geometry is updated
  79381. */
  79382. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  79383. private _scene;
  79384. private _engine;
  79385. private _meshes;
  79386. private _totalVertices;
  79387. /** @hidden */
  79388. _indices: IndicesArray;
  79389. /** @hidden */
  79390. _vertexBuffers: {
  79391. [key: string]: VertexBuffer;
  79392. };
  79393. private _isDisposed;
  79394. private _extend;
  79395. private _boundingBias;
  79396. /** @hidden */
  79397. _delayInfo: Array<string>;
  79398. private _indexBuffer;
  79399. private _indexBufferIsUpdatable;
  79400. /** @hidden */
  79401. _boundingInfo: Nullable<BoundingInfo>;
  79402. /** @hidden */
  79403. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  79404. /** @hidden */
  79405. _softwareSkinningFrameId: number;
  79406. private _vertexArrayObjects;
  79407. private _updatable;
  79408. /** @hidden */
  79409. _positions: Nullable<Vector3[]>;
  79410. /**
  79411. * 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
  79412. */
  79413. /**
  79414. * 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
  79415. */
  79416. boundingBias: Vector2;
  79417. /**
  79418. * Static function used to attach a new empty geometry to a mesh
  79419. * @param mesh defines the mesh to attach the geometry to
  79420. * @returns the new Geometry
  79421. */
  79422. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  79423. /**
  79424. * Creates a new geometry
  79425. * @param id defines the unique ID
  79426. * @param scene defines the hosting scene
  79427. * @param vertexData defines the VertexData used to get geometry data
  79428. * @param updatable defines if geometry must be updatable (false by default)
  79429. * @param mesh defines the mesh that will be associated with the geometry
  79430. */
  79431. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  79432. /**
  79433. * Gets the current extend of the geometry
  79434. */
  79435. readonly extend: {
  79436. minimum: Vector3;
  79437. maximum: Vector3;
  79438. };
  79439. /**
  79440. * Gets the hosting scene
  79441. * @returns the hosting Scene
  79442. */
  79443. getScene(): Scene;
  79444. /**
  79445. * Gets the hosting engine
  79446. * @returns the hosting Engine
  79447. */
  79448. getEngine(): Engine;
  79449. /**
  79450. * Defines if the geometry is ready to use
  79451. * @returns true if the geometry is ready to be used
  79452. */
  79453. isReady(): boolean;
  79454. /**
  79455. * Gets a value indicating that the geometry should not be serialized
  79456. */
  79457. readonly doNotSerialize: boolean;
  79458. /** @hidden */
  79459. _rebuild(): void;
  79460. /**
  79461. * Affects all geometry data in one call
  79462. * @param vertexData defines the geometry data
  79463. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  79464. */
  79465. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  79466. /**
  79467. * Set specific vertex data
  79468. * @param kind defines the data kind (Position, normal, etc...)
  79469. * @param data defines the vertex data to use
  79470. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79471. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79472. */
  79473. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  79474. /**
  79475. * Removes a specific vertex data
  79476. * @param kind defines the data kind (Position, normal, etc...)
  79477. */
  79478. removeVerticesData(kind: string): void;
  79479. /**
  79480. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  79481. * @param buffer defines the vertex buffer to use
  79482. * @param totalVertices defines the total number of vertices for position kind (could be null)
  79483. */
  79484. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  79485. /**
  79486. * Update a specific vertex buffer
  79487. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  79488. * It will do nothing if the buffer is not updatable
  79489. * @param kind defines the data kind (Position, normal, etc...)
  79490. * @param data defines the data to use
  79491. * @param offset defines the offset in the target buffer where to store the data
  79492. * @param useBytes set to true if the offset is in bytes
  79493. */
  79494. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  79495. /**
  79496. * Update a specific vertex buffer
  79497. * This function will create a new buffer if the current one is not updatable
  79498. * @param kind defines the data kind (Position, normal, etc...)
  79499. * @param data defines the data to use
  79500. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  79501. */
  79502. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  79503. private _updateBoundingInfo;
  79504. /** @hidden */
  79505. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  79506. /**
  79507. * Gets total number of vertices
  79508. * @returns the total number of vertices
  79509. */
  79510. getTotalVertices(): number;
  79511. /**
  79512. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79513. * @param kind defines the data kind (Position, normal, etc...)
  79514. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79515. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79516. * @returns a float array containing vertex data
  79517. */
  79518. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79519. /**
  79520. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  79521. * @param kind defines the data kind (Position, normal, etc...)
  79522. * @returns true if the vertex buffer with the specified kind is updatable
  79523. */
  79524. isVertexBufferUpdatable(kind: string): boolean;
  79525. /**
  79526. * Gets a specific vertex buffer
  79527. * @param kind defines the data kind (Position, normal, etc...)
  79528. * @returns a VertexBuffer
  79529. */
  79530. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  79531. /**
  79532. * Returns all vertex buffers
  79533. * @return an object holding all vertex buffers indexed by kind
  79534. */
  79535. getVertexBuffers(): Nullable<{
  79536. [key: string]: VertexBuffer;
  79537. }>;
  79538. /**
  79539. * Gets a boolean indicating if specific vertex buffer is present
  79540. * @param kind defines the data kind (Position, normal, etc...)
  79541. * @returns true if data is present
  79542. */
  79543. isVerticesDataPresent(kind: string): boolean;
  79544. /**
  79545. * Gets a list of all attached data kinds (Position, normal, etc...)
  79546. * @returns a list of string containing all kinds
  79547. */
  79548. getVerticesDataKinds(): string[];
  79549. /**
  79550. * Update index buffer
  79551. * @param indices defines the indices to store in the index buffer
  79552. * @param offset defines the offset in the target buffer where to store the data
  79553. */
  79554. updateIndices(indices: IndicesArray, offset?: number): void;
  79555. /**
  79556. * Creates a new index buffer
  79557. * @param indices defines the indices to store in the index buffer
  79558. * @param totalVertices defines the total number of vertices (could be null)
  79559. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79560. */
  79561. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  79562. /**
  79563. * Return the total number of indices
  79564. * @returns the total number of indices
  79565. */
  79566. getTotalIndices(): number;
  79567. /**
  79568. * Gets the index buffer array
  79569. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79570. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79571. * @returns the index buffer array
  79572. */
  79573. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79574. /**
  79575. * Gets the index buffer
  79576. * @return the index buffer
  79577. */
  79578. getIndexBuffer(): Nullable<WebGLBuffer>;
  79579. /** @hidden */
  79580. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  79581. /**
  79582. * Release the associated resources for a specific mesh
  79583. * @param mesh defines the source mesh
  79584. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  79585. */
  79586. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  79587. /**
  79588. * Apply current geometry to a given mesh
  79589. * @param mesh defines the mesh to apply geometry to
  79590. */
  79591. applyToMesh(mesh: Mesh): void;
  79592. private _updateExtend;
  79593. private _applyToMesh;
  79594. private notifyUpdate;
  79595. /**
  79596. * Load the geometry if it was flagged as delay loaded
  79597. * @param scene defines the hosting scene
  79598. * @param onLoaded defines a callback called when the geometry is loaded
  79599. */
  79600. load(scene: Scene, onLoaded?: () => void): void;
  79601. private _queueLoad;
  79602. /**
  79603. * Invert the geometry to move from a right handed system to a left handed one.
  79604. */
  79605. toLeftHanded(): void;
  79606. /** @hidden */
  79607. _resetPointsArrayCache(): void;
  79608. /** @hidden */
  79609. _generatePointsArray(): boolean;
  79610. /**
  79611. * Gets a value indicating if the geometry is disposed
  79612. * @returns true if the geometry was disposed
  79613. */
  79614. isDisposed(): boolean;
  79615. private _disposeVertexArrayObjects;
  79616. /**
  79617. * Free all associated resources
  79618. */
  79619. dispose(): void;
  79620. /**
  79621. * Clone the current geometry into a new geometry
  79622. * @param id defines the unique ID of the new geometry
  79623. * @returns a new geometry object
  79624. */
  79625. copy(id: string): Geometry;
  79626. /**
  79627. * Serialize the current geometry info (and not the vertices data) into a JSON object
  79628. * @return a JSON representation of the current geometry data (without the vertices data)
  79629. */
  79630. serialize(): any;
  79631. private toNumberArray;
  79632. /**
  79633. * Serialize all vertices data into a JSON oject
  79634. * @returns a JSON representation of the current geometry data
  79635. */
  79636. serializeVerticeData(): any;
  79637. /**
  79638. * Extracts a clone of a mesh geometry
  79639. * @param mesh defines the source mesh
  79640. * @param id defines the unique ID of the new geometry object
  79641. * @returns the new geometry object
  79642. */
  79643. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  79644. /**
  79645. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  79646. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  79647. * Be aware Math.random() could cause collisions, but:
  79648. * "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"
  79649. * @returns a string containing a new GUID
  79650. */
  79651. static RandomId(): string;
  79652. /** @hidden */
  79653. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  79654. private static _CleanMatricesWeights;
  79655. /**
  79656. * Create a new geometry from persisted data (Using .babylon file format)
  79657. * @param parsedVertexData defines the persisted data
  79658. * @param scene defines the hosting scene
  79659. * @param rootUrl defines the root url to use to load assets (like delayed data)
  79660. * @returns the new geometry object
  79661. */
  79662. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  79663. }
  79664. }
  79665. declare module BABYLON {
  79666. /**
  79667. * Define an interface for all classes that will get and set the data on vertices
  79668. */
  79669. export interface IGetSetVerticesData {
  79670. /**
  79671. * Gets a boolean indicating if specific vertex data is present
  79672. * @param kind defines the vertex data kind to use
  79673. * @returns true is data kind is present
  79674. */
  79675. isVerticesDataPresent(kind: string): boolean;
  79676. /**
  79677. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79678. * @param kind defines the data kind (Position, normal, etc...)
  79679. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79680. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79681. * @returns a float array containing vertex data
  79682. */
  79683. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79684. /**
  79685. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79686. * @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.
  79687. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79688. * @returns the indices array or an empty array if the mesh has no geometry
  79689. */
  79690. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79691. /**
  79692. * Set specific vertex data
  79693. * @param kind defines the data kind (Position, normal, etc...)
  79694. * @param data defines the vertex data to use
  79695. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79696. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79697. */
  79698. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  79699. /**
  79700. * Update a specific associated vertex buffer
  79701. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79702. * - VertexBuffer.PositionKind
  79703. * - VertexBuffer.UVKind
  79704. * - VertexBuffer.UV2Kind
  79705. * - VertexBuffer.UV3Kind
  79706. * - VertexBuffer.UV4Kind
  79707. * - VertexBuffer.UV5Kind
  79708. * - VertexBuffer.UV6Kind
  79709. * - VertexBuffer.ColorKind
  79710. * - VertexBuffer.MatricesIndicesKind
  79711. * - VertexBuffer.MatricesIndicesExtraKind
  79712. * - VertexBuffer.MatricesWeightsKind
  79713. * - VertexBuffer.MatricesWeightsExtraKind
  79714. * @param data defines the data source
  79715. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  79716. * @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)
  79717. */
  79718. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  79719. /**
  79720. * Creates a new index buffer
  79721. * @param indices defines the indices to store in the index buffer
  79722. * @param totalVertices defines the total number of vertices (could be null)
  79723. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79724. */
  79725. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  79726. }
  79727. /**
  79728. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  79729. */
  79730. export class VertexData {
  79731. /**
  79732. * Mesh side orientation : usually the external or front surface
  79733. */
  79734. static readonly FRONTSIDE: number;
  79735. /**
  79736. * Mesh side orientation : usually the internal or back surface
  79737. */
  79738. static readonly BACKSIDE: number;
  79739. /**
  79740. * Mesh side orientation : both internal and external or front and back surfaces
  79741. */
  79742. static readonly DOUBLESIDE: number;
  79743. /**
  79744. * Mesh side orientation : by default, `FRONTSIDE`
  79745. */
  79746. static readonly DEFAULTSIDE: number;
  79747. /**
  79748. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  79749. */
  79750. positions: Nullable<FloatArray>;
  79751. /**
  79752. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  79753. */
  79754. normals: Nullable<FloatArray>;
  79755. /**
  79756. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  79757. */
  79758. tangents: Nullable<FloatArray>;
  79759. /**
  79760. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79761. */
  79762. uvs: Nullable<FloatArray>;
  79763. /**
  79764. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79765. */
  79766. uvs2: Nullable<FloatArray>;
  79767. /**
  79768. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79769. */
  79770. uvs3: Nullable<FloatArray>;
  79771. /**
  79772. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79773. */
  79774. uvs4: Nullable<FloatArray>;
  79775. /**
  79776. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79777. */
  79778. uvs5: Nullable<FloatArray>;
  79779. /**
  79780. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79781. */
  79782. uvs6: Nullable<FloatArray>;
  79783. /**
  79784. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  79785. */
  79786. colors: Nullable<FloatArray>;
  79787. /**
  79788. * 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).
  79789. */
  79790. matricesIndices: Nullable<FloatArray>;
  79791. /**
  79792. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  79793. */
  79794. matricesWeights: Nullable<FloatArray>;
  79795. /**
  79796. * An array extending the number of possible indices
  79797. */
  79798. matricesIndicesExtra: Nullable<FloatArray>;
  79799. /**
  79800. * An array extending the number of possible weights when the number of indices is extended
  79801. */
  79802. matricesWeightsExtra: Nullable<FloatArray>;
  79803. /**
  79804. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  79805. */
  79806. indices: Nullable<IndicesArray>;
  79807. /**
  79808. * Uses the passed data array to set the set the values for the specified kind of data
  79809. * @param data a linear array of floating numbers
  79810. * @param kind the type of data that is being set, eg positions, colors etc
  79811. */
  79812. set(data: FloatArray, kind: string): void;
  79813. /**
  79814. * Associates the vertexData to the passed Mesh.
  79815. * Sets it as updatable or not (default `false`)
  79816. * @param mesh the mesh the vertexData is applied to
  79817. * @param updatable when used and having the value true allows new data to update the vertexData
  79818. * @returns the VertexData
  79819. */
  79820. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  79821. /**
  79822. * Associates the vertexData to the passed Geometry.
  79823. * Sets it as updatable or not (default `false`)
  79824. * @param geometry the geometry the vertexData is applied to
  79825. * @param updatable when used and having the value true allows new data to update the vertexData
  79826. * @returns VertexData
  79827. */
  79828. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  79829. /**
  79830. * Updates the associated mesh
  79831. * @param mesh the mesh to be updated
  79832. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79833. * @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
  79834. * @returns VertexData
  79835. */
  79836. updateMesh(mesh: Mesh): VertexData;
  79837. /**
  79838. * Updates the associated geometry
  79839. * @param geometry the geometry to be updated
  79840. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79841. * @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
  79842. * @returns VertexData.
  79843. */
  79844. updateGeometry(geometry: Geometry): VertexData;
  79845. private _applyTo;
  79846. private _update;
  79847. /**
  79848. * Transforms each position and each normal of the vertexData according to the passed Matrix
  79849. * @param matrix the transforming matrix
  79850. * @returns the VertexData
  79851. */
  79852. transform(matrix: Matrix): VertexData;
  79853. /**
  79854. * Merges the passed VertexData into the current one
  79855. * @param other the VertexData to be merged into the current one
  79856. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  79857. * @returns the modified VertexData
  79858. */
  79859. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  79860. private _mergeElement;
  79861. private _validate;
  79862. /**
  79863. * Serializes the VertexData
  79864. * @returns a serialized object
  79865. */
  79866. serialize(): any;
  79867. /**
  79868. * Extracts the vertexData from a mesh
  79869. * @param mesh the mesh from which to extract the VertexData
  79870. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  79871. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79872. * @returns the object VertexData associated to the passed mesh
  79873. */
  79874. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79875. /**
  79876. * Extracts the vertexData from the geometry
  79877. * @param geometry the geometry from which to extract the VertexData
  79878. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  79879. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79880. * @returns the object VertexData associated to the passed mesh
  79881. */
  79882. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79883. private static _ExtractFrom;
  79884. /**
  79885. * Creates the VertexData for a Ribbon
  79886. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  79887. * * pathArray array of paths, each of which an array of successive Vector3
  79888. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  79889. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  79890. * * 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
  79891. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79892. * * 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)
  79893. * * 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)
  79894. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  79895. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  79896. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  79897. * @returns the VertexData of the ribbon
  79898. */
  79899. static CreateRibbon(options: {
  79900. pathArray: Vector3[][];
  79901. closeArray?: boolean;
  79902. closePath?: boolean;
  79903. offset?: number;
  79904. sideOrientation?: number;
  79905. frontUVs?: Vector4;
  79906. backUVs?: Vector4;
  79907. invertUV?: boolean;
  79908. uvs?: Vector2[];
  79909. colors?: Color4[];
  79910. }): VertexData;
  79911. /**
  79912. * Creates the VertexData for a box
  79913. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79914. * * size sets the width, height and depth of the box to the value of size, optional default 1
  79915. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  79916. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  79917. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  79918. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  79919. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  79920. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79921. * * 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)
  79922. * * 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)
  79923. * @returns the VertexData of the box
  79924. */
  79925. static CreateBox(options: {
  79926. size?: number;
  79927. width?: number;
  79928. height?: number;
  79929. depth?: number;
  79930. faceUV?: Vector4[];
  79931. faceColors?: Color4[];
  79932. sideOrientation?: number;
  79933. frontUVs?: Vector4;
  79934. backUVs?: Vector4;
  79935. }): VertexData;
  79936. /**
  79937. * Creates the VertexData for an ellipsoid, defaults to a sphere
  79938. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79939. * * segments sets the number of horizontal strips optional, default 32
  79940. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  79941. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  79942. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  79943. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  79944. * * 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
  79945. * * 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
  79946. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79947. * * 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)
  79948. * * 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)
  79949. * @returns the VertexData of the ellipsoid
  79950. */
  79951. static CreateSphere(options: {
  79952. segments?: number;
  79953. diameter?: number;
  79954. diameterX?: number;
  79955. diameterY?: number;
  79956. diameterZ?: number;
  79957. arc?: number;
  79958. slice?: number;
  79959. sideOrientation?: number;
  79960. frontUVs?: Vector4;
  79961. backUVs?: Vector4;
  79962. }): VertexData;
  79963. /**
  79964. * Creates the VertexData for a cylinder, cone or prism
  79965. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79966. * * height sets the height (y direction) of the cylinder, optional, default 2
  79967. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  79968. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  79969. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  79970. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  79971. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  79972. * * 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
  79973. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79974. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79975. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  79976. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  79977. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79978. * * 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)
  79979. * * 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)
  79980. * @returns the VertexData of the cylinder, cone or prism
  79981. */
  79982. static CreateCylinder(options: {
  79983. height?: number;
  79984. diameterTop?: number;
  79985. diameterBottom?: number;
  79986. diameter?: number;
  79987. tessellation?: number;
  79988. subdivisions?: number;
  79989. arc?: number;
  79990. faceColors?: Color4[];
  79991. faceUV?: Vector4[];
  79992. hasRings?: boolean;
  79993. enclose?: boolean;
  79994. sideOrientation?: number;
  79995. frontUVs?: Vector4;
  79996. backUVs?: Vector4;
  79997. }): VertexData;
  79998. /**
  79999. * Creates the VertexData for a torus
  80000. * @param options an object used to set the following optional parameters for the box, required but can be empty
  80001. * * diameter the diameter of the torus, optional default 1
  80002. * * thickness the diameter of the tube forming the torus, optional default 0.5
  80003. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  80004. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80005. * * 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)
  80006. * * 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)
  80007. * @returns the VertexData of the torus
  80008. */
  80009. static CreateTorus(options: {
  80010. diameter?: number;
  80011. thickness?: number;
  80012. tessellation?: number;
  80013. sideOrientation?: number;
  80014. frontUVs?: Vector4;
  80015. backUVs?: Vector4;
  80016. }): VertexData;
  80017. /**
  80018. * Creates the VertexData of the LineSystem
  80019. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  80020. * - lines an array of lines, each line being an array of successive Vector3
  80021. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  80022. * @returns the VertexData of the LineSystem
  80023. */
  80024. static CreateLineSystem(options: {
  80025. lines: Vector3[][];
  80026. colors?: Nullable<Color4[][]>;
  80027. }): VertexData;
  80028. /**
  80029. * Create the VertexData for a DashedLines
  80030. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  80031. * - points an array successive Vector3
  80032. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  80033. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  80034. * - dashNb the intended total number of dashes, optional, default 200
  80035. * @returns the VertexData for the DashedLines
  80036. */
  80037. static CreateDashedLines(options: {
  80038. points: Vector3[];
  80039. dashSize?: number;
  80040. gapSize?: number;
  80041. dashNb?: number;
  80042. }): VertexData;
  80043. /**
  80044. * Creates the VertexData for a Ground
  80045. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  80046. * - width the width (x direction) of the ground, optional, default 1
  80047. * - height the height (z direction) of the ground, optional, default 1
  80048. * - subdivisions the number of subdivisions per side, optional, default 1
  80049. * @returns the VertexData of the Ground
  80050. */
  80051. static CreateGround(options: {
  80052. width?: number;
  80053. height?: number;
  80054. subdivisions?: number;
  80055. subdivisionsX?: number;
  80056. subdivisionsY?: number;
  80057. }): VertexData;
  80058. /**
  80059. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  80060. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  80061. * * xmin the ground minimum X coordinate, optional, default -1
  80062. * * zmin the ground minimum Z coordinate, optional, default -1
  80063. * * xmax the ground maximum X coordinate, optional, default 1
  80064. * * zmax the ground maximum Z coordinate, optional, default 1
  80065. * * 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}
  80066. * * 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}
  80067. * @returns the VertexData of the TiledGround
  80068. */
  80069. static CreateTiledGround(options: {
  80070. xmin: number;
  80071. zmin: number;
  80072. xmax: number;
  80073. zmax: number;
  80074. subdivisions?: {
  80075. w: number;
  80076. h: number;
  80077. };
  80078. precision?: {
  80079. w: number;
  80080. h: number;
  80081. };
  80082. }): VertexData;
  80083. /**
  80084. * Creates the VertexData of the Ground designed from a heightmap
  80085. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  80086. * * width the width (x direction) of the ground
  80087. * * height the height (z direction) of the ground
  80088. * * subdivisions the number of subdivisions per side
  80089. * * minHeight the minimum altitude on the ground, optional, default 0
  80090. * * maxHeight the maximum altitude on the ground, optional default 1
  80091. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  80092. * * buffer the array holding the image color data
  80093. * * bufferWidth the width of image
  80094. * * bufferHeight the height of image
  80095. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  80096. * @returns the VertexData of the Ground designed from a heightmap
  80097. */
  80098. static CreateGroundFromHeightMap(options: {
  80099. width: number;
  80100. height: number;
  80101. subdivisions: number;
  80102. minHeight: number;
  80103. maxHeight: number;
  80104. colorFilter: Color3;
  80105. buffer: Uint8Array;
  80106. bufferWidth: number;
  80107. bufferHeight: number;
  80108. alphaFilter: number;
  80109. }): VertexData;
  80110. /**
  80111. * Creates the VertexData for a Plane
  80112. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  80113. * * size sets the width and height of the plane to the value of size, optional default 1
  80114. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  80115. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  80116. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80117. * * 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)
  80118. * * 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)
  80119. * @returns the VertexData of the box
  80120. */
  80121. static CreatePlane(options: {
  80122. size?: number;
  80123. width?: number;
  80124. height?: number;
  80125. sideOrientation?: number;
  80126. frontUVs?: Vector4;
  80127. backUVs?: Vector4;
  80128. }): VertexData;
  80129. /**
  80130. * Creates the VertexData of the Disc or regular Polygon
  80131. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  80132. * * radius the radius of the disc, optional default 0.5
  80133. * * tessellation the number of polygon sides, optional, default 64
  80134. * * 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
  80135. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80136. * * 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)
  80137. * * 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)
  80138. * @returns the VertexData of the box
  80139. */
  80140. static CreateDisc(options: {
  80141. radius?: number;
  80142. tessellation?: number;
  80143. arc?: number;
  80144. sideOrientation?: number;
  80145. frontUVs?: Vector4;
  80146. backUVs?: Vector4;
  80147. }): VertexData;
  80148. /**
  80149. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  80150. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  80151. * @param polygon a mesh built from polygonTriangulation.build()
  80152. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80153. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  80154. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  80155. * @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)
  80156. * @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)
  80157. * @returns the VertexData of the Polygon
  80158. */
  80159. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  80160. /**
  80161. * Creates the VertexData of the IcoSphere
  80162. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  80163. * * radius the radius of the IcoSphere, optional default 1
  80164. * * radiusX allows stretching in the x direction, optional, default radius
  80165. * * radiusY allows stretching in the y direction, optional, default radius
  80166. * * radiusZ allows stretching in the z direction, optional, default radius
  80167. * * flat when true creates a flat shaded mesh, optional, default true
  80168. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  80169. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80170. * * 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)
  80171. * * 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)
  80172. * @returns the VertexData of the IcoSphere
  80173. */
  80174. static CreateIcoSphere(options: {
  80175. radius?: number;
  80176. radiusX?: number;
  80177. radiusY?: number;
  80178. radiusZ?: number;
  80179. flat?: boolean;
  80180. subdivisions?: number;
  80181. sideOrientation?: number;
  80182. frontUVs?: Vector4;
  80183. backUVs?: Vector4;
  80184. }): VertexData;
  80185. /**
  80186. * Creates the VertexData for a Polyhedron
  80187. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  80188. * * type provided types are:
  80189. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  80190. * * 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)
  80191. * * size the size of the IcoSphere, optional default 1
  80192. * * sizeX allows stretching in the x direction, optional, default size
  80193. * * sizeY allows stretching in the y direction, optional, default size
  80194. * * sizeZ allows stretching in the z direction, optional, default size
  80195. * * 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
  80196. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  80197. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  80198. * * flat when true creates a flat shaded mesh, optional, default true
  80199. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  80200. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80201. * * 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)
  80202. * * 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)
  80203. * @returns the VertexData of the Polyhedron
  80204. */
  80205. static CreatePolyhedron(options: {
  80206. type?: number;
  80207. size?: number;
  80208. sizeX?: number;
  80209. sizeY?: number;
  80210. sizeZ?: number;
  80211. custom?: any;
  80212. faceUV?: Vector4[];
  80213. faceColors?: Color4[];
  80214. flat?: boolean;
  80215. sideOrientation?: number;
  80216. frontUVs?: Vector4;
  80217. backUVs?: Vector4;
  80218. }): VertexData;
  80219. /**
  80220. * Creates the VertexData for a TorusKnot
  80221. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  80222. * * radius the radius of the torus knot, optional, default 2
  80223. * * tube the thickness of the tube, optional, default 0.5
  80224. * * radialSegments the number of sides on each tube segments, optional, default 32
  80225. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  80226. * * p the number of windings around the z axis, optional, default 2
  80227. * * q the number of windings around the x axis, optional, default 3
  80228. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80229. * * 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)
  80230. * * 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)
  80231. * @returns the VertexData of the Torus Knot
  80232. */
  80233. static CreateTorusKnot(options: {
  80234. radius?: number;
  80235. tube?: number;
  80236. radialSegments?: number;
  80237. tubularSegments?: number;
  80238. p?: number;
  80239. q?: number;
  80240. sideOrientation?: number;
  80241. frontUVs?: Vector4;
  80242. backUVs?: Vector4;
  80243. }): VertexData;
  80244. /**
  80245. * Compute normals for given positions and indices
  80246. * @param positions an array of vertex positions, [...., x, y, z, ......]
  80247. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  80248. * @param normals an array of vertex normals, [...., x, y, z, ......]
  80249. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  80250. * * facetNormals : optional array of facet normals (vector3)
  80251. * * facetPositions : optional array of facet positions (vector3)
  80252. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  80253. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  80254. * * bInfo : optional bounding info, required for facetPartitioning computation
  80255. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  80256. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  80257. * * useRightHandedSystem: optional boolean to for right handed system computation
  80258. * * depthSort : optional boolean to enable the facet depth sort computation
  80259. * * distanceTo : optional Vector3 to compute the facet depth from this location
  80260. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  80261. */
  80262. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  80263. facetNormals?: any;
  80264. facetPositions?: any;
  80265. facetPartitioning?: any;
  80266. ratio?: number;
  80267. bInfo?: any;
  80268. bbSize?: Vector3;
  80269. subDiv?: any;
  80270. useRightHandedSystem?: boolean;
  80271. depthSort?: boolean;
  80272. distanceTo?: Vector3;
  80273. depthSortedFacets?: any;
  80274. }): void;
  80275. /** @hidden */
  80276. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  80277. /**
  80278. * Applies VertexData created from the imported parameters to the geometry
  80279. * @param parsedVertexData the parsed data from an imported file
  80280. * @param geometry the geometry to apply the VertexData to
  80281. */
  80282. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  80283. }
  80284. }
  80285. declare module BABYLON {
  80286. /**
  80287. * Class containing static functions to help procedurally build meshes
  80288. */
  80289. export class DiscBuilder {
  80290. /**
  80291. * Creates a plane polygonal mesh. By default, this is a disc
  80292. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  80293. * * 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
  80294. * * 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
  80295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80296. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  80297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80298. * @param name defines the name of the mesh
  80299. * @param options defines the options used to create the mesh
  80300. * @param scene defines the hosting scene
  80301. * @returns the plane polygonal mesh
  80302. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  80303. */
  80304. static CreateDisc(name: string, options: {
  80305. radius?: number;
  80306. tessellation?: number;
  80307. arc?: number;
  80308. updatable?: boolean;
  80309. sideOrientation?: number;
  80310. frontUVs?: Vector4;
  80311. backUVs?: Vector4;
  80312. }, scene?: Nullable<Scene>): Mesh;
  80313. }
  80314. }
  80315. declare module BABYLON {
  80316. /**
  80317. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  80318. *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.
  80319. * The SPS is also a particle system. It provides some methods to manage the particles.
  80320. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  80321. *
  80322. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  80323. */
  80324. export class SolidParticleSystem implements IDisposable {
  80325. /**
  80326. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  80327. * Example : var p = SPS.particles[i];
  80328. */
  80329. particles: SolidParticle[];
  80330. /**
  80331. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  80332. */
  80333. nbParticles: number;
  80334. /**
  80335. * If the particles must ever face the camera (default false). Useful for planar particles.
  80336. */
  80337. billboard: boolean;
  80338. /**
  80339. * Recompute normals when adding a shape
  80340. */
  80341. recomputeNormals: boolean;
  80342. /**
  80343. * This a counter ofr your own usage. It's not set by any SPS functions.
  80344. */
  80345. counter: number;
  80346. /**
  80347. * The SPS name. This name is also given to the underlying mesh.
  80348. */
  80349. name: string;
  80350. /**
  80351. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  80352. */
  80353. mesh: Mesh;
  80354. /**
  80355. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  80356. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  80357. */
  80358. vars: any;
  80359. /**
  80360. * This array is populated when the SPS is set as 'pickable'.
  80361. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  80362. * Each element of this array is an object `{idx: int, faceId: int}`.
  80363. * `idx` is the picked particle index in the `SPS.particles` array
  80364. * `faceId` is the picked face index counted within this particle.
  80365. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  80366. */
  80367. pickedParticles: {
  80368. idx: number;
  80369. faceId: number;
  80370. }[];
  80371. /**
  80372. * This array is populated when `enableDepthSort` is set to true.
  80373. * Each element of this array is an instance of the class DepthSortedParticle.
  80374. */
  80375. depthSortedParticles: DepthSortedParticle[];
  80376. /**
  80377. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  80378. * @hidden
  80379. */
  80380. _bSphereOnly: boolean;
  80381. /**
  80382. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  80383. * @hidden
  80384. */
  80385. _bSphereRadiusFactor: number;
  80386. private _scene;
  80387. private _positions;
  80388. private _indices;
  80389. private _normals;
  80390. private _colors;
  80391. private _uvs;
  80392. private _indices32;
  80393. private _positions32;
  80394. private _normals32;
  80395. private _fixedNormal32;
  80396. private _colors32;
  80397. private _uvs32;
  80398. private _index;
  80399. private _updatable;
  80400. private _pickable;
  80401. private _isVisibilityBoxLocked;
  80402. private _alwaysVisible;
  80403. private _depthSort;
  80404. private _shapeCounter;
  80405. private _copy;
  80406. private _color;
  80407. private _computeParticleColor;
  80408. private _computeParticleTexture;
  80409. private _computeParticleRotation;
  80410. private _computeParticleVertex;
  80411. private _computeBoundingBox;
  80412. private _depthSortParticles;
  80413. private _camera;
  80414. private _mustUnrotateFixedNormals;
  80415. private _particlesIntersect;
  80416. private _needs32Bits;
  80417. /**
  80418. * Creates a SPS (Solid Particle System) object.
  80419. * @param name (String) is the SPS name, this will be the underlying mesh name.
  80420. * @param scene (Scene) is the scene in which the SPS is added.
  80421. * @param options defines the options of the sps e.g.
  80422. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  80423. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  80424. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  80425. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  80426. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  80427. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  80428. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  80429. */
  80430. constructor(name: string, scene: Scene, options?: {
  80431. updatable?: boolean;
  80432. isPickable?: boolean;
  80433. enableDepthSort?: boolean;
  80434. particleIntersection?: boolean;
  80435. boundingSphereOnly?: boolean;
  80436. bSphereRadiusFactor?: number;
  80437. });
  80438. /**
  80439. * Builds the SPS underlying mesh. Returns a standard Mesh.
  80440. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  80441. * @returns the created mesh
  80442. */
  80443. buildMesh(): Mesh;
  80444. /**
  80445. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  80446. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  80447. * Thus the particles generated from `digest()` have their property `position` set yet.
  80448. * @param mesh ( Mesh ) is the mesh to be digested
  80449. * @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
  80450. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  80451. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  80452. * @returns the current SPS
  80453. */
  80454. digest(mesh: Mesh, options?: {
  80455. facetNb?: number;
  80456. number?: number;
  80457. delta?: number;
  80458. }): SolidParticleSystem;
  80459. private _unrotateFixedNormals;
  80460. private _resetCopy;
  80461. private _meshBuilder;
  80462. private _posToShape;
  80463. private _uvsToShapeUV;
  80464. private _addParticle;
  80465. /**
  80466. * Adds some particles to the SPS from the model shape. Returns the shape id.
  80467. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  80468. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  80469. * @param nb (positive integer) the number of particles to be created from this model
  80470. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  80471. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  80472. * @returns the number of shapes in the system
  80473. */
  80474. addShape(mesh: Mesh, nb: number, options?: {
  80475. positionFunction?: any;
  80476. vertexFunction?: any;
  80477. }): number;
  80478. private _rebuildParticle;
  80479. /**
  80480. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  80481. * @returns the SPS.
  80482. */
  80483. rebuildMesh(): SolidParticleSystem;
  80484. /**
  80485. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  80486. * This method calls `updateParticle()` for each particle of the SPS.
  80487. * For an animated SPS, it is usually called within the render loop.
  80488. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  80489. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  80490. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  80491. * @returns the SPS.
  80492. */
  80493. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  80494. /**
  80495. * Disposes the SPS.
  80496. */
  80497. dispose(): void;
  80498. /**
  80499. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  80500. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80501. * @returns the SPS.
  80502. */
  80503. refreshVisibleSize(): SolidParticleSystem;
  80504. /**
  80505. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  80506. * @param size the size (float) of the visibility box
  80507. * note : this doesn't lock the SPS mesh bounding box.
  80508. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80509. */
  80510. setVisibilityBox(size: number): void;
  80511. /**
  80512. * Gets whether the SPS as always visible or not
  80513. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80514. */
  80515. /**
  80516. * Sets the SPS as always visible or not
  80517. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80518. */
  80519. isAlwaysVisible: boolean;
  80520. /**
  80521. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80522. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80523. */
  80524. /**
  80525. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80526. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80527. */
  80528. isVisibilityBoxLocked: boolean;
  80529. /**
  80530. * Tells to `setParticles()` to compute the particle rotations or not.
  80531. * Default value : true. The SPS is faster when it's set to false.
  80532. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80533. */
  80534. /**
  80535. * Gets if `setParticles()` computes the particle rotations or not.
  80536. * Default value : true. The SPS is faster when it's set to false.
  80537. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80538. */
  80539. computeParticleRotation: boolean;
  80540. /**
  80541. * Tells to `setParticles()` to compute the particle colors or not.
  80542. * Default value : true. The SPS is faster when it's set to false.
  80543. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80544. */
  80545. /**
  80546. * Gets if `setParticles()` computes the particle colors or not.
  80547. * Default value : true. The SPS is faster when it's set to false.
  80548. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80549. */
  80550. computeParticleColor: boolean;
  80551. /**
  80552. * Gets if `setParticles()` computes the particle textures or not.
  80553. * Default value : true. The SPS is faster when it's set to false.
  80554. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  80555. */
  80556. computeParticleTexture: boolean;
  80557. /**
  80558. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  80559. * Default value : false. The SPS is faster when it's set to false.
  80560. * Note : the particle custom vertex positions aren't stored values.
  80561. */
  80562. /**
  80563. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  80564. * Default value : false. The SPS is faster when it's set to false.
  80565. * Note : the particle custom vertex positions aren't stored values.
  80566. */
  80567. computeParticleVertex: boolean;
  80568. /**
  80569. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  80570. */
  80571. /**
  80572. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  80573. */
  80574. computeBoundingBox: boolean;
  80575. /**
  80576. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  80577. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80578. * Default : `true`
  80579. */
  80580. /**
  80581. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  80582. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80583. * Default : `true`
  80584. */
  80585. depthSortParticles: boolean;
  80586. /**
  80587. * This function does nothing. It may be overwritten to set all the particle first values.
  80588. * The SPS doesn't call this function, you may have to call it by your own.
  80589. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80590. */
  80591. initParticles(): void;
  80592. /**
  80593. * This function does nothing. It may be overwritten to recycle a particle.
  80594. * The SPS doesn't call this function, you may have to call it by your own.
  80595. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80596. * @param particle The particle to recycle
  80597. * @returns the recycled particle
  80598. */
  80599. recycleParticle(particle: SolidParticle): SolidParticle;
  80600. /**
  80601. * Updates a particle : this function should be overwritten by the user.
  80602. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  80603. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80604. * @example : just set a particle position or velocity and recycle conditions
  80605. * @param particle The particle to update
  80606. * @returns the updated particle
  80607. */
  80608. updateParticle(particle: SolidParticle): SolidParticle;
  80609. /**
  80610. * Updates a vertex of a particle : it can be overwritten by the user.
  80611. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  80612. * @param particle the current particle
  80613. * @param vertex the current index of the current particle
  80614. * @param pt the index of the current vertex in the particle shape
  80615. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  80616. * @example : just set a vertex particle position
  80617. * @returns the updated vertex
  80618. */
  80619. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  80620. /**
  80621. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  80622. * This does nothing and may be overwritten by the user.
  80623. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80624. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80625. * @param update the boolean update value actually passed to setParticles()
  80626. */
  80627. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80628. /**
  80629. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  80630. * This will be passed three parameters.
  80631. * This does nothing and may be overwritten by the user.
  80632. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80633. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80634. * @param update the boolean update value actually passed to setParticles()
  80635. */
  80636. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80637. }
  80638. }
  80639. declare module BABYLON {
  80640. /**
  80641. * Represents one particle of a solid particle system.
  80642. */
  80643. export class SolidParticle {
  80644. /**
  80645. * particle global index
  80646. */
  80647. idx: number;
  80648. /**
  80649. * The color of the particle
  80650. */
  80651. color: Nullable<Color4>;
  80652. /**
  80653. * The world space position of the particle.
  80654. */
  80655. position: Vector3;
  80656. /**
  80657. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  80658. */
  80659. rotation: Vector3;
  80660. /**
  80661. * The world space rotation quaternion of the particle.
  80662. */
  80663. rotationQuaternion: Nullable<Quaternion>;
  80664. /**
  80665. * The scaling of the particle.
  80666. */
  80667. scaling: Vector3;
  80668. /**
  80669. * The uvs of the particle.
  80670. */
  80671. uvs: Vector4;
  80672. /**
  80673. * The current speed of the particle.
  80674. */
  80675. velocity: Vector3;
  80676. /**
  80677. * The pivot point in the particle local space.
  80678. */
  80679. pivot: Vector3;
  80680. /**
  80681. * Must the particle be translated from its pivot point in its local space ?
  80682. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  80683. * Default : false
  80684. */
  80685. translateFromPivot: boolean;
  80686. /**
  80687. * Is the particle active or not ?
  80688. */
  80689. alive: boolean;
  80690. /**
  80691. * Is the particle visible or not ?
  80692. */
  80693. isVisible: boolean;
  80694. /**
  80695. * Index of this particle in the global "positions" array (Internal use)
  80696. * @hidden
  80697. */
  80698. _pos: number;
  80699. /**
  80700. * @hidden Index of this particle in the global "indices" array (Internal use)
  80701. */
  80702. _ind: number;
  80703. /**
  80704. * @hidden ModelShape of this particle (Internal use)
  80705. */
  80706. _model: ModelShape;
  80707. /**
  80708. * ModelShape id of this particle
  80709. */
  80710. shapeId: number;
  80711. /**
  80712. * Index of the particle in its shape id (Internal use)
  80713. */
  80714. idxInShape: number;
  80715. /**
  80716. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  80717. */
  80718. _modelBoundingInfo: BoundingInfo;
  80719. /**
  80720. * @hidden Particle BoundingInfo object (Internal use)
  80721. */
  80722. _boundingInfo: BoundingInfo;
  80723. /**
  80724. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  80725. */
  80726. _sps: SolidParticleSystem;
  80727. /**
  80728. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  80729. */
  80730. _stillInvisible: boolean;
  80731. /**
  80732. * @hidden Last computed particle rotation matrix
  80733. */
  80734. _rotationMatrix: number[];
  80735. /**
  80736. * Parent particle Id, if any.
  80737. * Default null.
  80738. */
  80739. parentId: Nullable<number>;
  80740. /**
  80741. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  80742. * The possible values are :
  80743. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80744. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80745. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80746. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80747. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80748. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  80749. * */
  80750. cullingStrategy: number;
  80751. /**
  80752. * @hidden Internal global position in the SPS.
  80753. */
  80754. _globalPosition: Vector3;
  80755. /**
  80756. * Creates a Solid Particle object.
  80757. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  80758. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  80759. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  80760. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  80761. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  80762. * @param shapeId (integer) is the model shape identifier in the SPS.
  80763. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  80764. * @param sps defines the sps it is associated to
  80765. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  80766. */
  80767. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  80768. /**
  80769. * Legacy support, changed scale to scaling
  80770. */
  80771. /**
  80772. * Legacy support, changed scale to scaling
  80773. */
  80774. scale: Vector3;
  80775. /**
  80776. * Legacy support, changed quaternion to rotationQuaternion
  80777. */
  80778. /**
  80779. * Legacy support, changed quaternion to rotationQuaternion
  80780. */
  80781. quaternion: Nullable<Quaternion>;
  80782. /**
  80783. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  80784. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  80785. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  80786. * @returns true if it intersects
  80787. */
  80788. intersectsMesh(target: Mesh | SolidParticle): boolean;
  80789. /**
  80790. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  80791. * A particle is in the frustum if its bounding box intersects the frustum
  80792. * @param frustumPlanes defines the frustum to test
  80793. * @returns true if the particle is in the frustum planes
  80794. */
  80795. isInFrustum(frustumPlanes: Plane[]): boolean;
  80796. /**
  80797. * get the rotation matrix of the particle
  80798. * @hidden
  80799. */
  80800. getRotationMatrix(m: Matrix): void;
  80801. }
  80802. /**
  80803. * Represents the shape of the model used by one particle of a solid particle system.
  80804. * SPS internal tool, don't use it manually.
  80805. */
  80806. export class ModelShape {
  80807. /**
  80808. * The shape id
  80809. * @hidden
  80810. */
  80811. shapeID: number;
  80812. /**
  80813. * flat array of model positions (internal use)
  80814. * @hidden
  80815. */
  80816. _shape: Vector3[];
  80817. /**
  80818. * flat array of model UVs (internal use)
  80819. * @hidden
  80820. */
  80821. _shapeUV: number[];
  80822. /**
  80823. * length of the shape in the model indices array (internal use)
  80824. * @hidden
  80825. */
  80826. _indicesLength: number;
  80827. /**
  80828. * Custom position function (internal use)
  80829. * @hidden
  80830. */
  80831. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  80832. /**
  80833. * Custom vertex function (internal use)
  80834. * @hidden
  80835. */
  80836. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  80837. /**
  80838. * 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.
  80839. * SPS internal tool, don't use it manually.
  80840. * @hidden
  80841. */
  80842. 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>);
  80843. }
  80844. /**
  80845. * Represents a Depth Sorted Particle in the solid particle system.
  80846. */
  80847. export class DepthSortedParticle {
  80848. /**
  80849. * Index of the particle in the "indices" array
  80850. */
  80851. ind: number;
  80852. /**
  80853. * Length of the particle shape in the "indices" array
  80854. */
  80855. indicesLength: number;
  80856. /**
  80857. * Squared distance from the particle to the camera
  80858. */
  80859. sqDistance: number;
  80860. }
  80861. }
  80862. declare module BABYLON {
  80863. /**
  80864. * Class used to store all common mesh properties
  80865. */
  80866. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  80867. /** No occlusion */
  80868. static OCCLUSION_TYPE_NONE: number;
  80869. /** Occlusion set to optimisitic */
  80870. static OCCLUSION_TYPE_OPTIMISTIC: number;
  80871. /** Occlusion set to strict */
  80872. static OCCLUSION_TYPE_STRICT: number;
  80873. /** Use an accurante occlusion algorithm */
  80874. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  80875. /** Use a conservative occlusion algorithm */
  80876. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  80877. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80878. * Test order :
  80879. * Is the bounding sphere outside the frustum ?
  80880. * If not, are the bounding box vertices outside the frustum ?
  80881. * It not, then the cullable object is in the frustum.
  80882. */
  80883. static readonly CULLINGSTRATEGY_STANDARD: number;
  80884. /** Culling strategy : Bounding Sphere Only.
  80885. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80886. * It's also less accurate than the standard because some not visible objects can still be selected.
  80887. * Test : is the bounding sphere outside the frustum ?
  80888. * If not, then the cullable object is in the frustum.
  80889. */
  80890. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80891. /** Culling strategy : Optimistic Inclusion.
  80892. * This in an inclusion test first, then the standard exclusion test.
  80893. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80894. * 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.
  80895. * Anyway, it's as accurate as the standard strategy.
  80896. * Test :
  80897. * Is the cullable object bounding sphere center in the frustum ?
  80898. * If not, apply the default culling strategy.
  80899. */
  80900. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80901. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80902. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80903. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80904. * 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.
  80905. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80906. * Test :
  80907. * Is the cullable object bounding sphere center in the frustum ?
  80908. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80909. */
  80910. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80911. /**
  80912. * No billboard
  80913. */
  80914. static readonly BILLBOARDMODE_NONE: number;
  80915. /** Billboard on X axis */
  80916. static readonly BILLBOARDMODE_X: number;
  80917. /** Billboard on Y axis */
  80918. static readonly BILLBOARDMODE_Y: number;
  80919. /** Billboard on Z axis */
  80920. static readonly BILLBOARDMODE_Z: number;
  80921. /** Billboard on all axes */
  80922. static readonly BILLBOARDMODE_ALL: number;
  80923. private _facetData;
  80924. /**
  80925. * The culling strategy to use to check whether the mesh must be rendered or not.
  80926. * This value can be changed at any time and will be used on the next render mesh selection.
  80927. * The possible values are :
  80928. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80929. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80930. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80931. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80932. * Please read each static variable documentation to get details about the culling process.
  80933. * */
  80934. cullingStrategy: number;
  80935. /**
  80936. * Gets the number of facets in the mesh
  80937. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80938. */
  80939. readonly facetNb: number;
  80940. /**
  80941. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  80942. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80943. */
  80944. partitioningSubdivisions: number;
  80945. /**
  80946. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  80947. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  80948. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80949. */
  80950. partitioningBBoxRatio: number;
  80951. /**
  80952. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  80953. * Works only for updatable meshes.
  80954. * Doesn't work with multi-materials
  80955. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80956. */
  80957. mustDepthSortFacets: boolean;
  80958. /**
  80959. * The location (Vector3) where the facet depth sort must be computed from.
  80960. * By default, the active camera position.
  80961. * Used only when facet depth sort is enabled
  80962. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80963. */
  80964. facetDepthSortFrom: Vector3;
  80965. /**
  80966. * gets a boolean indicating if facetData is enabled
  80967. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80968. */
  80969. readonly isFacetDataEnabled: boolean;
  80970. /** @hidden */
  80971. _updateNonUniformScalingState(value: boolean): boolean;
  80972. /**
  80973. * An event triggered when this mesh collides with another one
  80974. */
  80975. onCollideObservable: Observable<AbstractMesh>;
  80976. private _onCollideObserver;
  80977. /** Set a function to call when this mesh collides with another one */
  80978. onCollide: () => void;
  80979. /**
  80980. * An event triggered when the collision's position changes
  80981. */
  80982. onCollisionPositionChangeObservable: Observable<Vector3>;
  80983. private _onCollisionPositionChangeObserver;
  80984. /** Set a function to call when the collision's position changes */
  80985. onCollisionPositionChange: () => void;
  80986. /**
  80987. * An event triggered when material is changed
  80988. */
  80989. onMaterialChangedObservable: Observable<AbstractMesh>;
  80990. /**
  80991. * Gets or sets the orientation for POV movement & rotation
  80992. */
  80993. definedFacingForward: boolean;
  80994. /** @hidden */
  80995. _occlusionQuery: Nullable<WebGLQuery>;
  80996. private _visibility;
  80997. /**
  80998. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80999. */
  81000. /**
  81001. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  81002. */
  81003. visibility: number;
  81004. /** Gets or sets the alpha index used to sort transparent meshes
  81005. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  81006. */
  81007. alphaIndex: number;
  81008. /**
  81009. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  81010. */
  81011. isVisible: boolean;
  81012. /**
  81013. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  81014. */
  81015. isPickable: boolean;
  81016. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  81017. showSubMeshesBoundingBox: boolean;
  81018. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  81019. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  81020. */
  81021. isBlocker: boolean;
  81022. /**
  81023. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  81024. */
  81025. enablePointerMoveEvents: boolean;
  81026. /**
  81027. * Specifies the rendering group id for this mesh (0 by default)
  81028. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  81029. */
  81030. renderingGroupId: number;
  81031. private _material;
  81032. /** Gets or sets current material */
  81033. material: Nullable<Material>;
  81034. private _receiveShadows;
  81035. /**
  81036. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  81037. * @see http://doc.babylonjs.com/babylon101/shadows
  81038. */
  81039. receiveShadows: boolean;
  81040. /** Defines color to use when rendering outline */
  81041. outlineColor: Color3;
  81042. /** Define width to use when rendering outline */
  81043. outlineWidth: number;
  81044. /** Defines color to use when rendering overlay */
  81045. overlayColor: Color3;
  81046. /** Defines alpha to use when rendering overlay */
  81047. overlayAlpha: number;
  81048. private _hasVertexAlpha;
  81049. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  81050. hasVertexAlpha: boolean;
  81051. private _useVertexColors;
  81052. /** 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) */
  81053. useVertexColors: boolean;
  81054. private _computeBonesUsingShaders;
  81055. /**
  81056. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  81057. */
  81058. computeBonesUsingShaders: boolean;
  81059. private _numBoneInfluencers;
  81060. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  81061. numBoneInfluencers: number;
  81062. private _applyFog;
  81063. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  81064. applyFog: boolean;
  81065. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  81066. useOctreeForRenderingSelection: boolean;
  81067. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  81068. useOctreeForPicking: boolean;
  81069. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  81070. useOctreeForCollisions: boolean;
  81071. private _layerMask;
  81072. /**
  81073. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  81074. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  81075. */
  81076. layerMask: number;
  81077. /**
  81078. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  81079. */
  81080. alwaysSelectAsActiveMesh: boolean;
  81081. /**
  81082. * Gets or sets the current action manager
  81083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81084. */
  81085. actionManager: Nullable<AbstractActionManager>;
  81086. private _checkCollisions;
  81087. private _collisionMask;
  81088. private _collisionGroup;
  81089. /**
  81090. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  81091. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81092. */
  81093. ellipsoid: Vector3;
  81094. /**
  81095. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  81096. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81097. */
  81098. ellipsoidOffset: Vector3;
  81099. private _collider;
  81100. private _oldPositionForCollisions;
  81101. private _diffPositionForCollisions;
  81102. /**
  81103. * Gets or sets a collision mask used to mask collisions (default is -1).
  81104. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  81105. */
  81106. collisionMask: number;
  81107. /**
  81108. * Gets or sets the current collision group mask (-1 by default).
  81109. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  81110. */
  81111. collisionGroup: number;
  81112. /**
  81113. * Defines edge width used when edgesRenderer is enabled
  81114. * @see https://www.babylonjs-playground.com/#10OJSG#13
  81115. */
  81116. edgesWidth: number;
  81117. /**
  81118. * Defines edge color used when edgesRenderer is enabled
  81119. * @see https://www.babylonjs-playground.com/#10OJSG#13
  81120. */
  81121. edgesColor: Color4;
  81122. /** @hidden */
  81123. _edgesRenderer: Nullable<IEdgesRenderer>;
  81124. /** @hidden */
  81125. _masterMesh: Nullable<AbstractMesh>;
  81126. /** @hidden */
  81127. _boundingInfo: Nullable<BoundingInfo>;
  81128. /** @hidden */
  81129. _renderId: number;
  81130. /**
  81131. * Gets or sets the list of subMeshes
  81132. * @see http://doc.babylonjs.com/how_to/multi_materials
  81133. */
  81134. subMeshes: SubMesh[];
  81135. /** @hidden */
  81136. _intersectionsInProgress: AbstractMesh[];
  81137. /** @hidden */
  81138. _unIndexed: boolean;
  81139. /** @hidden */
  81140. _lightSources: Light[];
  81141. /** @hidden */
  81142. readonly _positions: Nullable<Vector3[]>;
  81143. /** @hidden */
  81144. _waitingActions: any;
  81145. /** @hidden */
  81146. _waitingFreezeWorldMatrix: Nullable<boolean>;
  81147. private _skeleton;
  81148. /** @hidden */
  81149. _bonesTransformMatrices: Nullable<Float32Array>;
  81150. /**
  81151. * Gets or sets a skeleton to apply skining transformations
  81152. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81153. */
  81154. skeleton: Nullable<Skeleton>;
  81155. /**
  81156. * An event triggered when the mesh is rebuilt.
  81157. */
  81158. onRebuildObservable: Observable<AbstractMesh>;
  81159. /**
  81160. * Creates a new AbstractMesh
  81161. * @param name defines the name of the mesh
  81162. * @param scene defines the hosting scene
  81163. */
  81164. constructor(name: string, scene?: Nullable<Scene>);
  81165. /**
  81166. * Returns the string "AbstractMesh"
  81167. * @returns "AbstractMesh"
  81168. */
  81169. getClassName(): string;
  81170. /**
  81171. * Gets a string representation of the current mesh
  81172. * @param fullDetails defines a boolean indicating if full details must be included
  81173. * @returns a string representation of the current mesh
  81174. */
  81175. toString(fullDetails?: boolean): string;
  81176. /** @hidden */
  81177. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  81178. /** @hidden */
  81179. _rebuild(): void;
  81180. /** @hidden */
  81181. _resyncLightSources(): void;
  81182. /** @hidden */
  81183. _resyncLighSource(light: Light): void;
  81184. /** @hidden */
  81185. _unBindEffect(): void;
  81186. /** @hidden */
  81187. _removeLightSource(light: Light): void;
  81188. private _markSubMeshesAsDirty;
  81189. /** @hidden */
  81190. _markSubMeshesAsLightDirty(): void;
  81191. /** @hidden */
  81192. _markSubMeshesAsAttributesDirty(): void;
  81193. /** @hidden */
  81194. _markSubMeshesAsMiscDirty(): void;
  81195. /**
  81196. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  81197. */
  81198. scaling: Vector3;
  81199. /**
  81200. * Returns true if the mesh is blocked. Implemented by child classes
  81201. */
  81202. readonly isBlocked: boolean;
  81203. /**
  81204. * Returns the mesh itself by default. Implemented by child classes
  81205. * @param camera defines the camera to use to pick the right LOD level
  81206. * @returns the currentAbstractMesh
  81207. */
  81208. getLOD(camera: Camera): Nullable<AbstractMesh>;
  81209. /**
  81210. * Returns 0 by default. Implemented by child classes
  81211. * @returns an integer
  81212. */
  81213. getTotalVertices(): number;
  81214. /**
  81215. * Returns a positive integer : the total number of indices in this mesh geometry.
  81216. * @returns the numner of indices or zero if the mesh has no geometry.
  81217. */
  81218. getTotalIndices(): number;
  81219. /**
  81220. * Returns null by default. Implemented by child classes
  81221. * @returns null
  81222. */
  81223. getIndices(): Nullable<IndicesArray>;
  81224. /**
  81225. * Returns the array of the requested vertex data kind. Implemented by child classes
  81226. * @param kind defines the vertex data kind to use
  81227. * @returns null
  81228. */
  81229. getVerticesData(kind: string): Nullable<FloatArray>;
  81230. /**
  81231. * Sets the vertex data of the mesh geometry for the requested `kind`.
  81232. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  81233. * Note that a new underlying VertexBuffer object is created each call.
  81234. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  81235. * @param kind defines vertex data kind:
  81236. * * VertexBuffer.PositionKind
  81237. * * VertexBuffer.UVKind
  81238. * * VertexBuffer.UV2Kind
  81239. * * VertexBuffer.UV3Kind
  81240. * * VertexBuffer.UV4Kind
  81241. * * VertexBuffer.UV5Kind
  81242. * * VertexBuffer.UV6Kind
  81243. * * VertexBuffer.ColorKind
  81244. * * VertexBuffer.MatricesIndicesKind
  81245. * * VertexBuffer.MatricesIndicesExtraKind
  81246. * * VertexBuffer.MatricesWeightsKind
  81247. * * VertexBuffer.MatricesWeightsExtraKind
  81248. * @param data defines the data source
  81249. * @param updatable defines if the data must be flagged as updatable (or static)
  81250. * @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
  81251. * @returns the current mesh
  81252. */
  81253. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  81254. /**
  81255. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  81256. * If the mesh has no geometry, it is simply returned as it is.
  81257. * @param kind defines vertex data kind:
  81258. * * VertexBuffer.PositionKind
  81259. * * VertexBuffer.UVKind
  81260. * * VertexBuffer.UV2Kind
  81261. * * VertexBuffer.UV3Kind
  81262. * * VertexBuffer.UV4Kind
  81263. * * VertexBuffer.UV5Kind
  81264. * * VertexBuffer.UV6Kind
  81265. * * VertexBuffer.ColorKind
  81266. * * VertexBuffer.MatricesIndicesKind
  81267. * * VertexBuffer.MatricesIndicesExtraKind
  81268. * * VertexBuffer.MatricesWeightsKind
  81269. * * VertexBuffer.MatricesWeightsExtraKind
  81270. * @param data defines the data source
  81271. * @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
  81272. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  81273. * @returns the current mesh
  81274. */
  81275. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  81276. /**
  81277. * Sets the mesh indices,
  81278. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  81279. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  81280. * @param totalVertices Defines the total number of vertices
  81281. * @returns the current mesh
  81282. */
  81283. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  81284. /**
  81285. * Gets a boolean indicating if specific vertex data is present
  81286. * @param kind defines the vertex data kind to use
  81287. * @returns true is data kind is present
  81288. */
  81289. isVerticesDataPresent(kind: string): boolean;
  81290. /**
  81291. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  81292. * @returns a BoundingInfo
  81293. */
  81294. getBoundingInfo(): BoundingInfo;
  81295. /**
  81296. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81297. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  81298. * @returns the current mesh
  81299. */
  81300. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  81301. /**
  81302. * Overwrite the current bounding info
  81303. * @param boundingInfo defines the new bounding info
  81304. * @returns the current mesh
  81305. */
  81306. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  81307. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  81308. readonly useBones: boolean;
  81309. /** @hidden */
  81310. _preActivate(): void;
  81311. /** @hidden */
  81312. _preActivateForIntermediateRendering(renderId: number): void;
  81313. /** @hidden */
  81314. _activate(renderId: number): void;
  81315. /**
  81316. * Gets the current world matrix
  81317. * @returns a Matrix
  81318. */
  81319. getWorldMatrix(): Matrix;
  81320. /** @hidden */
  81321. _getWorldMatrixDeterminant(): number;
  81322. /**
  81323. * Perform relative position change from the point of view of behind the front of the mesh.
  81324. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81325. * Supports definition of mesh facing forward or backward
  81326. * @param amountRight defines the distance on the right axis
  81327. * @param amountUp defines the distance on the up axis
  81328. * @param amountForward defines the distance on the forward axis
  81329. * @returns the current mesh
  81330. */
  81331. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  81332. /**
  81333. * Calculate relative position change from the point of view of behind the front of the mesh.
  81334. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81335. * Supports definition of mesh facing forward or backward
  81336. * @param amountRight defines the distance on the right axis
  81337. * @param amountUp defines the distance on the up axis
  81338. * @param amountForward defines the distance on the forward axis
  81339. * @returns the new displacement vector
  81340. */
  81341. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  81342. /**
  81343. * Perform relative rotation change from the point of view of behind the front of the mesh.
  81344. * Supports definition of mesh facing forward or backward
  81345. * @param flipBack defines the flip
  81346. * @param twirlClockwise defines the twirl
  81347. * @param tiltRight defines the tilt
  81348. * @returns the current mesh
  81349. */
  81350. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  81351. /**
  81352. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  81353. * Supports definition of mesh facing forward or backward.
  81354. * @param flipBack defines the flip
  81355. * @param twirlClockwise defines the twirl
  81356. * @param tiltRight defines the tilt
  81357. * @returns the new rotation vector
  81358. */
  81359. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  81360. /**
  81361. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  81362. * @param includeDescendants Include bounding info from descendants as well (true by default)
  81363. * @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
  81364. * @returns the new bounding vectors
  81365. */
  81366. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  81367. min: Vector3;
  81368. max: Vector3;
  81369. };
  81370. /**
  81371. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81372. * This means the mesh underlying bounding box and sphere are recomputed.
  81373. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81374. * @returns the current mesh
  81375. */
  81376. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  81377. /** @hidden */
  81378. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  81379. /** @hidden */
  81380. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  81381. /** @hidden */
  81382. _updateBoundingInfo(): AbstractMesh;
  81383. /** @hidden */
  81384. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  81385. /** @hidden */
  81386. protected _afterComputeWorldMatrix(): void;
  81387. /**
  81388. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81389. * A mesh is in the frustum if its bounding box intersects the frustum
  81390. * @param frustumPlanes defines the frustum to test
  81391. * @returns true if the mesh is in the frustum planes
  81392. */
  81393. isInFrustum(frustumPlanes: Plane[]): boolean;
  81394. /**
  81395. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  81396. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  81397. * @param frustumPlanes defines the frustum to test
  81398. * @returns true if the mesh is completely in the frustum planes
  81399. */
  81400. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81401. /**
  81402. * True if the mesh intersects another mesh or a SolidParticle object
  81403. * @param mesh defines a target mesh or SolidParticle to test
  81404. * @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)
  81405. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  81406. * @returns true if there is an intersection
  81407. */
  81408. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  81409. /**
  81410. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  81411. * @param point defines the point to test
  81412. * @returns true if there is an intersection
  81413. */
  81414. intersectsPoint(point: Vector3): boolean;
  81415. /**
  81416. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  81417. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81418. */
  81419. checkCollisions: boolean;
  81420. /**
  81421. * Gets Collider object used to compute collisions (not physics)
  81422. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81423. */
  81424. readonly collider: Collider;
  81425. /**
  81426. * Move the mesh using collision engine
  81427. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81428. * @param displacement defines the requested displacement vector
  81429. * @returns the current mesh
  81430. */
  81431. moveWithCollisions(displacement: Vector3): AbstractMesh;
  81432. private _onCollisionPositionChange;
  81433. /** @hidden */
  81434. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  81435. /** @hidden */
  81436. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  81437. /** @hidden */
  81438. _checkCollision(collider: Collider): AbstractMesh;
  81439. /** @hidden */
  81440. _generatePointsArray(): boolean;
  81441. /**
  81442. * Checks if the passed Ray intersects with the mesh
  81443. * @param ray defines the ray to use
  81444. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  81445. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81446. * @returns the picking info
  81447. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81448. */
  81449. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  81450. /**
  81451. * Clones the current mesh
  81452. * @param name defines the mesh name
  81453. * @param newParent defines the new mesh parent
  81454. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  81455. * @returns the new mesh
  81456. */
  81457. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  81458. /**
  81459. * Disposes all the submeshes of the current meshnp
  81460. * @returns the current mesh
  81461. */
  81462. releaseSubMeshes(): AbstractMesh;
  81463. /**
  81464. * Releases resources associated with this abstract mesh.
  81465. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81466. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81467. */
  81468. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81469. /**
  81470. * Adds the passed mesh as a child to the current mesh
  81471. * @param mesh defines the child mesh
  81472. * @returns the current mesh
  81473. */
  81474. addChild(mesh: AbstractMesh): AbstractMesh;
  81475. /**
  81476. * Removes the passed mesh from the current mesh children list
  81477. * @param mesh defines the child mesh
  81478. * @returns the current mesh
  81479. */
  81480. removeChild(mesh: AbstractMesh): AbstractMesh;
  81481. /** @hidden */
  81482. private _initFacetData;
  81483. /**
  81484. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  81485. * This method can be called within the render loop.
  81486. * 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
  81487. * @returns the current mesh
  81488. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81489. */
  81490. updateFacetData(): AbstractMesh;
  81491. /**
  81492. * Returns the facetLocalNormals array.
  81493. * The normals are expressed in the mesh local spac
  81494. * @returns an array of Vector3
  81495. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81496. */
  81497. getFacetLocalNormals(): Vector3[];
  81498. /**
  81499. * Returns the facetLocalPositions array.
  81500. * The facet positions are expressed in the mesh local space
  81501. * @returns an array of Vector3
  81502. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81503. */
  81504. getFacetLocalPositions(): Vector3[];
  81505. /**
  81506. * Returns the facetLocalPartioning array
  81507. * @returns an array of array of numbers
  81508. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81509. */
  81510. getFacetLocalPartitioning(): number[][];
  81511. /**
  81512. * Returns the i-th facet position in the world system.
  81513. * This method allocates a new Vector3 per call
  81514. * @param i defines the facet index
  81515. * @returns a new Vector3
  81516. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81517. */
  81518. getFacetPosition(i: number): Vector3;
  81519. /**
  81520. * Sets the reference Vector3 with the i-th facet position in the world system
  81521. * @param i defines the facet index
  81522. * @param ref defines the target vector
  81523. * @returns the current mesh
  81524. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81525. */
  81526. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  81527. /**
  81528. * Returns the i-th facet normal in the world system.
  81529. * This method allocates a new Vector3 per call
  81530. * @param i defines the facet index
  81531. * @returns a new Vector3
  81532. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81533. */
  81534. getFacetNormal(i: number): Vector3;
  81535. /**
  81536. * Sets the reference Vector3 with the i-th facet normal in the world system
  81537. * @param i defines the facet index
  81538. * @param ref defines the target vector
  81539. * @returns the current mesh
  81540. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81541. */
  81542. getFacetNormalToRef(i: number, ref: Vector3): this;
  81543. /**
  81544. * 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)
  81545. * @param x defines x coordinate
  81546. * @param y defines y coordinate
  81547. * @param z defines z coordinate
  81548. * @returns the array of facet indexes
  81549. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81550. */
  81551. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  81552. /**
  81553. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  81554. * @param projected sets as the (x,y,z) world projection on the facet
  81555. * @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
  81556. * @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
  81557. * @param x defines x coordinate
  81558. * @param y defines y coordinate
  81559. * @param z defines z coordinate
  81560. * @returns the face index if found (or null instead)
  81561. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81562. */
  81563. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81564. /**
  81565. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  81566. * @param projected sets as the (x,y,z) local projection on the facet
  81567. * @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
  81568. * @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
  81569. * @param x defines x coordinate
  81570. * @param y defines y coordinate
  81571. * @param z defines z coordinate
  81572. * @returns the face index if found (or null instead)
  81573. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81574. */
  81575. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81576. /**
  81577. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  81578. * @returns the parameters
  81579. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81580. */
  81581. getFacetDataParameters(): any;
  81582. /**
  81583. * Disables the feature FacetData and frees the related memory
  81584. * @returns the current mesh
  81585. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81586. */
  81587. disableFacetData(): AbstractMesh;
  81588. /**
  81589. * Updates the AbstractMesh indices array
  81590. * @param indices defines the data source
  81591. * @returns the current mesh
  81592. */
  81593. updateIndices(indices: IndicesArray): AbstractMesh;
  81594. /**
  81595. * Creates new normals data for the mesh
  81596. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  81597. * @returns the current mesh
  81598. */
  81599. createNormals(updatable: boolean): AbstractMesh;
  81600. /**
  81601. * Align the mesh with a normal
  81602. * @param normal defines the normal to use
  81603. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  81604. * @returns the current mesh
  81605. */
  81606. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  81607. /** @hidden */
  81608. _checkOcclusionQuery(): boolean;
  81609. }
  81610. }
  81611. declare module BABYLON {
  81612. /**
  81613. * Interface used to define ActionEvent
  81614. */
  81615. export interface IActionEvent {
  81616. /** The mesh or sprite that triggered the action */
  81617. source: any;
  81618. /** The X mouse cursor position at the time of the event */
  81619. pointerX: number;
  81620. /** The Y mouse cursor position at the time of the event */
  81621. pointerY: number;
  81622. /** The mesh that is currently pointed at (can be null) */
  81623. meshUnderPointer: Nullable<AbstractMesh>;
  81624. /** the original (browser) event that triggered the ActionEvent */
  81625. sourceEvent?: any;
  81626. /** additional data for the event */
  81627. additionalData?: any;
  81628. }
  81629. /**
  81630. * ActionEvent is the event being sent when an action is triggered.
  81631. */
  81632. export class ActionEvent implements IActionEvent {
  81633. /** The mesh or sprite that triggered the action */
  81634. source: any;
  81635. /** The X mouse cursor position at the time of the event */
  81636. pointerX: number;
  81637. /** The Y mouse cursor position at the time of the event */
  81638. pointerY: number;
  81639. /** The mesh that is currently pointed at (can be null) */
  81640. meshUnderPointer: Nullable<AbstractMesh>;
  81641. /** the original (browser) event that triggered the ActionEvent */
  81642. sourceEvent?: any;
  81643. /** additional data for the event */
  81644. additionalData?: any;
  81645. /**
  81646. * Creates a new ActionEvent
  81647. * @param source The mesh or sprite that triggered the action
  81648. * @param pointerX The X mouse cursor position at the time of the event
  81649. * @param pointerY The Y mouse cursor position at the time of the event
  81650. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  81651. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  81652. * @param additionalData additional data for the event
  81653. */
  81654. constructor(
  81655. /** The mesh or sprite that triggered the action */
  81656. source: any,
  81657. /** The X mouse cursor position at the time of the event */
  81658. pointerX: number,
  81659. /** The Y mouse cursor position at the time of the event */
  81660. pointerY: number,
  81661. /** The mesh that is currently pointed at (can be null) */
  81662. meshUnderPointer: Nullable<AbstractMesh>,
  81663. /** the original (browser) event that triggered the ActionEvent */
  81664. sourceEvent?: any,
  81665. /** additional data for the event */
  81666. additionalData?: any);
  81667. /**
  81668. * Helper function to auto-create an ActionEvent from a source mesh.
  81669. * @param source The source mesh that triggered the event
  81670. * @param evt The original (browser) event
  81671. * @param additionalData additional data for the event
  81672. * @returns the new ActionEvent
  81673. */
  81674. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  81675. /**
  81676. * Helper function to auto-create an ActionEvent from a source sprite
  81677. * @param source The source sprite that triggered the event
  81678. * @param scene Scene associated with the sprite
  81679. * @param evt The original (browser) event
  81680. * @param additionalData additional data for the event
  81681. * @returns the new ActionEvent
  81682. */
  81683. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  81684. /**
  81685. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  81686. * @param scene the scene where the event occurred
  81687. * @param evt The original (browser) event
  81688. * @returns the new ActionEvent
  81689. */
  81690. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  81691. /**
  81692. * Helper function to auto-create an ActionEvent from a primitive
  81693. * @param prim defines the target primitive
  81694. * @param pointerPos defines the pointer position
  81695. * @param evt The original (browser) event
  81696. * @param additionalData additional data for the event
  81697. * @returns the new ActionEvent
  81698. */
  81699. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  81700. }
  81701. }
  81702. declare module BABYLON {
  81703. /**
  81704. * Abstract class used to decouple action Manager from scene and meshes.
  81705. * Do not instantiate.
  81706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81707. */
  81708. export abstract class AbstractActionManager implements IDisposable {
  81709. /** Gets the list of active triggers */
  81710. static Triggers: {
  81711. [key: string]: number;
  81712. };
  81713. /** Gets the cursor to use when hovering items */
  81714. hoverCursor: string;
  81715. /** Gets the list of actions */
  81716. actions: IAction[];
  81717. /**
  81718. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  81719. */
  81720. isRecursive: boolean;
  81721. /**
  81722. * Releases all associated resources
  81723. */
  81724. abstract dispose(): void;
  81725. /**
  81726. * Does this action manager has pointer triggers
  81727. */
  81728. abstract readonly hasPointerTriggers: boolean;
  81729. /**
  81730. * Does this action manager has pick triggers
  81731. */
  81732. abstract readonly hasPickTriggers: boolean;
  81733. /**
  81734. * Process a specific trigger
  81735. * @param trigger defines the trigger to process
  81736. * @param evt defines the event details to be processed
  81737. */
  81738. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  81739. /**
  81740. * Does this action manager handles actions of any of the given triggers
  81741. * @param triggers defines the triggers to be tested
  81742. * @return a boolean indicating whether one (or more) of the triggers is handled
  81743. */
  81744. abstract hasSpecificTriggers(triggers: number[]): boolean;
  81745. /**
  81746. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  81747. * speed.
  81748. * @param triggerA defines the trigger to be tested
  81749. * @param triggerB defines the trigger to be tested
  81750. * @return a boolean indicating whether one (or more) of the triggers is handled
  81751. */
  81752. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  81753. /**
  81754. * Does this action manager handles actions of a given trigger
  81755. * @param trigger defines the trigger to be tested
  81756. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  81757. * @return whether the trigger is handled
  81758. */
  81759. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  81760. /**
  81761. * Serialize this manager to a JSON object
  81762. * @param name defines the property name to store this manager
  81763. * @returns a JSON representation of this manager
  81764. */
  81765. abstract serialize(name: string): any;
  81766. /**
  81767. * Registers an action to this action manager
  81768. * @param action defines the action to be registered
  81769. * @return the action amended (prepared) after registration
  81770. */
  81771. abstract registerAction(action: IAction): Nullable<IAction>;
  81772. /**
  81773. * Unregisters an action to this action manager
  81774. * @param action defines the action to be unregistered
  81775. * @return a boolean indicating whether the action has been unregistered
  81776. */
  81777. abstract unregisterAction(action: IAction): Boolean;
  81778. /**
  81779. * Does exist one action manager with at least one trigger
  81780. **/
  81781. static readonly HasTriggers: boolean;
  81782. /**
  81783. * Does exist one action manager with at least one pick trigger
  81784. **/
  81785. static readonly HasPickTriggers: boolean;
  81786. /**
  81787. * Does exist one action manager that handles actions of a given trigger
  81788. * @param trigger defines the trigger to be tested
  81789. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  81790. **/
  81791. static HasSpecificTrigger(trigger: number): boolean;
  81792. }
  81793. }
  81794. declare module BABYLON {
  81795. /**
  81796. * Defines how a node can be built from a string name.
  81797. */
  81798. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  81799. /**
  81800. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  81801. */
  81802. export class Node implements IBehaviorAware<Node> {
  81803. /** @hidden */
  81804. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  81805. private static _NodeConstructors;
  81806. /**
  81807. * Add a new node constructor
  81808. * @param type defines the type name of the node to construct
  81809. * @param constructorFunc defines the constructor function
  81810. */
  81811. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  81812. /**
  81813. * Returns a node constructor based on type name
  81814. * @param type defines the type name
  81815. * @param name defines the new node name
  81816. * @param scene defines the hosting scene
  81817. * @param options defines optional options to transmit to constructors
  81818. * @returns the new constructor or null
  81819. */
  81820. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  81821. /**
  81822. * Gets or sets the name of the node
  81823. */
  81824. name: string;
  81825. /**
  81826. * Gets or sets the id of the node
  81827. */
  81828. id: string;
  81829. /**
  81830. * Gets or sets the unique id of the node
  81831. */
  81832. uniqueId: number;
  81833. /**
  81834. * Gets or sets a string used to store user defined state for the node
  81835. */
  81836. state: string;
  81837. /**
  81838. * Gets or sets an object used to store user defined information for the node
  81839. */
  81840. metadata: any;
  81841. /**
  81842. * For internal use only. Please do not use.
  81843. */
  81844. reservedDataStore: any;
  81845. /**
  81846. * Gets or sets a boolean used to define if the node must be serialized
  81847. */
  81848. doNotSerialize: boolean;
  81849. /** @hidden */
  81850. _isDisposed: boolean;
  81851. /**
  81852. * Gets a list of Animations associated with the node
  81853. */
  81854. animations: Animation[];
  81855. protected _ranges: {
  81856. [name: string]: Nullable<AnimationRange>;
  81857. };
  81858. /**
  81859. * Callback raised when the node is ready to be used
  81860. */
  81861. onReady: (node: Node) => void;
  81862. private _isEnabled;
  81863. private _isParentEnabled;
  81864. private _isReady;
  81865. /** @hidden */
  81866. _currentRenderId: number;
  81867. private _parentRenderId;
  81868. protected _childRenderId: number;
  81869. /** @hidden */
  81870. _waitingParentId: Nullable<string>;
  81871. /** @hidden */
  81872. _scene: Scene;
  81873. /** @hidden */
  81874. _cache: any;
  81875. private _parentNode;
  81876. private _children;
  81877. /** @hidden */
  81878. _worldMatrix: Matrix;
  81879. /** @hidden */
  81880. _worldMatrixDeterminant: number;
  81881. /** @hidden */
  81882. private _sceneRootNodesIndex;
  81883. /**
  81884. * Gets a boolean indicating if the node has been disposed
  81885. * @returns true if the node was disposed
  81886. */
  81887. isDisposed(): boolean;
  81888. /**
  81889. * Gets or sets the parent of the node
  81890. */
  81891. parent: Nullable<Node>;
  81892. private addToSceneRootNodes;
  81893. private removeFromSceneRootNodes;
  81894. private _animationPropertiesOverride;
  81895. /**
  81896. * Gets or sets the animation properties override
  81897. */
  81898. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81899. /**
  81900. * Gets a string idenfifying the name of the class
  81901. * @returns "Node" string
  81902. */
  81903. getClassName(): string;
  81904. /** @hidden */
  81905. readonly _isNode: boolean;
  81906. /**
  81907. * An event triggered when the mesh is disposed
  81908. */
  81909. onDisposeObservable: Observable<Node>;
  81910. private _onDisposeObserver;
  81911. /**
  81912. * Sets a callback that will be raised when the node will be disposed
  81913. */
  81914. onDispose: () => void;
  81915. /**
  81916. * Creates a new Node
  81917. * @param name the name and id to be given to this node
  81918. * @param scene the scene this node will be added to
  81919. * @param addToRootNodes the node will be added to scene.rootNodes
  81920. */
  81921. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  81922. /**
  81923. * Gets the scene of the node
  81924. * @returns a scene
  81925. */
  81926. getScene(): Scene;
  81927. /**
  81928. * Gets the engine of the node
  81929. * @returns a Engine
  81930. */
  81931. getEngine(): Engine;
  81932. private _behaviors;
  81933. /**
  81934. * Attach a behavior to the node
  81935. * @see http://doc.babylonjs.com/features/behaviour
  81936. * @param behavior defines the behavior to attach
  81937. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  81938. * @returns the current Node
  81939. */
  81940. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  81941. /**
  81942. * Remove an attached behavior
  81943. * @see http://doc.babylonjs.com/features/behaviour
  81944. * @param behavior defines the behavior to attach
  81945. * @returns the current Node
  81946. */
  81947. removeBehavior(behavior: Behavior<Node>): Node;
  81948. /**
  81949. * Gets the list of attached behaviors
  81950. * @see http://doc.babylonjs.com/features/behaviour
  81951. */
  81952. readonly behaviors: Behavior<Node>[];
  81953. /**
  81954. * Gets an attached behavior by name
  81955. * @param name defines the name of the behavior to look for
  81956. * @see http://doc.babylonjs.com/features/behaviour
  81957. * @returns null if behavior was not found else the requested behavior
  81958. */
  81959. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  81960. /**
  81961. * Returns the latest update of the World matrix
  81962. * @returns a Matrix
  81963. */
  81964. getWorldMatrix(): Matrix;
  81965. /** @hidden */
  81966. _getWorldMatrixDeterminant(): number;
  81967. /**
  81968. * Returns directly the latest state of the mesh World matrix.
  81969. * A Matrix is returned.
  81970. */
  81971. readonly worldMatrixFromCache: Matrix;
  81972. /** @hidden */
  81973. _initCache(): void;
  81974. /** @hidden */
  81975. updateCache(force?: boolean): void;
  81976. /** @hidden */
  81977. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  81978. /** @hidden */
  81979. _updateCache(ignoreParentClass?: boolean): void;
  81980. /** @hidden */
  81981. _isSynchronized(): boolean;
  81982. /** @hidden */
  81983. _markSyncedWithParent(): void;
  81984. /** @hidden */
  81985. isSynchronizedWithParent(): boolean;
  81986. /** @hidden */
  81987. isSynchronized(): boolean;
  81988. /**
  81989. * Is this node ready to be used/rendered
  81990. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81991. * @return true if the node is ready
  81992. */
  81993. isReady(completeCheck?: boolean): boolean;
  81994. /**
  81995. * Is this node enabled?
  81996. * 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
  81997. * @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
  81998. * @return whether this node (and its parent) is enabled
  81999. */
  82000. isEnabled(checkAncestors?: boolean): boolean;
  82001. /** @hidden */
  82002. protected _syncParentEnabledState(): void;
  82003. /**
  82004. * Set the enabled state of this node
  82005. * @param value defines the new enabled state
  82006. */
  82007. setEnabled(value: boolean): void;
  82008. /**
  82009. * Is this node a descendant of the given node?
  82010. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  82011. * @param ancestor defines the parent node to inspect
  82012. * @returns a boolean indicating if this node is a descendant of the given node
  82013. */
  82014. isDescendantOf(ancestor: Node): boolean;
  82015. /** @hidden */
  82016. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  82017. /**
  82018. * Will return all nodes that have this node as ascendant
  82019. * @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
  82020. * @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
  82021. * @return all children nodes of all types
  82022. */
  82023. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  82024. /**
  82025. * Get all child-meshes of this node
  82026. * @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)
  82027. * @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
  82028. * @returns an array of AbstractMesh
  82029. */
  82030. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  82031. /**
  82032. * Get all direct children of this node
  82033. * @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
  82034. * @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)
  82035. * @returns an array of Node
  82036. */
  82037. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  82038. /** @hidden */
  82039. _setReady(state: boolean): void;
  82040. /**
  82041. * Get an animation by name
  82042. * @param name defines the name of the animation to look for
  82043. * @returns null if not found else the requested animation
  82044. */
  82045. getAnimationByName(name: string): Nullable<Animation>;
  82046. /**
  82047. * Creates an animation range for this node
  82048. * @param name defines the name of the range
  82049. * @param from defines the starting key
  82050. * @param to defines the end key
  82051. */
  82052. createAnimationRange(name: string, from: number, to: number): void;
  82053. /**
  82054. * Delete a specific animation range
  82055. * @param name defines the name of the range to delete
  82056. * @param deleteFrames defines if animation frames from the range must be deleted as well
  82057. */
  82058. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  82059. /**
  82060. * Get an animation range by name
  82061. * @param name defines the name of the animation range to look for
  82062. * @returns null if not found else the requested animation range
  82063. */
  82064. getAnimationRange(name: string): Nullable<AnimationRange>;
  82065. /**
  82066. * Gets the list of all animation ranges defined on this node
  82067. * @returns an array
  82068. */
  82069. getAnimationRanges(): Nullable<AnimationRange>[];
  82070. /**
  82071. * Will start the animation sequence
  82072. * @param name defines the range frames for animation sequence
  82073. * @param loop defines if the animation should loop (false by default)
  82074. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  82075. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  82076. * @returns the object created for this animation. If range does not exist, it will return null
  82077. */
  82078. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  82079. /**
  82080. * Serialize animation ranges into a JSON compatible object
  82081. * @returns serialization object
  82082. */
  82083. serializeAnimationRanges(): any;
  82084. /**
  82085. * Computes the world matrix of the node
  82086. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82087. * @returns the world matrix
  82088. */
  82089. computeWorldMatrix(force?: boolean): Matrix;
  82090. /**
  82091. * Releases resources associated with this node.
  82092. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82093. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82094. */
  82095. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82096. /**
  82097. * Parse animation range data from a serialization object and store them into a given node
  82098. * @param node defines where to store the animation ranges
  82099. * @param parsedNode defines the serialization object to read data from
  82100. * @param scene defines the hosting scene
  82101. */
  82102. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  82103. }
  82104. }
  82105. declare module BABYLON {
  82106. /**
  82107. * Class used to store any kind of animation
  82108. */
  82109. export class Animation {
  82110. /**Name of the animation */
  82111. name: string;
  82112. /**Property to animate */
  82113. targetProperty: string;
  82114. /**The frames per second of the animation */
  82115. framePerSecond: number;
  82116. /**The data type of the animation */
  82117. dataType: number;
  82118. /**The loop mode of the animation */
  82119. loopMode?: number | undefined;
  82120. /**Specifies if blending should be enabled */
  82121. enableBlending?: boolean | undefined;
  82122. /**
  82123. * Use matrix interpolation instead of using direct key value when animating matrices
  82124. */
  82125. static AllowMatricesInterpolation: boolean;
  82126. /**
  82127. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  82128. */
  82129. static AllowMatrixDecomposeForInterpolation: boolean;
  82130. /**
  82131. * Stores the key frames of the animation
  82132. */
  82133. private _keys;
  82134. /**
  82135. * Stores the easing function of the animation
  82136. */
  82137. private _easingFunction;
  82138. /**
  82139. * @hidden Internal use only
  82140. */
  82141. _runtimeAnimations: RuntimeAnimation[];
  82142. /**
  82143. * The set of event that will be linked to this animation
  82144. */
  82145. private _events;
  82146. /**
  82147. * Stores an array of target property paths
  82148. */
  82149. targetPropertyPath: string[];
  82150. /**
  82151. * Stores the blending speed of the animation
  82152. */
  82153. blendingSpeed: number;
  82154. /**
  82155. * Stores the animation ranges for the animation
  82156. */
  82157. private _ranges;
  82158. /**
  82159. * @hidden Internal use
  82160. */
  82161. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  82162. /**
  82163. * Sets up an animation
  82164. * @param property The property to animate
  82165. * @param animationType The animation type to apply
  82166. * @param framePerSecond The frames per second of the animation
  82167. * @param easingFunction The easing function used in the animation
  82168. * @returns The created animation
  82169. */
  82170. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  82171. /**
  82172. * Create and start an animation on a node
  82173. * @param name defines the name of the global animation that will be run on all nodes
  82174. * @param node defines the root node where the animation will take place
  82175. * @param targetProperty defines property to animate
  82176. * @param framePerSecond defines the number of frame per second yo use
  82177. * @param totalFrame defines the number of frames in total
  82178. * @param from defines the initial value
  82179. * @param to defines the final value
  82180. * @param loopMode defines which loop mode you want to use (off by default)
  82181. * @param easingFunction defines the easing function to use (linear by default)
  82182. * @param onAnimationEnd defines the callback to call when animation end
  82183. * @returns the animatable created for this animation
  82184. */
  82185. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  82186. /**
  82187. * Create and start an animation on a node and its descendants
  82188. * @param name defines the name of the global animation that will be run on all nodes
  82189. * @param node defines the root node where the animation will take place
  82190. * @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
  82191. * @param targetProperty defines property to animate
  82192. * @param framePerSecond defines the number of frame per second to use
  82193. * @param totalFrame defines the number of frames in total
  82194. * @param from defines the initial value
  82195. * @param to defines the final value
  82196. * @param loopMode defines which loop mode you want to use (off by default)
  82197. * @param easingFunction defines the easing function to use (linear by default)
  82198. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82199. * @returns the list of animatables created for all nodes
  82200. * @example https://www.babylonjs-playground.com/#MH0VLI
  82201. */
  82202. 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[]>;
  82203. /**
  82204. * Creates a new animation, merges it with the existing animations and starts it
  82205. * @param name Name of the animation
  82206. * @param node Node which contains the scene that begins the animations
  82207. * @param targetProperty Specifies which property to animate
  82208. * @param framePerSecond The frames per second of the animation
  82209. * @param totalFrame The total number of frames
  82210. * @param from The frame at the beginning of the animation
  82211. * @param to The frame at the end of the animation
  82212. * @param loopMode Specifies the loop mode of the animation
  82213. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  82214. * @param onAnimationEnd Callback to run once the animation is complete
  82215. * @returns Nullable animation
  82216. */
  82217. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  82218. /**
  82219. * Transition property of an host to the target Value
  82220. * @param property The property to transition
  82221. * @param targetValue The target Value of the property
  82222. * @param host The object where the property to animate belongs
  82223. * @param scene Scene used to run the animation
  82224. * @param frameRate Framerate (in frame/s) to use
  82225. * @param transition The transition type we want to use
  82226. * @param duration The duration of the animation, in milliseconds
  82227. * @param onAnimationEnd Callback trigger at the end of the animation
  82228. * @returns Nullable animation
  82229. */
  82230. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  82231. /**
  82232. * Return the array of runtime animations currently using this animation
  82233. */
  82234. readonly runtimeAnimations: RuntimeAnimation[];
  82235. /**
  82236. * Specifies if any of the runtime animations are currently running
  82237. */
  82238. readonly hasRunningRuntimeAnimations: boolean;
  82239. /**
  82240. * Initializes the animation
  82241. * @param name Name of the animation
  82242. * @param targetProperty Property to animate
  82243. * @param framePerSecond The frames per second of the animation
  82244. * @param dataType The data type of the animation
  82245. * @param loopMode The loop mode of the animation
  82246. * @param enableBlending Specifies if blending should be enabled
  82247. */
  82248. constructor(
  82249. /**Name of the animation */
  82250. name: string,
  82251. /**Property to animate */
  82252. targetProperty: string,
  82253. /**The frames per second of the animation */
  82254. framePerSecond: number,
  82255. /**The data type of the animation */
  82256. dataType: number,
  82257. /**The loop mode of the animation */
  82258. loopMode?: number | undefined,
  82259. /**Specifies if blending should be enabled */
  82260. enableBlending?: boolean | undefined);
  82261. /**
  82262. * Converts the animation to a string
  82263. * @param fullDetails support for multiple levels of logging within scene loading
  82264. * @returns String form of the animation
  82265. */
  82266. toString(fullDetails?: boolean): string;
  82267. /**
  82268. * Add an event to this animation
  82269. * @param event Event to add
  82270. */
  82271. addEvent(event: AnimationEvent): void;
  82272. /**
  82273. * Remove all events found at the given frame
  82274. * @param frame The frame to remove events from
  82275. */
  82276. removeEvents(frame: number): void;
  82277. /**
  82278. * Retrieves all the events from the animation
  82279. * @returns Events from the animation
  82280. */
  82281. getEvents(): AnimationEvent[];
  82282. /**
  82283. * Creates an animation range
  82284. * @param name Name of the animation range
  82285. * @param from Starting frame of the animation range
  82286. * @param to Ending frame of the animation
  82287. */
  82288. createRange(name: string, from: number, to: number): void;
  82289. /**
  82290. * Deletes an animation range by name
  82291. * @param name Name of the animation range to delete
  82292. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  82293. */
  82294. deleteRange(name: string, deleteFrames?: boolean): void;
  82295. /**
  82296. * Gets the animation range by name, or null if not defined
  82297. * @param name Name of the animation range
  82298. * @returns Nullable animation range
  82299. */
  82300. getRange(name: string): Nullable<AnimationRange>;
  82301. /**
  82302. * Gets the key frames from the animation
  82303. * @returns The key frames of the animation
  82304. */
  82305. getKeys(): Array<IAnimationKey>;
  82306. /**
  82307. * Gets the highest frame rate of the animation
  82308. * @returns Highest frame rate of the animation
  82309. */
  82310. getHighestFrame(): number;
  82311. /**
  82312. * Gets the easing function of the animation
  82313. * @returns Easing function of the animation
  82314. */
  82315. getEasingFunction(): IEasingFunction;
  82316. /**
  82317. * Sets the easing function of the animation
  82318. * @param easingFunction A custom mathematical formula for animation
  82319. */
  82320. setEasingFunction(easingFunction: EasingFunction): void;
  82321. /**
  82322. * Interpolates a scalar linearly
  82323. * @param startValue Start value of the animation curve
  82324. * @param endValue End value of the animation curve
  82325. * @param gradient Scalar amount to interpolate
  82326. * @returns Interpolated scalar value
  82327. */
  82328. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  82329. /**
  82330. * Interpolates a scalar cubically
  82331. * @param startValue Start value of the animation curve
  82332. * @param outTangent End tangent of the animation
  82333. * @param endValue End value of the animation curve
  82334. * @param inTangent Start tangent of the animation curve
  82335. * @param gradient Scalar amount to interpolate
  82336. * @returns Interpolated scalar value
  82337. */
  82338. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  82339. /**
  82340. * Interpolates a quaternion using a spherical linear interpolation
  82341. * @param startValue Start value of the animation curve
  82342. * @param endValue End value of the animation curve
  82343. * @param gradient Scalar amount to interpolate
  82344. * @returns Interpolated quaternion value
  82345. */
  82346. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  82347. /**
  82348. * Interpolates a quaternion cubically
  82349. * @param startValue Start value of the animation curve
  82350. * @param outTangent End tangent of the animation curve
  82351. * @param endValue End value of the animation curve
  82352. * @param inTangent Start tangent of the animation curve
  82353. * @param gradient Scalar amount to interpolate
  82354. * @returns Interpolated quaternion value
  82355. */
  82356. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  82357. /**
  82358. * Interpolates a Vector3 linearl
  82359. * @param startValue Start value of the animation curve
  82360. * @param endValue End value of the animation curve
  82361. * @param gradient Scalar amount to interpolate
  82362. * @returns Interpolated scalar value
  82363. */
  82364. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  82365. /**
  82366. * Interpolates a Vector3 cubically
  82367. * @param startValue Start value of the animation curve
  82368. * @param outTangent End tangent of the animation
  82369. * @param endValue End value of the animation curve
  82370. * @param inTangent Start tangent of the animation curve
  82371. * @param gradient Scalar amount to interpolate
  82372. * @returns InterpolatedVector3 value
  82373. */
  82374. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  82375. /**
  82376. * Interpolates a Vector2 linearly
  82377. * @param startValue Start value of the animation curve
  82378. * @param endValue End value of the animation curve
  82379. * @param gradient Scalar amount to interpolate
  82380. * @returns Interpolated Vector2 value
  82381. */
  82382. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  82383. /**
  82384. * Interpolates a Vector2 cubically
  82385. * @param startValue Start value of the animation curve
  82386. * @param outTangent End tangent of the animation
  82387. * @param endValue End value of the animation curve
  82388. * @param inTangent Start tangent of the animation curve
  82389. * @param gradient Scalar amount to interpolate
  82390. * @returns Interpolated Vector2 value
  82391. */
  82392. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  82393. /**
  82394. * Interpolates a size linearly
  82395. * @param startValue Start value of the animation curve
  82396. * @param endValue End value of the animation curve
  82397. * @param gradient Scalar amount to interpolate
  82398. * @returns Interpolated Size value
  82399. */
  82400. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  82401. /**
  82402. * Interpolates a Color3 linearly
  82403. * @param startValue Start value of the animation curve
  82404. * @param endValue End value of the animation curve
  82405. * @param gradient Scalar amount to interpolate
  82406. * @returns Interpolated Color3 value
  82407. */
  82408. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  82409. /**
  82410. * @hidden Internal use only
  82411. */
  82412. _getKeyValue(value: any): any;
  82413. /**
  82414. * @hidden Internal use only
  82415. */
  82416. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  82417. /**
  82418. * Defines the function to use to interpolate matrices
  82419. * @param startValue defines the start matrix
  82420. * @param endValue defines the end matrix
  82421. * @param gradient defines the gradient between both matrices
  82422. * @param result defines an optional target matrix where to store the interpolation
  82423. * @returns the interpolated matrix
  82424. */
  82425. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  82426. /**
  82427. * Makes a copy of the animation
  82428. * @returns Cloned animation
  82429. */
  82430. clone(): Animation;
  82431. /**
  82432. * Sets the key frames of the animation
  82433. * @param values The animation key frames to set
  82434. */
  82435. setKeys(values: Array<IAnimationKey>): void;
  82436. /**
  82437. * Serializes the animation to an object
  82438. * @returns Serialized object
  82439. */
  82440. serialize(): any;
  82441. /**
  82442. * Float animation type
  82443. */
  82444. private static _ANIMATIONTYPE_FLOAT;
  82445. /**
  82446. * Vector3 animation type
  82447. */
  82448. private static _ANIMATIONTYPE_VECTOR3;
  82449. /**
  82450. * Quaternion animation type
  82451. */
  82452. private static _ANIMATIONTYPE_QUATERNION;
  82453. /**
  82454. * Matrix animation type
  82455. */
  82456. private static _ANIMATIONTYPE_MATRIX;
  82457. /**
  82458. * Color3 animation type
  82459. */
  82460. private static _ANIMATIONTYPE_COLOR3;
  82461. /**
  82462. * Vector2 animation type
  82463. */
  82464. private static _ANIMATIONTYPE_VECTOR2;
  82465. /**
  82466. * Size animation type
  82467. */
  82468. private static _ANIMATIONTYPE_SIZE;
  82469. /**
  82470. * Relative Loop Mode
  82471. */
  82472. private static _ANIMATIONLOOPMODE_RELATIVE;
  82473. /**
  82474. * Cycle Loop Mode
  82475. */
  82476. private static _ANIMATIONLOOPMODE_CYCLE;
  82477. /**
  82478. * Constant Loop Mode
  82479. */
  82480. private static _ANIMATIONLOOPMODE_CONSTANT;
  82481. /**
  82482. * Get the float animation type
  82483. */
  82484. static readonly ANIMATIONTYPE_FLOAT: number;
  82485. /**
  82486. * Get the Vector3 animation type
  82487. */
  82488. static readonly ANIMATIONTYPE_VECTOR3: number;
  82489. /**
  82490. * Get the Vector2 animation type
  82491. */
  82492. static readonly ANIMATIONTYPE_VECTOR2: number;
  82493. /**
  82494. * Get the Size animation type
  82495. */
  82496. static readonly ANIMATIONTYPE_SIZE: number;
  82497. /**
  82498. * Get the Quaternion animation type
  82499. */
  82500. static readonly ANIMATIONTYPE_QUATERNION: number;
  82501. /**
  82502. * Get the Matrix animation type
  82503. */
  82504. static readonly ANIMATIONTYPE_MATRIX: number;
  82505. /**
  82506. * Get the Color3 animation type
  82507. */
  82508. static readonly ANIMATIONTYPE_COLOR3: number;
  82509. /**
  82510. * Get the Relative Loop Mode
  82511. */
  82512. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  82513. /**
  82514. * Get the Cycle Loop Mode
  82515. */
  82516. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  82517. /**
  82518. * Get the Constant Loop Mode
  82519. */
  82520. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  82521. /** @hidden */
  82522. static _UniversalLerp(left: any, right: any, amount: number): any;
  82523. /**
  82524. * Parses an animation object and creates an animation
  82525. * @param parsedAnimation Parsed animation object
  82526. * @returns Animation object
  82527. */
  82528. static Parse(parsedAnimation: any): Animation;
  82529. /**
  82530. * Appends the serialized animations from the source animations
  82531. * @param source Source containing the animations
  82532. * @param destination Target to store the animations
  82533. */
  82534. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  82535. }
  82536. }
  82537. declare module BABYLON {
  82538. /**
  82539. * Base class of all the textures in babylon.
  82540. * It groups all the common properties the materials, post process, lights... might need
  82541. * in order to make a correct use of the texture.
  82542. */
  82543. export class BaseTexture implements IAnimatable {
  82544. /**
  82545. * Default anisotropic filtering level for the application.
  82546. * It is set to 4 as a good tradeoff between perf and quality.
  82547. */
  82548. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  82549. /**
  82550. * Gets or sets the unique id of the texture
  82551. */
  82552. uniqueId: number;
  82553. /**
  82554. * Define the name of the texture.
  82555. */
  82556. name: string;
  82557. /**
  82558. * Gets or sets an object used to store user defined information.
  82559. */
  82560. metadata: any;
  82561. /**
  82562. * For internal use only. Please do not use.
  82563. */
  82564. reservedDataStore: any;
  82565. private _hasAlpha;
  82566. /**
  82567. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  82568. */
  82569. hasAlpha: boolean;
  82570. /**
  82571. * Defines if the alpha value should be determined via the rgb values.
  82572. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  82573. */
  82574. getAlphaFromRGB: boolean;
  82575. /**
  82576. * Intensity or strength of the texture.
  82577. * It is commonly used by materials to fine tune the intensity of the texture
  82578. */
  82579. level: number;
  82580. /**
  82581. * Define the UV chanel to use starting from 0 and defaulting to 0.
  82582. * This is part of the texture as textures usually maps to one uv set.
  82583. */
  82584. coordinatesIndex: number;
  82585. private _coordinatesMode;
  82586. /**
  82587. * How a texture is mapped.
  82588. *
  82589. * | Value | Type | Description |
  82590. * | ----- | ----------------------------------- | ----------- |
  82591. * | 0 | EXPLICIT_MODE | |
  82592. * | 1 | SPHERICAL_MODE | |
  82593. * | 2 | PLANAR_MODE | |
  82594. * | 3 | CUBIC_MODE | |
  82595. * | 4 | PROJECTION_MODE | |
  82596. * | 5 | SKYBOX_MODE | |
  82597. * | 6 | INVCUBIC_MODE | |
  82598. * | 7 | EQUIRECTANGULAR_MODE | |
  82599. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  82600. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  82601. */
  82602. coordinatesMode: number;
  82603. /**
  82604. * | Value | Type | Description |
  82605. * | ----- | ------------------ | ----------- |
  82606. * | 0 | CLAMP_ADDRESSMODE | |
  82607. * | 1 | WRAP_ADDRESSMODE | |
  82608. * | 2 | MIRROR_ADDRESSMODE | |
  82609. */
  82610. wrapU: number;
  82611. /**
  82612. * | Value | Type | Description |
  82613. * | ----- | ------------------ | ----------- |
  82614. * | 0 | CLAMP_ADDRESSMODE | |
  82615. * | 1 | WRAP_ADDRESSMODE | |
  82616. * | 2 | MIRROR_ADDRESSMODE | |
  82617. */
  82618. wrapV: number;
  82619. /**
  82620. * | Value | Type | Description |
  82621. * | ----- | ------------------ | ----------- |
  82622. * | 0 | CLAMP_ADDRESSMODE | |
  82623. * | 1 | WRAP_ADDRESSMODE | |
  82624. * | 2 | MIRROR_ADDRESSMODE | |
  82625. */
  82626. wrapR: number;
  82627. /**
  82628. * With compliant hardware and browser (supporting anisotropic filtering)
  82629. * this defines the level of anisotropic filtering in the texture.
  82630. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  82631. */
  82632. anisotropicFilteringLevel: number;
  82633. /**
  82634. * Define if the texture is a cube texture or if false a 2d texture.
  82635. */
  82636. isCube: boolean;
  82637. /**
  82638. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  82639. */
  82640. is3D: boolean;
  82641. /**
  82642. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  82643. * HDR texture are usually stored in linear space.
  82644. * This only impacts the PBR and Background materials
  82645. */
  82646. gammaSpace: boolean;
  82647. /**
  82648. * Gets whether or not the texture contains RGBD data.
  82649. */
  82650. readonly isRGBD: boolean;
  82651. /**
  82652. * Is Z inverted in the texture (useful in a cube texture).
  82653. */
  82654. invertZ: boolean;
  82655. /**
  82656. * Are mip maps generated for this texture or not.
  82657. */
  82658. readonly noMipmap: boolean;
  82659. /**
  82660. * @hidden
  82661. */
  82662. lodLevelInAlpha: boolean;
  82663. /**
  82664. * With prefiltered texture, defined the offset used during the prefiltering steps.
  82665. */
  82666. lodGenerationOffset: number;
  82667. /**
  82668. * With prefiltered texture, defined the scale used during the prefiltering steps.
  82669. */
  82670. lodGenerationScale: number;
  82671. /**
  82672. * Define if the texture is a render target.
  82673. */
  82674. isRenderTarget: boolean;
  82675. /**
  82676. * Define the unique id of the texture in the scene.
  82677. */
  82678. readonly uid: string;
  82679. /**
  82680. * Return a string representation of the texture.
  82681. * @returns the texture as a string
  82682. */
  82683. toString(): string;
  82684. /**
  82685. * Get the class name of the texture.
  82686. * @returns "BaseTexture"
  82687. */
  82688. getClassName(): string;
  82689. /**
  82690. * Define the list of animation attached to the texture.
  82691. */
  82692. animations: Animation[];
  82693. /**
  82694. * An event triggered when the texture is disposed.
  82695. */
  82696. onDisposeObservable: Observable<BaseTexture>;
  82697. private _onDisposeObserver;
  82698. /**
  82699. * Callback triggered when the texture has been disposed.
  82700. * Kept for back compatibility, you can use the onDisposeObservable instead.
  82701. */
  82702. onDispose: () => void;
  82703. /**
  82704. * Define the current state of the loading sequence when in delayed load mode.
  82705. */
  82706. delayLoadState: number;
  82707. private _scene;
  82708. /** @hidden */
  82709. _texture: Nullable<InternalTexture>;
  82710. private _uid;
  82711. /**
  82712. * Define if the texture is preventinga material to render or not.
  82713. * If not and the texture is not ready, the engine will use a default black texture instead.
  82714. */
  82715. readonly isBlocking: boolean;
  82716. /**
  82717. * Instantiates a new BaseTexture.
  82718. * Base class of all the textures in babylon.
  82719. * It groups all the common properties the materials, post process, lights... might need
  82720. * in order to make a correct use of the texture.
  82721. * @param scene Define the scene the texture blongs to
  82722. */
  82723. constructor(scene: Nullable<Scene>);
  82724. /**
  82725. * Get the scene the texture belongs to.
  82726. * @returns the scene or null if undefined
  82727. */
  82728. getScene(): Nullable<Scene>;
  82729. /**
  82730. * Get the texture transform matrix used to offset tile the texture for istance.
  82731. * @returns the transformation matrix
  82732. */
  82733. getTextureMatrix(): Matrix;
  82734. /**
  82735. * Get the texture reflection matrix used to rotate/transform the reflection.
  82736. * @returns the reflection matrix
  82737. */
  82738. getReflectionTextureMatrix(): Matrix;
  82739. /**
  82740. * Get the underlying lower level texture from Babylon.
  82741. * @returns the insternal texture
  82742. */
  82743. getInternalTexture(): Nullable<InternalTexture>;
  82744. /**
  82745. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  82746. * @returns true if ready or not blocking
  82747. */
  82748. isReadyOrNotBlocking(): boolean;
  82749. /**
  82750. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  82751. * @returns true if fully ready
  82752. */
  82753. isReady(): boolean;
  82754. private _cachedSize;
  82755. /**
  82756. * Get the size of the texture.
  82757. * @returns the texture size.
  82758. */
  82759. getSize(): ISize;
  82760. /**
  82761. * Get the base size of the texture.
  82762. * It can be different from the size if the texture has been resized for POT for instance
  82763. * @returns the base size
  82764. */
  82765. getBaseSize(): ISize;
  82766. /**
  82767. * Update the sampling mode of the texture.
  82768. * Default is Trilinear mode.
  82769. *
  82770. * | Value | Type | Description |
  82771. * | ----- | ------------------ | ----------- |
  82772. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  82773. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  82774. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  82775. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  82776. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  82777. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  82778. * | 7 | NEAREST_LINEAR | |
  82779. * | 8 | NEAREST_NEAREST | |
  82780. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  82781. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  82782. * | 11 | LINEAR_LINEAR | |
  82783. * | 12 | LINEAR_NEAREST | |
  82784. *
  82785. * > _mag_: magnification filter (close to the viewer)
  82786. * > _min_: minification filter (far from the viewer)
  82787. * > _mip_: filter used between mip map levels
  82788. *@param samplingMode Define the new sampling mode of the texture
  82789. */
  82790. updateSamplingMode(samplingMode: number): void;
  82791. /**
  82792. * Scales the texture if is `canRescale()`
  82793. * @param ratio the resize factor we want to use to rescale
  82794. */
  82795. scale(ratio: number): void;
  82796. /**
  82797. * Get if the texture can rescale.
  82798. */
  82799. readonly canRescale: boolean;
  82800. /** @hidden */
  82801. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  82802. /** @hidden */
  82803. _rebuild(): void;
  82804. /**
  82805. * Triggers the load sequence in delayed load mode.
  82806. */
  82807. delayLoad(): void;
  82808. /**
  82809. * Clones the texture.
  82810. * @returns the cloned texture
  82811. */
  82812. clone(): Nullable<BaseTexture>;
  82813. /**
  82814. * Get the texture underlying type (INT, FLOAT...)
  82815. */
  82816. readonly textureType: number;
  82817. /**
  82818. * Get the texture underlying format (RGB, RGBA...)
  82819. */
  82820. readonly textureFormat: number;
  82821. /**
  82822. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  82823. * This will returns an RGBA array buffer containing either in values (0-255) or
  82824. * float values (0-1) depending of the underlying buffer type.
  82825. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  82826. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  82827. * @param buffer defines a user defined buffer to fill with data (can be null)
  82828. * @returns The Array buffer containing the pixels data.
  82829. */
  82830. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  82831. /**
  82832. * Release and destroy the underlying lower level texture aka internalTexture.
  82833. */
  82834. releaseInternalTexture(): void;
  82835. /**
  82836. * Get the polynomial representation of the texture data.
  82837. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  82838. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  82839. */
  82840. sphericalPolynomial: Nullable<SphericalPolynomial>;
  82841. /** @hidden */
  82842. readonly _lodTextureHigh: Nullable<BaseTexture>;
  82843. /** @hidden */
  82844. readonly _lodTextureMid: Nullable<BaseTexture>;
  82845. /** @hidden */
  82846. readonly _lodTextureLow: Nullable<BaseTexture>;
  82847. /**
  82848. * Dispose the texture and release its associated resources.
  82849. */
  82850. dispose(): void;
  82851. /**
  82852. * Serialize the texture into a JSON representation that can be parsed later on.
  82853. * @returns the JSON representation of the texture
  82854. */
  82855. serialize(): any;
  82856. /**
  82857. * Helper function to be called back once a list of texture contains only ready textures.
  82858. * @param textures Define the list of textures to wait for
  82859. * @param callback Define the callback triggered once the entire list will be ready
  82860. */
  82861. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  82862. }
  82863. }
  82864. declare module BABYLON {
  82865. /**
  82866. * Uniform buffer objects.
  82867. *
  82868. * Handles blocks of uniform on the GPU.
  82869. *
  82870. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82871. *
  82872. * For more information, please refer to :
  82873. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82874. */
  82875. export class UniformBuffer {
  82876. private _engine;
  82877. private _buffer;
  82878. private _data;
  82879. private _bufferData;
  82880. private _dynamic?;
  82881. private _uniformLocations;
  82882. private _uniformSizes;
  82883. private _uniformLocationPointer;
  82884. private _needSync;
  82885. private _noUBO;
  82886. private _currentEffect;
  82887. private static _MAX_UNIFORM_SIZE;
  82888. private static _tempBuffer;
  82889. /**
  82890. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  82891. * This is dynamic to allow compat with webgl 1 and 2.
  82892. * You will need to pass the name of the uniform as well as the value.
  82893. */
  82894. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  82895. /**
  82896. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  82897. * This is dynamic to allow compat with webgl 1 and 2.
  82898. * You will need to pass the name of the uniform as well as the value.
  82899. */
  82900. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  82901. /**
  82902. * Lambda to Update a single float in a uniform buffer.
  82903. * This is dynamic to allow compat with webgl 1 and 2.
  82904. * You will need to pass the name of the uniform as well as the value.
  82905. */
  82906. updateFloat: (name: string, x: number) => void;
  82907. /**
  82908. * Lambda to Update a vec2 of float in a uniform buffer.
  82909. * This is dynamic to allow compat with webgl 1 and 2.
  82910. * You will need to pass the name of the uniform as well as the value.
  82911. */
  82912. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  82913. /**
  82914. * Lambda to Update a vec3 of float in a uniform buffer.
  82915. * This is dynamic to allow compat with webgl 1 and 2.
  82916. * You will need to pass the name of the uniform as well as the value.
  82917. */
  82918. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  82919. /**
  82920. * Lambda to Update a vec4 of float in a uniform buffer.
  82921. * This is dynamic to allow compat with webgl 1 and 2.
  82922. * You will need to pass the name of the uniform as well as the value.
  82923. */
  82924. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  82925. /**
  82926. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  82927. * This is dynamic to allow compat with webgl 1 and 2.
  82928. * You will need to pass the name of the uniform as well as the value.
  82929. */
  82930. updateMatrix: (name: string, mat: Matrix) => void;
  82931. /**
  82932. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  82933. * This is dynamic to allow compat with webgl 1 and 2.
  82934. * You will need to pass the name of the uniform as well as the value.
  82935. */
  82936. updateVector3: (name: string, vector: Vector3) => void;
  82937. /**
  82938. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  82939. * This is dynamic to allow compat with webgl 1 and 2.
  82940. * You will need to pass the name of the uniform as well as the value.
  82941. */
  82942. updateVector4: (name: string, vector: Vector4) => void;
  82943. /**
  82944. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  82945. * This is dynamic to allow compat with webgl 1 and 2.
  82946. * You will need to pass the name of the uniform as well as the value.
  82947. */
  82948. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  82949. /**
  82950. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  82951. * This is dynamic to allow compat with webgl 1 and 2.
  82952. * You will need to pass the name of the uniform as well as the value.
  82953. */
  82954. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  82955. /**
  82956. * Instantiates a new Uniform buffer objects.
  82957. *
  82958. * Handles blocks of uniform on the GPU.
  82959. *
  82960. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82961. *
  82962. * For more information, please refer to :
  82963. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82964. * @param engine Define the engine the buffer is associated with
  82965. * @param data Define the data contained in the buffer
  82966. * @param dynamic Define if the buffer is updatable
  82967. */
  82968. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  82969. /**
  82970. * Indicates if the buffer is using the WebGL2 UBO implementation,
  82971. * or just falling back on setUniformXXX calls.
  82972. */
  82973. readonly useUbo: boolean;
  82974. /**
  82975. * Indicates if the WebGL underlying uniform buffer is in sync
  82976. * with the javascript cache data.
  82977. */
  82978. readonly isSync: boolean;
  82979. /**
  82980. * Indicates if the WebGL underlying uniform buffer is dynamic.
  82981. * Also, a dynamic UniformBuffer will disable cache verification and always
  82982. * update the underlying WebGL uniform buffer to the GPU.
  82983. * @returns if Dynamic, otherwise false
  82984. */
  82985. isDynamic(): boolean;
  82986. /**
  82987. * The data cache on JS side.
  82988. * @returns the underlying data as a float array
  82989. */
  82990. getData(): Float32Array;
  82991. /**
  82992. * The underlying WebGL Uniform buffer.
  82993. * @returns the webgl buffer
  82994. */
  82995. getBuffer(): Nullable<WebGLBuffer>;
  82996. /**
  82997. * std140 layout specifies how to align data within an UBO structure.
  82998. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  82999. * for specs.
  83000. */
  83001. private _fillAlignment;
  83002. /**
  83003. * Adds an uniform in the buffer.
  83004. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  83005. * for the layout to be correct !
  83006. * @param name Name of the uniform, as used in the uniform block in the shader.
  83007. * @param size Data size, or data directly.
  83008. */
  83009. addUniform(name: string, size: number | number[]): void;
  83010. /**
  83011. * Adds a Matrix 4x4 to the uniform buffer.
  83012. * @param name Name of the uniform, as used in the uniform block in the shader.
  83013. * @param mat A 4x4 matrix.
  83014. */
  83015. addMatrix(name: string, mat: Matrix): void;
  83016. /**
  83017. * Adds a vec2 to the uniform buffer.
  83018. * @param name Name of the uniform, as used in the uniform block in the shader.
  83019. * @param x Define the x component value of the vec2
  83020. * @param y Define the y component value of the vec2
  83021. */
  83022. addFloat2(name: string, x: number, y: number): void;
  83023. /**
  83024. * Adds a vec3 to the uniform buffer.
  83025. * @param name Name of the uniform, as used in the uniform block in the shader.
  83026. * @param x Define the x component value of the vec3
  83027. * @param y Define the y component value of the vec3
  83028. * @param z Define the z component value of the vec3
  83029. */
  83030. addFloat3(name: string, x: number, y: number, z: number): void;
  83031. /**
  83032. * Adds a vec3 to the uniform buffer.
  83033. * @param name Name of the uniform, as used in the uniform block in the shader.
  83034. * @param color Define the vec3 from a Color
  83035. */
  83036. addColor3(name: string, color: Color3): void;
  83037. /**
  83038. * Adds a vec4 to the uniform buffer.
  83039. * @param name Name of the uniform, as used in the uniform block in the shader.
  83040. * @param color Define the rgb components from a Color
  83041. * @param alpha Define the a component of the vec4
  83042. */
  83043. addColor4(name: string, color: Color3, alpha: number): void;
  83044. /**
  83045. * Adds a vec3 to the uniform buffer.
  83046. * @param name Name of the uniform, as used in the uniform block in the shader.
  83047. * @param vector Define the vec3 components from a Vector
  83048. */
  83049. addVector3(name: string, vector: Vector3): void;
  83050. /**
  83051. * Adds a Matrix 3x3 to the uniform buffer.
  83052. * @param name Name of the uniform, as used in the uniform block in the shader.
  83053. */
  83054. addMatrix3x3(name: string): void;
  83055. /**
  83056. * Adds a Matrix 2x2 to the uniform buffer.
  83057. * @param name Name of the uniform, as used in the uniform block in the shader.
  83058. */
  83059. addMatrix2x2(name: string): void;
  83060. /**
  83061. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  83062. */
  83063. create(): void;
  83064. /** @hidden */
  83065. _rebuild(): void;
  83066. /**
  83067. * Updates the WebGL Uniform Buffer on the GPU.
  83068. * If the `dynamic` flag is set to true, no cache comparison is done.
  83069. * Otherwise, the buffer will be updated only if the cache differs.
  83070. */
  83071. update(): void;
  83072. /**
  83073. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  83074. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83075. * @param data Define the flattened data
  83076. * @param size Define the size of the data.
  83077. */
  83078. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  83079. private _updateMatrix3x3ForUniform;
  83080. private _updateMatrix3x3ForEffect;
  83081. private _updateMatrix2x2ForEffect;
  83082. private _updateMatrix2x2ForUniform;
  83083. private _updateFloatForEffect;
  83084. private _updateFloatForUniform;
  83085. private _updateFloat2ForEffect;
  83086. private _updateFloat2ForUniform;
  83087. private _updateFloat3ForEffect;
  83088. private _updateFloat3ForUniform;
  83089. private _updateFloat4ForEffect;
  83090. private _updateFloat4ForUniform;
  83091. private _updateMatrixForEffect;
  83092. private _updateMatrixForUniform;
  83093. private _updateVector3ForEffect;
  83094. private _updateVector3ForUniform;
  83095. private _updateVector4ForEffect;
  83096. private _updateVector4ForUniform;
  83097. private _updateColor3ForEffect;
  83098. private _updateColor3ForUniform;
  83099. private _updateColor4ForEffect;
  83100. private _updateColor4ForUniform;
  83101. /**
  83102. * Sets a sampler uniform on the effect.
  83103. * @param name Define the name of the sampler.
  83104. * @param texture Define the texture to set in the sampler
  83105. */
  83106. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  83107. /**
  83108. * Directly updates the value of the uniform in the cache AND on the GPU.
  83109. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83110. * @param data Define the flattened data
  83111. */
  83112. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  83113. /**
  83114. * Binds this uniform buffer to an effect.
  83115. * @param effect Define the effect to bind the buffer to
  83116. * @param name Name of the uniform block in the shader.
  83117. */
  83118. bindToEffect(effect: Effect, name: string): void;
  83119. /**
  83120. * Disposes the uniform buffer.
  83121. */
  83122. dispose(): void;
  83123. }
  83124. }
  83125. declare module BABYLON {
  83126. /**
  83127. * This represents the required contract to create a new type of texture loader.
  83128. */
  83129. export interface IInternalTextureLoader {
  83130. /**
  83131. * Defines wether the loader supports cascade loading the different faces.
  83132. */
  83133. supportCascades: boolean;
  83134. /**
  83135. * This returns if the loader support the current file information.
  83136. * @param extension defines the file extension of the file being loaded
  83137. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83138. * @param fallback defines the fallback internal texture if any
  83139. * @param isBase64 defines whether the texture is encoded as a base64
  83140. * @param isBuffer defines whether the texture data are stored as a buffer
  83141. * @returns true if the loader can load the specified file
  83142. */
  83143. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  83144. /**
  83145. * Transform the url before loading if required.
  83146. * @param rootUrl the url of the texture
  83147. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83148. * @returns the transformed texture
  83149. */
  83150. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  83151. /**
  83152. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  83153. * @param rootUrl the url of the texture
  83154. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83155. * @returns the fallback texture
  83156. */
  83157. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  83158. /**
  83159. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  83160. * @param data contains the texture data
  83161. * @param texture defines the BabylonJS internal texture
  83162. * @param createPolynomials will be true if polynomials have been requested
  83163. * @param onLoad defines the callback to trigger once the texture is ready
  83164. * @param onError defines the callback to trigger in case of error
  83165. */
  83166. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  83167. /**
  83168. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  83169. * @param data contains the texture data
  83170. * @param texture defines the BabylonJS internal texture
  83171. * @param callback defines the method to call once ready to upload
  83172. */
  83173. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  83174. }
  83175. }
  83176. declare module BABYLON {
  83177. /**
  83178. * Creation options of the multi render target texture.
  83179. */
  83180. export interface IMultiRenderTargetOptions {
  83181. /**
  83182. * Define if the texture needs to create mip maps after render.
  83183. */
  83184. generateMipMaps?: boolean;
  83185. /**
  83186. * Define the types of all the draw buffers we want to create
  83187. */
  83188. types?: number[];
  83189. /**
  83190. * Define the sampling modes of all the draw buffers we want to create
  83191. */
  83192. samplingModes?: number[];
  83193. /**
  83194. * Define if a depth buffer is required
  83195. */
  83196. generateDepthBuffer?: boolean;
  83197. /**
  83198. * Define if a stencil buffer is required
  83199. */
  83200. generateStencilBuffer?: boolean;
  83201. /**
  83202. * Define if a depth texture is required instead of a depth buffer
  83203. */
  83204. generateDepthTexture?: boolean;
  83205. /**
  83206. * Define the number of desired draw buffers
  83207. */
  83208. textureCount?: number;
  83209. /**
  83210. * Define if aspect ratio should be adapted to the texture or stay the scene one
  83211. */
  83212. doNotChangeAspectRatio?: boolean;
  83213. /**
  83214. * Define the default type of the buffers we are creating
  83215. */
  83216. defaultType?: number;
  83217. }
  83218. /**
  83219. * A multi render target, like a render target provides the ability to render to a texture.
  83220. * Unlike the render target, it can render to several draw buffers in one draw.
  83221. * This is specially interesting in deferred rendering or for any effects requiring more than
  83222. * just one color from a single pass.
  83223. */
  83224. export class MultiRenderTarget extends RenderTargetTexture {
  83225. private _internalTextures;
  83226. private _textures;
  83227. private _multiRenderTargetOptions;
  83228. /**
  83229. * Get if draw buffers are currently supported by the used hardware and browser.
  83230. */
  83231. readonly isSupported: boolean;
  83232. /**
  83233. * Get the list of textures generated by the multi render target.
  83234. */
  83235. readonly textures: Texture[];
  83236. /**
  83237. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  83238. */
  83239. readonly depthTexture: Texture;
  83240. /**
  83241. * Set the wrapping mode on U of all the textures we are rendering to.
  83242. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  83243. */
  83244. wrapU: number;
  83245. /**
  83246. * Set the wrapping mode on V of all the textures we are rendering to.
  83247. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  83248. */
  83249. wrapV: number;
  83250. /**
  83251. * Instantiate a new multi render target texture.
  83252. * A multi render target, like a render target provides the ability to render to a texture.
  83253. * Unlike the render target, it can render to several draw buffers in one draw.
  83254. * This is specially interesting in deferred rendering or for any effects requiring more than
  83255. * just one color from a single pass.
  83256. * @param name Define the name of the texture
  83257. * @param size Define the size of the buffers to render to
  83258. * @param count Define the number of target we are rendering into
  83259. * @param scene Define the scene the texture belongs to
  83260. * @param options Define the options used to create the multi render target
  83261. */
  83262. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  83263. /** @hidden */
  83264. _rebuild(): void;
  83265. private _createInternalTextures;
  83266. private _createTextures;
  83267. /**
  83268. * Define the number of samples used if MSAA is enabled.
  83269. */
  83270. samples: number;
  83271. /**
  83272. * Resize all the textures in the multi render target.
  83273. * Be carrefull as it will recreate all the data in the new texture.
  83274. * @param size Define the new size
  83275. */
  83276. resize(size: any): void;
  83277. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  83278. /**
  83279. * Dispose the render targets and their associated resources
  83280. */
  83281. dispose(): void;
  83282. /**
  83283. * Release all the underlying texture used as draw buffers.
  83284. */
  83285. releaseInternalTextures(): void;
  83286. }
  83287. }
  83288. declare module BABYLON {
  83289. /**
  83290. * Class used to work with sound analyzer using fast fourier transform (FFT)
  83291. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83292. */
  83293. export class Analyser {
  83294. /**
  83295. * Gets or sets the smoothing
  83296. * @ignorenaming
  83297. */
  83298. SMOOTHING: number;
  83299. /**
  83300. * Gets or sets the FFT table size
  83301. * @ignorenaming
  83302. */
  83303. FFT_SIZE: number;
  83304. /**
  83305. * Gets or sets the bar graph amplitude
  83306. * @ignorenaming
  83307. */
  83308. BARGRAPHAMPLITUDE: number;
  83309. /**
  83310. * Gets or sets the position of the debug canvas
  83311. * @ignorenaming
  83312. */
  83313. DEBUGCANVASPOS: {
  83314. x: number;
  83315. y: number;
  83316. };
  83317. /**
  83318. * Gets or sets the debug canvas size
  83319. * @ignorenaming
  83320. */
  83321. DEBUGCANVASSIZE: {
  83322. width: number;
  83323. height: number;
  83324. };
  83325. private _byteFreqs;
  83326. private _byteTime;
  83327. private _floatFreqs;
  83328. private _webAudioAnalyser;
  83329. private _debugCanvas;
  83330. private _debugCanvasContext;
  83331. private _scene;
  83332. private _registerFunc;
  83333. private _audioEngine;
  83334. /**
  83335. * Creates a new analyser
  83336. * @param scene defines hosting scene
  83337. */
  83338. constructor(scene: Scene);
  83339. /**
  83340. * Get the number of data values you will have to play with for the visualization
  83341. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  83342. * @returns a number
  83343. */
  83344. getFrequencyBinCount(): number;
  83345. /**
  83346. * Gets the current frequency data as a byte array
  83347. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83348. * @returns a Uint8Array
  83349. */
  83350. getByteFrequencyData(): Uint8Array;
  83351. /**
  83352. * Gets the current waveform as a byte array
  83353. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  83354. * @returns a Uint8Array
  83355. */
  83356. getByteTimeDomainData(): Uint8Array;
  83357. /**
  83358. * Gets the current frequency data as a float array
  83359. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83360. * @returns a Float32Array
  83361. */
  83362. getFloatFrequencyData(): Float32Array;
  83363. /**
  83364. * Renders the debug canvas
  83365. */
  83366. drawDebugCanvas(): void;
  83367. /**
  83368. * Stops rendering the debug canvas and removes it
  83369. */
  83370. stopDebugCanvas(): void;
  83371. /**
  83372. * Connects two audio nodes
  83373. * @param inputAudioNode defines first node to connect
  83374. * @param outputAudioNode defines second node to connect
  83375. */
  83376. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  83377. /**
  83378. * Releases all associated resources
  83379. */
  83380. dispose(): void;
  83381. }
  83382. }
  83383. declare module BABYLON {
  83384. /**
  83385. * This represents an audio engine and it is responsible
  83386. * to play, synchronize and analyse sounds throughout the application.
  83387. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83388. */
  83389. export interface IAudioEngine extends IDisposable {
  83390. /**
  83391. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83392. */
  83393. readonly canUseWebAudio: boolean;
  83394. /**
  83395. * Gets the current AudioContext if available.
  83396. */
  83397. readonly audioContext: Nullable<AudioContext>;
  83398. /**
  83399. * The master gain node defines the global audio volume of your audio engine.
  83400. */
  83401. readonly masterGain: GainNode;
  83402. /**
  83403. * Gets whether or not mp3 are supported by your browser.
  83404. */
  83405. readonly isMP3supported: boolean;
  83406. /**
  83407. * Gets whether or not ogg are supported by your browser.
  83408. */
  83409. readonly isOGGsupported: boolean;
  83410. /**
  83411. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83412. * @ignoreNaming
  83413. */
  83414. WarnedWebAudioUnsupported: boolean;
  83415. /**
  83416. * Defines if the audio engine relies on a custom unlocked button.
  83417. * In this case, the embedded button will not be displayed.
  83418. */
  83419. useCustomUnlockedButton: boolean;
  83420. /**
  83421. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  83422. */
  83423. readonly unlocked: boolean;
  83424. /**
  83425. * Event raised when audio has been unlocked on the browser.
  83426. */
  83427. onAudioUnlockedObservable: Observable<AudioEngine>;
  83428. /**
  83429. * Event raised when audio has been locked on the browser.
  83430. */
  83431. onAudioLockedObservable: Observable<AudioEngine>;
  83432. /**
  83433. * Flags the audio engine in Locked state.
  83434. * This happens due to new browser policies preventing audio to autoplay.
  83435. */
  83436. lock(): void;
  83437. /**
  83438. * Unlocks the audio engine once a user action has been done on the dom.
  83439. * This is helpful to resume play once browser policies have been satisfied.
  83440. */
  83441. unlock(): void;
  83442. }
  83443. /**
  83444. * This represents the default audio engine used in babylon.
  83445. * It is responsible to play, synchronize and analyse sounds throughout the application.
  83446. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83447. */
  83448. export class AudioEngine implements IAudioEngine {
  83449. private _audioContext;
  83450. private _audioContextInitialized;
  83451. private _muteButton;
  83452. private _hostElement;
  83453. /**
  83454. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83455. */
  83456. canUseWebAudio: boolean;
  83457. /**
  83458. * The master gain node defines the global audio volume of your audio engine.
  83459. */
  83460. masterGain: GainNode;
  83461. /**
  83462. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83463. * @ignoreNaming
  83464. */
  83465. WarnedWebAudioUnsupported: boolean;
  83466. /**
  83467. * Gets whether or not mp3 are supported by your browser.
  83468. */
  83469. isMP3supported: boolean;
  83470. /**
  83471. * Gets whether or not ogg are supported by your browser.
  83472. */
  83473. isOGGsupported: boolean;
  83474. /**
  83475. * Gets whether audio has been unlocked on the device.
  83476. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  83477. * a user interaction has happened.
  83478. */
  83479. unlocked: boolean;
  83480. /**
  83481. * Defines if the audio engine relies on a custom unlocked button.
  83482. * In this case, the embedded button will not be displayed.
  83483. */
  83484. useCustomUnlockedButton: boolean;
  83485. /**
  83486. * Event raised when audio has been unlocked on the browser.
  83487. */
  83488. onAudioUnlockedObservable: Observable<AudioEngine>;
  83489. /**
  83490. * Event raised when audio has been locked on the browser.
  83491. */
  83492. onAudioLockedObservable: Observable<AudioEngine>;
  83493. /**
  83494. * Gets the current AudioContext if available.
  83495. */
  83496. readonly audioContext: Nullable<AudioContext>;
  83497. private _connectedAnalyser;
  83498. /**
  83499. * Instantiates a new audio engine.
  83500. *
  83501. * There should be only one per page as some browsers restrict the number
  83502. * of audio contexts you can create.
  83503. * @param hostElement defines the host element where to display the mute icon if necessary
  83504. */
  83505. constructor(hostElement?: Nullable<HTMLElement>);
  83506. /**
  83507. * Flags the audio engine in Locked state.
  83508. * This happens due to new browser policies preventing audio to autoplay.
  83509. */
  83510. lock(): void;
  83511. /**
  83512. * Unlocks the audio engine once a user action has been done on the dom.
  83513. * This is helpful to resume play once browser policies have been satisfied.
  83514. */
  83515. unlock(): void;
  83516. private _resumeAudioContext;
  83517. private _initializeAudioContext;
  83518. private _tryToRun;
  83519. private _triggerRunningState;
  83520. private _triggerSuspendedState;
  83521. private _displayMuteButton;
  83522. private _moveButtonToTopLeft;
  83523. private _onResize;
  83524. private _hideMuteButton;
  83525. /**
  83526. * Destroy and release the resources associated with the audio ccontext.
  83527. */
  83528. dispose(): void;
  83529. /**
  83530. * Gets the global volume sets on the master gain.
  83531. * @returns the global volume if set or -1 otherwise
  83532. */
  83533. getGlobalVolume(): number;
  83534. /**
  83535. * Sets the global volume of your experience (sets on the master gain).
  83536. * @param newVolume Defines the new global volume of the application
  83537. */
  83538. setGlobalVolume(newVolume: number): void;
  83539. /**
  83540. * Connect the audio engine to an audio analyser allowing some amazing
  83541. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  83542. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  83543. * @param analyser The analyser to connect to the engine
  83544. */
  83545. connectToAnalyser(analyser: Analyser): void;
  83546. }
  83547. }
  83548. declare module BABYLON {
  83549. /**
  83550. * Interface used to present a loading screen while loading a scene
  83551. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83552. */
  83553. export interface ILoadingScreen {
  83554. /**
  83555. * Function called to display the loading screen
  83556. */
  83557. displayLoadingUI: () => void;
  83558. /**
  83559. * Function called to hide the loading screen
  83560. */
  83561. hideLoadingUI: () => void;
  83562. /**
  83563. * Gets or sets the color to use for the background
  83564. */
  83565. loadingUIBackgroundColor: string;
  83566. /**
  83567. * Gets or sets the text to display while loading
  83568. */
  83569. loadingUIText: string;
  83570. }
  83571. /**
  83572. * Class used for the default loading screen
  83573. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83574. */
  83575. export class DefaultLoadingScreen implements ILoadingScreen {
  83576. private _renderingCanvas;
  83577. private _loadingText;
  83578. private _loadingDivBackgroundColor;
  83579. private _loadingDiv;
  83580. private _loadingTextDiv;
  83581. /**
  83582. * Creates a new default loading screen
  83583. * @param _renderingCanvas defines the canvas used to render the scene
  83584. * @param _loadingText defines the default text to display
  83585. * @param _loadingDivBackgroundColor defines the default background color
  83586. */
  83587. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  83588. /**
  83589. * Function called to display the loading screen
  83590. */
  83591. displayLoadingUI(): void;
  83592. /**
  83593. * Function called to hide the loading screen
  83594. */
  83595. hideLoadingUI(): void;
  83596. /**
  83597. * Gets or sets the text to display while loading
  83598. */
  83599. loadingUIText: string;
  83600. /**
  83601. * Gets or sets the color to use for the background
  83602. */
  83603. loadingUIBackgroundColor: string;
  83604. private _resizeLoadingUI;
  83605. }
  83606. }
  83607. declare module BABYLON {
  83608. /**
  83609. * Settings for finer control over video usage
  83610. */
  83611. export interface VideoTextureSettings {
  83612. /**
  83613. * Applies `autoplay` to video, if specified
  83614. */
  83615. autoPlay?: boolean;
  83616. /**
  83617. * Applies `loop` to video, if specified
  83618. */
  83619. loop?: boolean;
  83620. /**
  83621. * Automatically updates internal texture from video at every frame in the render loop
  83622. */
  83623. autoUpdateTexture: boolean;
  83624. /**
  83625. * Image src displayed during the video loading or until the user interacts with the video.
  83626. */
  83627. poster?: string;
  83628. }
  83629. /**
  83630. * If you want to display a video in your scene, this is the special texture for that.
  83631. * This special texture works similar to other textures, with the exception of a few parameters.
  83632. * @see https://doc.babylonjs.com/how_to/video_texture
  83633. */
  83634. export class VideoTexture extends Texture {
  83635. /**
  83636. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  83637. */
  83638. readonly autoUpdateTexture: boolean;
  83639. /**
  83640. * The video instance used by the texture internally
  83641. */
  83642. readonly video: HTMLVideoElement;
  83643. private _onUserActionRequestedObservable;
  83644. /**
  83645. * Event triggerd when a dom action is required by the user to play the video.
  83646. * This happens due to recent changes in browser policies preventing video to auto start.
  83647. */
  83648. readonly onUserActionRequestedObservable: Observable<Texture>;
  83649. private _generateMipMaps;
  83650. private _engine;
  83651. private _stillImageCaptured;
  83652. private _displayingPosterTexture;
  83653. private _settings;
  83654. private _createInternalTextureOnEvent;
  83655. /**
  83656. * Creates a video texture.
  83657. * If you want to display a video in your scene, this is the special texture for that.
  83658. * This special texture works similar to other textures, with the exception of a few parameters.
  83659. * @see https://doc.babylonjs.com/how_to/video_texture
  83660. * @param name optional name, will detect from video source, if not defined
  83661. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  83662. * @param scene is obviously the current scene.
  83663. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  83664. * @param invertY is false by default but can be used to invert video on Y axis
  83665. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  83666. * @param settings allows finer control over video usage
  83667. */
  83668. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  83669. private _getName;
  83670. private _getVideo;
  83671. private _createInternalTexture;
  83672. private reset;
  83673. /**
  83674. * @hidden Internal method to initiate `update`.
  83675. */
  83676. _rebuild(): void;
  83677. /**
  83678. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  83679. */
  83680. update(): void;
  83681. /**
  83682. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  83683. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  83684. */
  83685. updateTexture(isVisible: boolean): void;
  83686. protected _updateInternalTexture: () => void;
  83687. /**
  83688. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  83689. * @param url New url.
  83690. */
  83691. updateURL(url: string): void;
  83692. /**
  83693. * Dispose the texture and release its associated resources.
  83694. */
  83695. dispose(): void;
  83696. /**
  83697. * Creates a video texture straight from a stream.
  83698. * @param scene Define the scene the texture should be created in
  83699. * @param stream Define the stream the texture should be created from
  83700. * @returns The created video texture as a promise
  83701. */
  83702. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  83703. /**
  83704. * Creates a video texture straight from your WebCam video feed.
  83705. * @param scene Define the scene the texture should be created in
  83706. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83707. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83708. * @returns The created video texture as a promise
  83709. */
  83710. static CreateFromWebCamAsync(scene: Scene, constraints: {
  83711. minWidth: number;
  83712. maxWidth: number;
  83713. minHeight: number;
  83714. maxHeight: number;
  83715. deviceId: string;
  83716. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  83717. /**
  83718. * Creates a video texture straight from your WebCam video feed.
  83719. * @param scene Define the scene the texture should be created in
  83720. * @param onReady Define a callback to triggered once the texture will be ready
  83721. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83722. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83723. */
  83724. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  83725. minWidth: number;
  83726. maxWidth: number;
  83727. minHeight: number;
  83728. maxHeight: number;
  83729. deviceId: string;
  83730. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  83731. }
  83732. }
  83733. declare module BABYLON {
  83734. /**
  83735. * Interface for attribute information associated with buffer instanciation
  83736. */
  83737. export class InstancingAttributeInfo {
  83738. /**
  83739. * Index/offset of the attribute in the vertex shader
  83740. */
  83741. index: number;
  83742. /**
  83743. * size of the attribute, 1, 2, 3 or 4
  83744. */
  83745. attributeSize: number;
  83746. /**
  83747. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  83748. * default is FLOAT
  83749. */
  83750. attribyteType: number;
  83751. /**
  83752. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  83753. */
  83754. normalized: boolean;
  83755. /**
  83756. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  83757. */
  83758. offset: number;
  83759. /**
  83760. * Name of the GLSL attribute, for debugging purpose only
  83761. */
  83762. attributeName: string;
  83763. }
  83764. /**
  83765. * Define options used to create a depth texture
  83766. */
  83767. export class DepthTextureCreationOptions {
  83768. /** Specifies whether or not a stencil should be allocated in the texture */
  83769. generateStencil?: boolean;
  83770. /** Specifies whether or not bilinear filtering is enable on the texture */
  83771. bilinearFiltering?: boolean;
  83772. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  83773. comparisonFunction?: number;
  83774. /** Specifies if the created texture is a cube texture */
  83775. isCube?: boolean;
  83776. }
  83777. /**
  83778. * Class used to describe the capabilities of the engine relatively to the current browser
  83779. */
  83780. export class EngineCapabilities {
  83781. /** Maximum textures units per fragment shader */
  83782. maxTexturesImageUnits: number;
  83783. /** Maximum texture units per vertex shader */
  83784. maxVertexTextureImageUnits: number;
  83785. /** Maximum textures units in the entire pipeline */
  83786. maxCombinedTexturesImageUnits: number;
  83787. /** Maximum texture size */
  83788. maxTextureSize: number;
  83789. /** Maximum cube texture size */
  83790. maxCubemapTextureSize: number;
  83791. /** Maximum render texture size */
  83792. maxRenderTextureSize: number;
  83793. /** Maximum number of vertex attributes */
  83794. maxVertexAttribs: number;
  83795. /** Maximum number of varyings */
  83796. maxVaryingVectors: number;
  83797. /** Maximum number of uniforms per vertex shader */
  83798. maxVertexUniformVectors: number;
  83799. /** Maximum number of uniforms per fragment shader */
  83800. maxFragmentUniformVectors: number;
  83801. /** Defines if standard derivates (dx/dy) are supported */
  83802. standardDerivatives: boolean;
  83803. /** Defines if s3tc texture compression is supported */
  83804. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  83805. /** Defines if pvrtc texture compression is supported */
  83806. pvrtc: any;
  83807. /** Defines if etc1 texture compression is supported */
  83808. etc1: any;
  83809. /** Defines if etc2 texture compression is supported */
  83810. etc2: any;
  83811. /** Defines if astc texture compression is supported */
  83812. astc: any;
  83813. /** Defines if float textures are supported */
  83814. textureFloat: boolean;
  83815. /** Defines if vertex array objects are supported */
  83816. vertexArrayObject: boolean;
  83817. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  83818. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  83819. /** Gets the maximum level of anisotropy supported */
  83820. maxAnisotropy: number;
  83821. /** Defines if instancing is supported */
  83822. instancedArrays: boolean;
  83823. /** Defines if 32 bits indices are supported */
  83824. uintIndices: boolean;
  83825. /** Defines if high precision shaders are supported */
  83826. highPrecisionShaderSupported: boolean;
  83827. /** Defines if depth reading in the fragment shader is supported */
  83828. fragmentDepthSupported: boolean;
  83829. /** Defines if float texture linear filtering is supported*/
  83830. textureFloatLinearFiltering: boolean;
  83831. /** Defines if rendering to float textures is supported */
  83832. textureFloatRender: boolean;
  83833. /** Defines if half float textures are supported*/
  83834. textureHalfFloat: boolean;
  83835. /** Defines if half float texture linear filtering is supported*/
  83836. textureHalfFloatLinearFiltering: boolean;
  83837. /** Defines if rendering to half float textures is supported */
  83838. textureHalfFloatRender: boolean;
  83839. /** Defines if textureLOD shader command is supported */
  83840. textureLOD: boolean;
  83841. /** Defines if draw buffers extension is supported */
  83842. drawBuffersExtension: boolean;
  83843. /** Defines if depth textures are supported */
  83844. depthTextureExtension: boolean;
  83845. /** Defines if float color buffer are supported */
  83846. colorBufferFloat: boolean;
  83847. /** Gets disjoint timer query extension (null if not supported) */
  83848. timerQuery: EXT_disjoint_timer_query;
  83849. /** Defines if timestamp can be used with timer query */
  83850. canUseTimestampForTimerQuery: boolean;
  83851. /** Function used to let the system compiles shaders in background */
  83852. parallelShaderCompile: {
  83853. MAX_SHADER_COMPILER_THREADS_KHR: number;
  83854. maxShaderCompilerThreadsKHR: (thread: number) => void;
  83855. COMPLETION_STATUS_KHR: number;
  83856. };
  83857. }
  83858. /** Interface defining initialization parameters for Engine class */
  83859. export interface EngineOptions extends WebGLContextAttributes {
  83860. /**
  83861. * Defines if the engine should no exceed a specified device ratio
  83862. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  83863. */
  83864. limitDeviceRatio?: number;
  83865. /**
  83866. * Defines if webvr should be enabled automatically
  83867. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83868. */
  83869. autoEnableWebVR?: boolean;
  83870. /**
  83871. * Defines if webgl2 should be turned off even if supported
  83872. * @see http://doc.babylonjs.com/features/webgl2
  83873. */
  83874. disableWebGL2Support?: boolean;
  83875. /**
  83876. * Defines if webaudio should be initialized as well
  83877. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83878. */
  83879. audioEngine?: boolean;
  83880. /**
  83881. * Defines if animations should run using a deterministic lock step
  83882. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83883. */
  83884. deterministicLockstep?: boolean;
  83885. /** Defines the maximum steps to use with deterministic lock step mode */
  83886. lockstepMaxSteps?: number;
  83887. /**
  83888. * Defines that engine should ignore context lost events
  83889. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  83890. */
  83891. doNotHandleContextLost?: boolean;
  83892. /**
  83893. * Defines that engine should ignore modifying touch action attribute and style
  83894. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  83895. */
  83896. doNotHandleTouchAction?: boolean;
  83897. }
  83898. /**
  83899. * Defines the interface used by display changed events
  83900. */
  83901. export interface IDisplayChangedEventArgs {
  83902. /** Gets the vrDisplay object (if any) */
  83903. vrDisplay: Nullable<any>;
  83904. /** Gets a boolean indicating if webVR is supported */
  83905. vrSupported: boolean;
  83906. }
  83907. /**
  83908. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  83909. */
  83910. export class Engine {
  83911. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  83912. static ExceptionList: ({
  83913. key: string;
  83914. capture: string;
  83915. captureConstraint: number;
  83916. targets: string[];
  83917. } | {
  83918. key: string;
  83919. capture: null;
  83920. captureConstraint: null;
  83921. targets: string[];
  83922. })[];
  83923. /** Gets the list of created engines */
  83924. static readonly Instances: Engine[];
  83925. /**
  83926. * Gets the latest created engine
  83927. */
  83928. static readonly LastCreatedEngine: Nullable<Engine>;
  83929. /**
  83930. * Gets the latest created scene
  83931. */
  83932. static readonly LastCreatedScene: Nullable<Scene>;
  83933. /**
  83934. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  83935. * @param flag defines which part of the materials must be marked as dirty
  83936. * @param predicate defines a predicate used to filter which materials should be affected
  83937. */
  83938. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  83939. /**
  83940. * Hidden
  83941. */
  83942. static _TextureLoaders: IInternalTextureLoader[];
  83943. /** Defines that alpha blending is disabled */
  83944. static readonly ALPHA_DISABLE: number;
  83945. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  83946. static readonly ALPHA_ADD: number;
  83947. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  83948. static readonly ALPHA_COMBINE: number;
  83949. /** Defines that alpha blending to DEST - SRC * DEST */
  83950. static readonly ALPHA_SUBTRACT: number;
  83951. /** Defines that alpha blending to SRC * DEST */
  83952. static readonly ALPHA_MULTIPLY: number;
  83953. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  83954. static readonly ALPHA_MAXIMIZED: number;
  83955. /** Defines that alpha blending to SRC + DEST */
  83956. static readonly ALPHA_ONEONE: number;
  83957. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  83958. static readonly ALPHA_PREMULTIPLIED: number;
  83959. /**
  83960. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  83961. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  83962. */
  83963. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  83964. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  83965. static readonly ALPHA_INTERPOLATE: number;
  83966. /**
  83967. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  83968. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  83969. */
  83970. static readonly ALPHA_SCREENMODE: number;
  83971. /** Defines that the ressource is not delayed*/
  83972. static readonly DELAYLOADSTATE_NONE: number;
  83973. /** Defines that the ressource was successfully delay loaded */
  83974. static readonly DELAYLOADSTATE_LOADED: number;
  83975. /** Defines that the ressource is currently delay loading */
  83976. static readonly DELAYLOADSTATE_LOADING: number;
  83977. /** Defines that the ressource is delayed and has not started loading */
  83978. static readonly DELAYLOADSTATE_NOTLOADED: number;
  83979. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  83980. static readonly NEVER: number;
  83981. /** 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 */
  83982. static readonly ALWAYS: number;
  83983. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  83984. static readonly LESS: number;
  83985. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  83986. static readonly EQUAL: number;
  83987. /** 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 */
  83988. static readonly LEQUAL: number;
  83989. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  83990. static readonly GREATER: number;
  83991. /** 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 */
  83992. static readonly GEQUAL: number;
  83993. /** 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 */
  83994. static readonly NOTEQUAL: number;
  83995. /** Passed to stencilOperation to specify that stencil value must be kept */
  83996. static readonly KEEP: number;
  83997. /** Passed to stencilOperation to specify that stencil value must be replaced */
  83998. static readonly REPLACE: number;
  83999. /** Passed to stencilOperation to specify that stencil value must be incremented */
  84000. static readonly INCR: number;
  84001. /** Passed to stencilOperation to specify that stencil value must be decremented */
  84002. static readonly DECR: number;
  84003. /** Passed to stencilOperation to specify that stencil value must be inverted */
  84004. static readonly INVERT: number;
  84005. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  84006. static readonly INCR_WRAP: number;
  84007. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  84008. static readonly DECR_WRAP: number;
  84009. /** Texture is not repeating outside of 0..1 UVs */
  84010. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  84011. /** Texture is repeating outside of 0..1 UVs */
  84012. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  84013. /** Texture is repeating and mirrored */
  84014. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  84015. /** ALPHA */
  84016. static readonly TEXTUREFORMAT_ALPHA: number;
  84017. /** LUMINANCE */
  84018. static readonly TEXTUREFORMAT_LUMINANCE: number;
  84019. /** LUMINANCE_ALPHA */
  84020. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  84021. /** RGB */
  84022. static readonly TEXTUREFORMAT_RGB: number;
  84023. /** RGBA */
  84024. static readonly TEXTUREFORMAT_RGBA: number;
  84025. /** RED */
  84026. static readonly TEXTUREFORMAT_RED: number;
  84027. /** RED (2nd reference) */
  84028. static readonly TEXTUREFORMAT_R: number;
  84029. /** RG */
  84030. static readonly TEXTUREFORMAT_RG: number;
  84031. /** RED_INTEGER */
  84032. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  84033. /** RED_INTEGER (2nd reference) */
  84034. static readonly TEXTUREFORMAT_R_INTEGER: number;
  84035. /** RG_INTEGER */
  84036. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  84037. /** RGB_INTEGER */
  84038. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  84039. /** RGBA_INTEGER */
  84040. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  84041. /** UNSIGNED_BYTE */
  84042. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  84043. /** UNSIGNED_BYTE (2nd reference) */
  84044. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  84045. /** FLOAT */
  84046. static readonly TEXTURETYPE_FLOAT: number;
  84047. /** HALF_FLOAT */
  84048. static readonly TEXTURETYPE_HALF_FLOAT: number;
  84049. /** BYTE */
  84050. static readonly TEXTURETYPE_BYTE: number;
  84051. /** SHORT */
  84052. static readonly TEXTURETYPE_SHORT: number;
  84053. /** UNSIGNED_SHORT */
  84054. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  84055. /** INT */
  84056. static readonly TEXTURETYPE_INT: number;
  84057. /** UNSIGNED_INT */
  84058. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  84059. /** UNSIGNED_SHORT_4_4_4_4 */
  84060. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  84061. /** UNSIGNED_SHORT_5_5_5_1 */
  84062. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  84063. /** UNSIGNED_SHORT_5_6_5 */
  84064. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  84065. /** UNSIGNED_INT_2_10_10_10_REV */
  84066. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  84067. /** UNSIGNED_INT_24_8 */
  84068. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  84069. /** UNSIGNED_INT_10F_11F_11F_REV */
  84070. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  84071. /** UNSIGNED_INT_5_9_9_9_REV */
  84072. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  84073. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  84074. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  84075. /** nearest is mag = nearest and min = nearest and mip = linear */
  84076. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  84077. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84078. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  84079. /** Trilinear is mag = linear and min = linear and mip = linear */
  84080. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  84081. /** nearest is mag = nearest and min = nearest and mip = linear */
  84082. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  84083. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84084. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  84085. /** Trilinear is mag = linear and min = linear and mip = linear */
  84086. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  84087. /** mag = nearest and min = nearest and mip = nearest */
  84088. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  84089. /** mag = nearest and min = linear and mip = nearest */
  84090. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  84091. /** mag = nearest and min = linear and mip = linear */
  84092. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  84093. /** mag = nearest and min = linear and mip = none */
  84094. static readonly TEXTURE_NEAREST_LINEAR: number;
  84095. /** mag = nearest and min = nearest and mip = none */
  84096. static readonly TEXTURE_NEAREST_NEAREST: number;
  84097. /** mag = linear and min = nearest and mip = nearest */
  84098. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  84099. /** mag = linear and min = nearest and mip = linear */
  84100. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  84101. /** mag = linear and min = linear and mip = none */
  84102. static readonly TEXTURE_LINEAR_LINEAR: number;
  84103. /** mag = linear and min = nearest and mip = none */
  84104. static readonly TEXTURE_LINEAR_NEAREST: number;
  84105. /** Explicit coordinates mode */
  84106. static readonly TEXTURE_EXPLICIT_MODE: number;
  84107. /** Spherical coordinates mode */
  84108. static readonly TEXTURE_SPHERICAL_MODE: number;
  84109. /** Planar coordinates mode */
  84110. static readonly TEXTURE_PLANAR_MODE: number;
  84111. /** Cubic coordinates mode */
  84112. static readonly TEXTURE_CUBIC_MODE: number;
  84113. /** Projection coordinates mode */
  84114. static readonly TEXTURE_PROJECTION_MODE: number;
  84115. /** Skybox coordinates mode */
  84116. static readonly TEXTURE_SKYBOX_MODE: number;
  84117. /** Inverse Cubic coordinates mode */
  84118. static readonly TEXTURE_INVCUBIC_MODE: number;
  84119. /** Equirectangular coordinates mode */
  84120. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  84121. /** Equirectangular Fixed coordinates mode */
  84122. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  84123. /** Equirectangular Fixed Mirrored coordinates mode */
  84124. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  84125. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  84126. static readonly SCALEMODE_FLOOR: number;
  84127. /** Defines that texture rescaling will look for the nearest power of 2 size */
  84128. static readonly SCALEMODE_NEAREST: number;
  84129. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  84130. static readonly SCALEMODE_CEILING: number;
  84131. /**
  84132. * Returns the current version of the framework
  84133. */
  84134. static readonly Version: string;
  84135. /**
  84136. * Returns a string describing the current engine
  84137. */
  84138. readonly description: string;
  84139. /**
  84140. * Gets or sets the epsilon value used by collision engine
  84141. */
  84142. static CollisionsEpsilon: number;
  84143. /**
  84144. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  84145. */
  84146. static ShadersRepository: string;
  84147. /**
  84148. * Method called to create the default loading screen.
  84149. * This can be overriden in your own app.
  84150. * @param canvas The rendering canvas element
  84151. * @returns The loading screen
  84152. */
  84153. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  84154. /**
  84155. * Method called to create the default rescale post process on each engine.
  84156. */
  84157. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  84158. /**
  84159. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  84160. */
  84161. forcePOTTextures: boolean;
  84162. /**
  84163. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  84164. */
  84165. isFullscreen: boolean;
  84166. /**
  84167. * Gets a boolean indicating if the pointer is currently locked
  84168. */
  84169. isPointerLock: boolean;
  84170. /**
  84171. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  84172. */
  84173. cullBackFaces: boolean;
  84174. /**
  84175. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  84176. */
  84177. renderEvenInBackground: boolean;
  84178. /**
  84179. * Gets or sets a boolean indicating that cache can be kept between frames
  84180. */
  84181. preventCacheWipeBetweenFrames: boolean;
  84182. /**
  84183. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  84184. **/
  84185. enableOfflineSupport: boolean;
  84186. /**
  84187. * 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)
  84188. **/
  84189. disableManifestCheck: boolean;
  84190. /**
  84191. * Gets the list of created scenes
  84192. */
  84193. scenes: Scene[];
  84194. /**
  84195. * Event raised when a new scene is created
  84196. */
  84197. onNewSceneAddedObservable: Observable<Scene>;
  84198. /**
  84199. * Gets the list of created postprocesses
  84200. */
  84201. postProcesses: PostProcess[];
  84202. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  84203. validateShaderPrograms: boolean;
  84204. /**
  84205. * Observable event triggered each time the rendering canvas is resized
  84206. */
  84207. onResizeObservable: Observable<Engine>;
  84208. /**
  84209. * Observable event triggered each time the canvas loses focus
  84210. */
  84211. onCanvasBlurObservable: Observable<Engine>;
  84212. /**
  84213. * Observable event triggered each time the canvas gains focus
  84214. */
  84215. onCanvasFocusObservable: Observable<Engine>;
  84216. /**
  84217. * Observable event triggered each time the canvas receives pointerout event
  84218. */
  84219. onCanvasPointerOutObservable: Observable<PointerEvent>;
  84220. /**
  84221. * Observable event triggered before each texture is initialized
  84222. */
  84223. onBeforeTextureInitObservable: Observable<Texture>;
  84224. private _vrDisplay;
  84225. private _vrSupported;
  84226. private _oldSize;
  84227. private _oldHardwareScaleFactor;
  84228. private _vrExclusivePointerMode;
  84229. private _webVRInitPromise;
  84230. /**
  84231. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  84232. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  84233. */
  84234. readonly isInVRExclusivePointerMode: boolean;
  84235. /**
  84236. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  84237. */
  84238. disableUniformBuffers: boolean;
  84239. /** @hidden */
  84240. _uniformBuffers: UniformBuffer[];
  84241. /**
  84242. * Gets a boolean indicating that the engine supports uniform buffers
  84243. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84244. */
  84245. readonly supportsUniformBuffers: boolean;
  84246. /**
  84247. * Observable raised when the engine begins a new frame
  84248. */
  84249. onBeginFrameObservable: Observable<Engine>;
  84250. /**
  84251. * If set, will be used to request the next animation frame for the render loop
  84252. */
  84253. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  84254. /**
  84255. * Observable raised when the engine ends the current frame
  84256. */
  84257. onEndFrameObservable: Observable<Engine>;
  84258. /**
  84259. * Observable raised when the engine is about to compile a shader
  84260. */
  84261. onBeforeShaderCompilationObservable: Observable<Engine>;
  84262. /**
  84263. * Observable raised when the engine has jsut compiled a shader
  84264. */
  84265. onAfterShaderCompilationObservable: Observable<Engine>;
  84266. /** @hidden */
  84267. _gl: WebGLRenderingContext;
  84268. private _renderingCanvas;
  84269. private _windowIsBackground;
  84270. private _webGLVersion;
  84271. /**
  84272. * Gets a boolean indicating that only power of 2 textures are supported
  84273. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  84274. */
  84275. readonly needPOTTextures: boolean;
  84276. /** @hidden */
  84277. _badOS: boolean;
  84278. /** @hidden */
  84279. _badDesktopOS: boolean;
  84280. /**
  84281. * Gets or sets a value indicating if we want to disable texture binding optimization.
  84282. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  84283. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  84284. */
  84285. disableTextureBindingOptimization: boolean;
  84286. /**
  84287. * Gets the audio engine
  84288. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84289. * @ignorenaming
  84290. */
  84291. static audioEngine: IAudioEngine;
  84292. /**
  84293. * Default AudioEngine factory responsible of creating the Audio Engine.
  84294. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  84295. */
  84296. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  84297. /**
  84298. * Default offline support factory responsible of creating a tool used to store data locally.
  84299. * By default, this will create a Database object if the workload has been embedded.
  84300. */
  84301. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  84302. private _onFocus;
  84303. private _onBlur;
  84304. private _onCanvasPointerOut;
  84305. private _onCanvasBlur;
  84306. private _onCanvasFocus;
  84307. private _onFullscreenChange;
  84308. private _onPointerLockChange;
  84309. private _onVRDisplayPointerRestricted;
  84310. private _onVRDisplayPointerUnrestricted;
  84311. private _onVrDisplayConnect;
  84312. private _onVrDisplayDisconnect;
  84313. private _onVrDisplayPresentChange;
  84314. /**
  84315. * Observable signaled when VR display mode changes
  84316. */
  84317. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  84318. /**
  84319. * Observable signaled when VR request present is complete
  84320. */
  84321. onVRRequestPresentComplete: Observable<boolean>;
  84322. /**
  84323. * Observable signaled when VR request present starts
  84324. */
  84325. onVRRequestPresentStart: Observable<Engine>;
  84326. private _hardwareScalingLevel;
  84327. /** @hidden */
  84328. protected _caps: EngineCapabilities;
  84329. private _pointerLockRequested;
  84330. private _isStencilEnable;
  84331. private _colorWrite;
  84332. private _loadingScreen;
  84333. /** @hidden */
  84334. _drawCalls: PerfCounter;
  84335. /** @hidden */
  84336. _textureCollisions: PerfCounter;
  84337. private _glVersion;
  84338. private _glRenderer;
  84339. private _glVendor;
  84340. private _videoTextureSupported;
  84341. private _renderingQueueLaunched;
  84342. private _activeRenderLoops;
  84343. private _deterministicLockstep;
  84344. private _lockstepMaxSteps;
  84345. /**
  84346. * Observable signaled when a context lost event is raised
  84347. */
  84348. onContextLostObservable: Observable<Engine>;
  84349. /**
  84350. * Observable signaled when a context restored event is raised
  84351. */
  84352. onContextRestoredObservable: Observable<Engine>;
  84353. private _onContextLost;
  84354. private _onContextRestored;
  84355. private _contextWasLost;
  84356. private _doNotHandleContextLost;
  84357. /**
  84358. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  84359. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  84360. */
  84361. doNotHandleContextLost: boolean;
  84362. private _performanceMonitor;
  84363. private _fps;
  84364. private _deltaTime;
  84365. /**
  84366. * Turn this value on if you want to pause FPS computation when in background
  84367. */
  84368. disablePerformanceMonitorInBackground: boolean;
  84369. /**
  84370. * Gets the performance monitor attached to this engine
  84371. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  84372. */
  84373. readonly performanceMonitor: PerformanceMonitor;
  84374. /** @hidden */
  84375. protected _depthCullingState: _DepthCullingState;
  84376. /** @hidden */
  84377. protected _stencilState: _StencilState;
  84378. /** @hidden */
  84379. protected _alphaState: _AlphaState;
  84380. /** @hidden */
  84381. protected _alphaMode: number;
  84382. protected _internalTexturesCache: InternalTexture[];
  84383. /** @hidden */
  84384. protected _activeChannel: number;
  84385. private _currentTextureChannel;
  84386. /** @hidden */
  84387. protected _boundTexturesCache: {
  84388. [key: string]: Nullable<InternalTexture>;
  84389. };
  84390. /** @hidden */
  84391. protected _currentEffect: Nullable<Effect>;
  84392. /** @hidden */
  84393. protected _currentProgram: Nullable<WebGLProgram>;
  84394. private _compiledEffects;
  84395. private _vertexAttribArraysEnabled;
  84396. /** @hidden */
  84397. protected _cachedViewport: Nullable<Viewport>;
  84398. private _cachedVertexArrayObject;
  84399. /** @hidden */
  84400. protected _cachedVertexBuffers: any;
  84401. /** @hidden */
  84402. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  84403. /** @hidden */
  84404. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  84405. /** @hidden */
  84406. protected _currentRenderTarget: Nullable<InternalTexture>;
  84407. private _uintIndicesCurrentlySet;
  84408. private _currentBoundBuffer;
  84409. /** @hidden */
  84410. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  84411. private _currentBufferPointers;
  84412. private _currentInstanceLocations;
  84413. private _currentInstanceBuffers;
  84414. private _textureUnits;
  84415. private _firstBoundInternalTextureTracker;
  84416. private _lastBoundInternalTextureTracker;
  84417. private _workingCanvas;
  84418. private _workingContext;
  84419. private _rescalePostProcess;
  84420. private _dummyFramebuffer;
  84421. private _externalData;
  84422. private _bindedRenderFunction;
  84423. private _vaoRecordInProgress;
  84424. private _mustWipeVertexAttributes;
  84425. private _emptyTexture;
  84426. private _emptyCubeTexture;
  84427. private _emptyTexture3D;
  84428. /** @hidden */
  84429. _frameHandler: number;
  84430. private _nextFreeTextureSlots;
  84431. private _maxSimultaneousTextures;
  84432. private _activeRequests;
  84433. private _texturesSupported;
  84434. private _textureFormatInUse;
  84435. /**
  84436. * Gets the list of texture formats supported
  84437. */
  84438. readonly texturesSupported: Array<string>;
  84439. /**
  84440. * Gets the list of texture formats in use
  84441. */
  84442. readonly textureFormatInUse: Nullable<string>;
  84443. /**
  84444. * Gets the current viewport
  84445. */
  84446. readonly currentViewport: Nullable<Viewport>;
  84447. /**
  84448. * Gets the default empty texture
  84449. */
  84450. readonly emptyTexture: InternalTexture;
  84451. /**
  84452. * Gets the default empty 3D texture
  84453. */
  84454. readonly emptyTexture3D: InternalTexture;
  84455. /**
  84456. * Gets the default empty cube texture
  84457. */
  84458. readonly emptyCubeTexture: InternalTexture;
  84459. /**
  84460. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  84461. */
  84462. readonly premultipliedAlpha: boolean;
  84463. /**
  84464. * Creates a new engine
  84465. * @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
  84466. * @param antialias defines enable antialiasing (default: false)
  84467. * @param options defines further options to be sent to the getContext() function
  84468. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  84469. */
  84470. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  84471. private _disableTouchAction;
  84472. private _rebuildInternalTextures;
  84473. private _rebuildEffects;
  84474. /**
  84475. * Gets a boolean indicating if all created effects are ready
  84476. * @returns true if all effects are ready
  84477. */
  84478. areAllEffectsReady(): boolean;
  84479. private _rebuildBuffers;
  84480. private _initGLContext;
  84481. /**
  84482. * Gets version of the current webGL context
  84483. */
  84484. readonly webGLVersion: number;
  84485. /**
  84486. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  84487. */
  84488. readonly isStencilEnable: boolean;
  84489. private _prepareWorkingCanvas;
  84490. /**
  84491. * Reset the texture cache to empty state
  84492. */
  84493. resetTextureCache(): void;
  84494. /**
  84495. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  84496. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84497. * @returns true if engine is in deterministic lock step mode
  84498. */
  84499. isDeterministicLockStep(): boolean;
  84500. /**
  84501. * Gets the max steps when engine is running in deterministic lock step
  84502. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84503. * @returns the max steps
  84504. */
  84505. getLockstepMaxSteps(): number;
  84506. /**
  84507. * Gets an object containing information about the current webGL context
  84508. * @returns an object containing the vender, the renderer and the version of the current webGL context
  84509. */
  84510. getGlInfo(): {
  84511. vendor: string;
  84512. renderer: string;
  84513. version: string;
  84514. };
  84515. /**
  84516. * Gets current aspect ratio
  84517. * @param camera defines the camera to use to get the aspect ratio
  84518. * @param useScreen defines if screen size must be used (or the current render target if any)
  84519. * @returns a number defining the aspect ratio
  84520. */
  84521. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  84522. /**
  84523. * Gets current screen aspect ratio
  84524. * @returns a number defining the aspect ratio
  84525. */
  84526. getScreenAspectRatio(): number;
  84527. /**
  84528. * Gets the current render width
  84529. * @param useScreen defines if screen size must be used (or the current render target if any)
  84530. * @returns a number defining the current render width
  84531. */
  84532. getRenderWidth(useScreen?: boolean): number;
  84533. /**
  84534. * Gets the current render height
  84535. * @param useScreen defines if screen size must be used (or the current render target if any)
  84536. * @returns a number defining the current render height
  84537. */
  84538. getRenderHeight(useScreen?: boolean): number;
  84539. /**
  84540. * Gets the HTML canvas attached with the current webGL context
  84541. * @returns a HTML canvas
  84542. */
  84543. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  84544. /**
  84545. * Gets the client rect of the HTML canvas attached with the current webGL context
  84546. * @returns a client rectanglee
  84547. */
  84548. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  84549. /**
  84550. * Defines the hardware scaling level.
  84551. * By default the hardware scaling level is computed from the window device ratio.
  84552. * 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.
  84553. * @param level defines the level to use
  84554. */
  84555. setHardwareScalingLevel(level: number): void;
  84556. /**
  84557. * Gets the current hardware scaling level.
  84558. * By default the hardware scaling level is computed from the window device ratio.
  84559. * 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.
  84560. * @returns a number indicating the current hardware scaling level
  84561. */
  84562. getHardwareScalingLevel(): number;
  84563. /**
  84564. * Gets the list of loaded textures
  84565. * @returns an array containing all loaded textures
  84566. */
  84567. getLoadedTexturesCache(): InternalTexture[];
  84568. /**
  84569. * Gets the object containing all engine capabilities
  84570. * @returns the EngineCapabilities object
  84571. */
  84572. getCaps(): EngineCapabilities;
  84573. /**
  84574. * Gets the current depth function
  84575. * @returns a number defining the depth function
  84576. */
  84577. getDepthFunction(): Nullable<number>;
  84578. /**
  84579. * Sets the current depth function
  84580. * @param depthFunc defines the function to use
  84581. */
  84582. setDepthFunction(depthFunc: number): void;
  84583. /**
  84584. * Sets the current depth function to GREATER
  84585. */
  84586. setDepthFunctionToGreater(): void;
  84587. /**
  84588. * Sets the current depth function to GEQUAL
  84589. */
  84590. setDepthFunctionToGreaterOrEqual(): void;
  84591. /**
  84592. * Sets the current depth function to LESS
  84593. */
  84594. setDepthFunctionToLess(): void;
  84595. /**
  84596. * Sets the current depth function to LEQUAL
  84597. */
  84598. setDepthFunctionToLessOrEqual(): void;
  84599. /**
  84600. * Gets a boolean indicating if stencil buffer is enabled
  84601. * @returns the current stencil buffer state
  84602. */
  84603. getStencilBuffer(): boolean;
  84604. /**
  84605. * Enable or disable the stencil buffer
  84606. * @param enable defines if the stencil buffer must be enabled or disabled
  84607. */
  84608. setStencilBuffer(enable: boolean): void;
  84609. /**
  84610. * Gets the current stencil mask
  84611. * @returns a number defining the new stencil mask to use
  84612. */
  84613. getStencilMask(): number;
  84614. /**
  84615. * Sets the current stencil mask
  84616. * @param mask defines the new stencil mask to use
  84617. */
  84618. setStencilMask(mask: number): void;
  84619. /**
  84620. * Gets the current stencil function
  84621. * @returns a number defining the stencil function to use
  84622. */
  84623. getStencilFunction(): number;
  84624. /**
  84625. * Gets the current stencil reference value
  84626. * @returns a number defining the stencil reference value to use
  84627. */
  84628. getStencilFunctionReference(): number;
  84629. /**
  84630. * Gets the current stencil mask
  84631. * @returns a number defining the stencil mask to use
  84632. */
  84633. getStencilFunctionMask(): number;
  84634. /**
  84635. * Sets the current stencil function
  84636. * @param stencilFunc defines the new stencil function to use
  84637. */
  84638. setStencilFunction(stencilFunc: number): void;
  84639. /**
  84640. * Sets the current stencil reference
  84641. * @param reference defines the new stencil reference to use
  84642. */
  84643. setStencilFunctionReference(reference: number): void;
  84644. /**
  84645. * Sets the current stencil mask
  84646. * @param mask defines the new stencil mask to use
  84647. */
  84648. setStencilFunctionMask(mask: number): void;
  84649. /**
  84650. * Gets the current stencil operation when stencil fails
  84651. * @returns a number defining stencil operation to use when stencil fails
  84652. */
  84653. getStencilOperationFail(): number;
  84654. /**
  84655. * Gets the current stencil operation when depth fails
  84656. * @returns a number defining stencil operation to use when depth fails
  84657. */
  84658. getStencilOperationDepthFail(): number;
  84659. /**
  84660. * Gets the current stencil operation when stencil passes
  84661. * @returns a number defining stencil operation to use when stencil passes
  84662. */
  84663. getStencilOperationPass(): number;
  84664. /**
  84665. * Sets the stencil operation to use when stencil fails
  84666. * @param operation defines the stencil operation to use when stencil fails
  84667. */
  84668. setStencilOperationFail(operation: number): void;
  84669. /**
  84670. * Sets the stencil operation to use when depth fails
  84671. * @param operation defines the stencil operation to use when depth fails
  84672. */
  84673. setStencilOperationDepthFail(operation: number): void;
  84674. /**
  84675. * Sets the stencil operation to use when stencil passes
  84676. * @param operation defines the stencil operation to use when stencil passes
  84677. */
  84678. setStencilOperationPass(operation: number): void;
  84679. /**
  84680. * Sets a boolean indicating if the dithering state is enabled or disabled
  84681. * @param value defines the dithering state
  84682. */
  84683. setDitheringState(value: boolean): void;
  84684. /**
  84685. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  84686. * @param value defines the rasterizer state
  84687. */
  84688. setRasterizerState(value: boolean): void;
  84689. /**
  84690. * stop executing a render loop function and remove it from the execution array
  84691. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  84692. */
  84693. stopRenderLoop(renderFunction?: () => void): void;
  84694. /** @hidden */
  84695. _renderLoop(): void;
  84696. /**
  84697. * Register and execute a render loop. The engine can have more than one render function
  84698. * @param renderFunction defines the function to continuously execute
  84699. */
  84700. runRenderLoop(renderFunction: () => void): void;
  84701. /**
  84702. * Toggle full screen mode
  84703. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84704. */
  84705. switchFullscreen(requestPointerLock: boolean): void;
  84706. /**
  84707. * Enters full screen mode
  84708. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84709. */
  84710. enterFullscreen(requestPointerLock: boolean): void;
  84711. /**
  84712. * Exits full screen mode
  84713. */
  84714. exitFullscreen(): void;
  84715. /**
  84716. * Clear the current render buffer or the current render target (if any is set up)
  84717. * @param color defines the color to use
  84718. * @param backBuffer defines if the back buffer must be cleared
  84719. * @param depth defines if the depth buffer must be cleared
  84720. * @param stencil defines if the stencil buffer must be cleared
  84721. */
  84722. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  84723. /**
  84724. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  84725. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84726. * @param y defines the y-coordinate of the corner of the clear rectangle
  84727. * @param width defines the width of the clear rectangle
  84728. * @param height defines the height of the clear rectangle
  84729. * @param clearColor defines the clear color
  84730. */
  84731. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  84732. /**
  84733. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  84734. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84735. * @param y defines the y-coordinate of the corner of the clear rectangle
  84736. * @param width defines the width of the clear rectangle
  84737. * @param height defines the height of the clear rectangle
  84738. */
  84739. enableScissor(x: number, y: number, width: number, height: number): void;
  84740. /**
  84741. * Disable previously set scissor test rectangle
  84742. */
  84743. disableScissor(): void;
  84744. private _viewportCached;
  84745. /** @hidden */
  84746. _viewport(x: number, y: number, width: number, height: number): void;
  84747. /**
  84748. * Set the WebGL's viewport
  84749. * @param viewport defines the viewport element to be used
  84750. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  84751. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  84752. */
  84753. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  84754. /**
  84755. * Directly set the WebGL Viewport
  84756. * @param x defines the x coordinate of the viewport (in screen space)
  84757. * @param y defines the y coordinate of the viewport (in screen space)
  84758. * @param width defines the width of the viewport (in screen space)
  84759. * @param height defines the height of the viewport (in screen space)
  84760. * @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
  84761. */
  84762. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  84763. /**
  84764. * Begin a new frame
  84765. */
  84766. beginFrame(): void;
  84767. /**
  84768. * Enf the current frame
  84769. */
  84770. endFrame(): void;
  84771. /**
  84772. * Resize the view according to the canvas' size
  84773. */
  84774. resize(): void;
  84775. /**
  84776. * Force a specific size of the canvas
  84777. * @param width defines the new canvas' width
  84778. * @param height defines the new canvas' height
  84779. */
  84780. setSize(width: number, height: number): void;
  84781. /**
  84782. * Gets a boolean indicating if a webVR device was detected
  84783. * @returns true if a webVR device was detected
  84784. */
  84785. isVRDevicePresent(): boolean;
  84786. /**
  84787. * Gets the current webVR device
  84788. * @returns the current webVR device (or null)
  84789. */
  84790. getVRDevice(): any;
  84791. /**
  84792. * Initializes a webVR display and starts listening to display change events
  84793. * The onVRDisplayChangedObservable will be notified upon these changes
  84794. * @returns The onVRDisplayChangedObservable
  84795. */
  84796. initWebVR(): Observable<IDisplayChangedEventArgs>;
  84797. /**
  84798. * Initializes a webVR display and starts listening to display change events
  84799. * The onVRDisplayChangedObservable will be notified upon these changes
  84800. * @returns A promise containing a VRDisplay and if vr is supported
  84801. */
  84802. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  84803. /**
  84804. * Call this function to switch to webVR mode
  84805. * Will do nothing if webVR is not supported or if there is no webVR device
  84806. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84807. */
  84808. enableVR(): void;
  84809. /**
  84810. * Call this function to leave webVR mode
  84811. * Will do nothing if webVR is not supported or if there is no webVR device
  84812. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84813. */
  84814. disableVR(): void;
  84815. private _onVRFullScreenTriggered;
  84816. private _getVRDisplaysAsync;
  84817. /**
  84818. * Binds the frame buffer to the specified texture.
  84819. * @param texture The texture to render to or null for the default canvas
  84820. * @param faceIndex The face of the texture to render to in case of cube texture
  84821. * @param requiredWidth The width of the target to render to
  84822. * @param requiredHeight The height of the target to render to
  84823. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  84824. * @param depthStencilTexture The depth stencil texture to use to render
  84825. * @param lodLevel defines le lod level to bind to the frame buffer
  84826. */
  84827. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  84828. private bindUnboundFramebuffer;
  84829. /**
  84830. * Unbind the current render target texture from the webGL context
  84831. * @param texture defines the render target texture to unbind
  84832. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84833. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84834. */
  84835. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84836. /**
  84837. * Unbind a list of render target textures from the webGL context
  84838. * This is used only when drawBuffer extension or webGL2 are active
  84839. * @param textures defines the render target textures to unbind
  84840. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84841. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84842. */
  84843. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84844. /**
  84845. * Force the mipmap generation for the given render target texture
  84846. * @param texture defines the render target texture to use
  84847. */
  84848. generateMipMapsForCubemap(texture: InternalTexture): void;
  84849. /**
  84850. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  84851. */
  84852. flushFramebuffer(): void;
  84853. /**
  84854. * Unbind the current render target and bind the default framebuffer
  84855. */
  84856. restoreDefaultFramebuffer(): void;
  84857. /**
  84858. * Create an uniform buffer
  84859. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84860. * @param elements defines the content of the uniform buffer
  84861. * @returns the webGL uniform buffer
  84862. */
  84863. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  84864. /**
  84865. * Create a dynamic uniform buffer
  84866. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84867. * @param elements defines the content of the uniform buffer
  84868. * @returns the webGL uniform buffer
  84869. */
  84870. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  84871. /**
  84872. * Update an existing uniform buffer
  84873. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84874. * @param uniformBuffer defines the target uniform buffer
  84875. * @param elements defines the content to update
  84876. * @param offset defines the offset in the uniform buffer where update should start
  84877. * @param count defines the size of the data to update
  84878. */
  84879. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84880. private _resetVertexBufferBinding;
  84881. /**
  84882. * Creates a vertex buffer
  84883. * @param data the data for the vertex buffer
  84884. * @returns the new WebGL static buffer
  84885. */
  84886. createVertexBuffer(data: DataArray): WebGLBuffer;
  84887. /**
  84888. * Creates a dynamic vertex buffer
  84889. * @param data the data for the dynamic vertex buffer
  84890. * @returns the new WebGL dynamic buffer
  84891. */
  84892. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  84893. /**
  84894. * Update a dynamic index buffer
  84895. * @param indexBuffer defines the target index buffer
  84896. * @param indices defines the data to update
  84897. * @param offset defines the offset in the target index buffer where update should start
  84898. */
  84899. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  84900. /**
  84901. * Updates a dynamic vertex buffer.
  84902. * @param vertexBuffer the vertex buffer to update
  84903. * @param data the data used to update the vertex buffer
  84904. * @param byteOffset the byte offset of the data
  84905. * @param byteLength the byte length of the data
  84906. */
  84907. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  84908. private _resetIndexBufferBinding;
  84909. /**
  84910. * Creates a new index buffer
  84911. * @param indices defines the content of the index buffer
  84912. * @param updatable defines if the index buffer must be updatable
  84913. * @returns a new webGL buffer
  84914. */
  84915. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  84916. /**
  84917. * Bind a webGL buffer to the webGL context
  84918. * @param buffer defines the buffer to bind
  84919. */
  84920. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  84921. /**
  84922. * Bind an uniform buffer to the current webGL context
  84923. * @param buffer defines the buffer to bind
  84924. */
  84925. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  84926. /**
  84927. * Bind a buffer to the current webGL context at a given location
  84928. * @param buffer defines the buffer to bind
  84929. * @param location defines the index where to bind the buffer
  84930. */
  84931. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  84932. /**
  84933. * Bind a specific block at a given index in a specific shader program
  84934. * @param shaderProgram defines the shader program
  84935. * @param blockName defines the block name
  84936. * @param index defines the index where to bind the block
  84937. */
  84938. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  84939. private bindIndexBuffer;
  84940. private bindBuffer;
  84941. /**
  84942. * update the bound buffer with the given data
  84943. * @param data defines the data to update
  84944. */
  84945. updateArrayBuffer(data: Float32Array): void;
  84946. private _vertexAttribPointer;
  84947. private _bindIndexBufferWithCache;
  84948. private _bindVertexBuffersAttributes;
  84949. /**
  84950. * Records a vertex array object
  84951. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84952. * @param vertexBuffers defines the list of vertex buffers to store
  84953. * @param indexBuffer defines the index buffer to store
  84954. * @param effect defines the effect to store
  84955. * @returns the new vertex array object
  84956. */
  84957. recordVertexArrayObject(vertexBuffers: {
  84958. [key: string]: VertexBuffer;
  84959. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  84960. /**
  84961. * Bind a specific vertex array object
  84962. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84963. * @param vertexArrayObject defines the vertex array object to bind
  84964. * @param indexBuffer defines the index buffer to bind
  84965. */
  84966. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  84967. /**
  84968. * Bind webGl buffers directly to the webGL context
  84969. * @param vertexBuffer defines the vertex buffer to bind
  84970. * @param indexBuffer defines the index buffer to bind
  84971. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  84972. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  84973. * @param effect defines the effect associated with the vertex buffer
  84974. */
  84975. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  84976. private _unbindVertexArrayObject;
  84977. /**
  84978. * Bind a list of vertex buffers to the webGL context
  84979. * @param vertexBuffers defines the list of vertex buffers to bind
  84980. * @param indexBuffer defines the index buffer to bind
  84981. * @param effect defines the effect associated with the vertex buffers
  84982. */
  84983. bindBuffers(vertexBuffers: {
  84984. [key: string]: Nullable<VertexBuffer>;
  84985. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  84986. /**
  84987. * Unbind all instance attributes
  84988. */
  84989. unbindInstanceAttributes(): void;
  84990. /**
  84991. * Release and free the memory of a vertex array object
  84992. * @param vao defines the vertex array object to delete
  84993. */
  84994. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  84995. /** @hidden */
  84996. _releaseBuffer(buffer: WebGLBuffer): boolean;
  84997. /**
  84998. * Creates a webGL buffer to use with instanciation
  84999. * @param capacity defines the size of the buffer
  85000. * @returns the webGL buffer
  85001. */
  85002. createInstancesBuffer(capacity: number): WebGLBuffer;
  85003. /**
  85004. * Delete a webGL buffer used with instanciation
  85005. * @param buffer defines the webGL buffer to delete
  85006. */
  85007. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  85008. /**
  85009. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  85010. * @param instancesBuffer defines the webGL buffer to update and bind
  85011. * @param data defines the data to store in the buffer
  85012. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  85013. */
  85014. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  85015. /**
  85016. * Apply all cached states (depth, culling, stencil and alpha)
  85017. */
  85018. applyStates(): void;
  85019. /**
  85020. * Send a draw order
  85021. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  85022. * @param indexStart defines the starting index
  85023. * @param indexCount defines the number of index to draw
  85024. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85025. */
  85026. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  85027. /**
  85028. * Draw a list of points
  85029. * @param verticesStart defines the index of first vertex to draw
  85030. * @param verticesCount defines the count of vertices to draw
  85031. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85032. */
  85033. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85034. /**
  85035. * Draw a list of unindexed primitives
  85036. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  85037. * @param verticesStart defines the index of first vertex to draw
  85038. * @param verticesCount defines the count of vertices to draw
  85039. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85040. */
  85041. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85042. /**
  85043. * Draw a list of indexed primitives
  85044. * @param fillMode defines the primitive to use
  85045. * @param indexStart defines the starting index
  85046. * @param indexCount defines the number of index to draw
  85047. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85048. */
  85049. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  85050. /**
  85051. * Draw a list of unindexed primitives
  85052. * @param fillMode defines the primitive to use
  85053. * @param verticesStart defines the index of first vertex to draw
  85054. * @param verticesCount defines the count of vertices to draw
  85055. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85056. */
  85057. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85058. private _drawMode;
  85059. /** @hidden */
  85060. _releaseEffect(effect: Effect): void;
  85061. /** @hidden */
  85062. _deleteProgram(program: WebGLProgram): void;
  85063. /**
  85064. * Create a new effect (used to store vertex/fragment shaders)
  85065. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  85066. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  85067. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  85068. * @param samplers defines an array of string used to represent textures
  85069. * @param defines defines the string containing the defines to use to compile the shaders
  85070. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  85071. * @param onCompiled defines a function to call when the effect creation is successful
  85072. * @param onError defines a function to call when the effect creation has failed
  85073. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  85074. * @returns the new Effect
  85075. */
  85076. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  85077. private _compileShader;
  85078. private _compileRawShader;
  85079. /**
  85080. * Directly creates a webGL program
  85081. * @param vertexCode defines the vertex shader code to use
  85082. * @param fragmentCode defines the fragment shader code to use
  85083. * @param context defines the webGL context to use (if not set, the current one will be used)
  85084. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  85085. * @returns the new webGL program
  85086. */
  85087. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  85088. /**
  85089. * Creates a webGL program
  85090. * @param vertexCode defines the vertex shader code to use
  85091. * @param fragmentCode defines the fragment shader code to use
  85092. * @param defines defines the string containing the defines to use to compile the shaders
  85093. * @param context defines the webGL context to use (if not set, the current one will be used)
  85094. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  85095. * @returns the new webGL program
  85096. */
  85097. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  85098. private _createShaderProgram;
  85099. private _finalizeProgram;
  85100. /** @hidden */
  85101. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  85102. /** @hidden */
  85103. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  85104. /**
  85105. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  85106. * @param shaderProgram defines the webGL program to use
  85107. * @param uniformsNames defines the list of uniform names
  85108. * @returns an array of webGL uniform locations
  85109. */
  85110. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  85111. /**
  85112. * Gets the lsit of active attributes for a given webGL program
  85113. * @param shaderProgram defines the webGL program to use
  85114. * @param attributesNames defines the list of attribute names to get
  85115. * @returns an array of indices indicating the offset of each attribute
  85116. */
  85117. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  85118. /**
  85119. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  85120. * @param effect defines the effect to activate
  85121. */
  85122. enableEffect(effect: Nullable<Effect>): void;
  85123. /**
  85124. * Set the value of an uniform to an array of int32
  85125. * @param uniform defines the webGL uniform location where to store the value
  85126. * @param array defines the array of int32 to store
  85127. */
  85128. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85129. /**
  85130. * Set the value of an uniform to an array of int32 (stored as vec2)
  85131. * @param uniform defines the webGL uniform location where to store the value
  85132. * @param array defines the array of int32 to store
  85133. */
  85134. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85135. /**
  85136. * Set the value of an uniform to an array of int32 (stored as vec3)
  85137. * @param uniform defines the webGL uniform location where to store the value
  85138. * @param array defines the array of int32 to store
  85139. */
  85140. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85141. /**
  85142. * Set the value of an uniform to an array of int32 (stored as vec4)
  85143. * @param uniform defines the webGL uniform location where to store the value
  85144. * @param array defines the array of int32 to store
  85145. */
  85146. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85147. /**
  85148. * Set the value of an uniform to an array of float32
  85149. * @param uniform defines the webGL uniform location where to store the value
  85150. * @param array defines the array of float32 to store
  85151. */
  85152. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85153. /**
  85154. * Set the value of an uniform to an array of float32 (stored as vec2)
  85155. * @param uniform defines the webGL uniform location where to store the value
  85156. * @param array defines the array of float32 to store
  85157. */
  85158. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85159. /**
  85160. * Set the value of an uniform to an array of float32 (stored as vec3)
  85161. * @param uniform defines the webGL uniform location where to store the value
  85162. * @param array defines the array of float32 to store
  85163. */
  85164. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85165. /**
  85166. * Set the value of an uniform to an array of float32 (stored as vec4)
  85167. * @param uniform defines the webGL uniform location where to store the value
  85168. * @param array defines the array of float32 to store
  85169. */
  85170. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85171. /**
  85172. * Set the value of an uniform to an array of number
  85173. * @param uniform defines the webGL uniform location where to store the value
  85174. * @param array defines the array of number to store
  85175. */
  85176. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85177. /**
  85178. * Set the value of an uniform to an array of number (stored as vec2)
  85179. * @param uniform defines the webGL uniform location where to store the value
  85180. * @param array defines the array of number to store
  85181. */
  85182. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85183. /**
  85184. * Set the value of an uniform to an array of number (stored as vec3)
  85185. * @param uniform defines the webGL uniform location where to store the value
  85186. * @param array defines the array of number to store
  85187. */
  85188. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85189. /**
  85190. * Set the value of an uniform to an array of number (stored as vec4)
  85191. * @param uniform defines the webGL uniform location where to store the value
  85192. * @param array defines the array of number to store
  85193. */
  85194. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85195. /**
  85196. * Set the value of an uniform to an array of float32 (stored as matrices)
  85197. * @param uniform defines the webGL uniform location where to store the value
  85198. * @param matrices defines the array of float32 to store
  85199. */
  85200. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  85201. /**
  85202. * Set the value of an uniform to a matrix
  85203. * @param uniform defines the webGL uniform location where to store the value
  85204. * @param matrix defines the matrix to store
  85205. */
  85206. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  85207. /**
  85208. * Set the value of an uniform to a matrix (3x3)
  85209. * @param uniform defines the webGL uniform location where to store the value
  85210. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  85211. */
  85212. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  85213. /**
  85214. * Set the value of an uniform to a matrix (2x2)
  85215. * @param uniform defines the webGL uniform location where to store the value
  85216. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  85217. */
  85218. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  85219. /**
  85220. * Set the value of an uniform to a number (int)
  85221. * @param uniform defines the webGL uniform location where to store the value
  85222. * @param value defines the int number to store
  85223. */
  85224. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  85225. /**
  85226. * Set the value of an uniform to a number (float)
  85227. * @param uniform defines the webGL uniform location where to store the value
  85228. * @param value defines the float number to store
  85229. */
  85230. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  85231. /**
  85232. * Set the value of an uniform to a vec2
  85233. * @param uniform defines the webGL uniform location where to store the value
  85234. * @param x defines the 1st component of the value
  85235. * @param y defines the 2nd component of the value
  85236. */
  85237. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  85238. /**
  85239. * Set the value of an uniform to a vec3
  85240. * @param uniform defines the webGL uniform location where to store the value
  85241. * @param x defines the 1st component of the value
  85242. * @param y defines the 2nd component of the value
  85243. * @param z defines the 3rd component of the value
  85244. */
  85245. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  85246. /**
  85247. * Set the value of an uniform to a boolean
  85248. * @param uniform defines the webGL uniform location where to store the value
  85249. * @param bool defines the boolean to store
  85250. */
  85251. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  85252. /**
  85253. * Set the value of an uniform to a vec4
  85254. * @param uniform defines the webGL uniform location where to store the value
  85255. * @param x defines the 1st component of the value
  85256. * @param y defines the 2nd component of the value
  85257. * @param z defines the 3rd component of the value
  85258. * @param w defines the 4th component of the value
  85259. */
  85260. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  85261. /**
  85262. * Set the value of an uniform to a Color3
  85263. * @param uniform defines the webGL uniform location where to store the value
  85264. * @param color3 defines the color to store
  85265. */
  85266. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  85267. /**
  85268. * Set the value of an uniform to a Color3 and an alpha value
  85269. * @param uniform defines the webGL uniform location where to store the value
  85270. * @param color3 defines the color to store
  85271. * @param alpha defines the alpha component to store
  85272. */
  85273. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  85274. /**
  85275. * Sets a Color4 on a uniform variable
  85276. * @param uniform defines the uniform location
  85277. * @param color4 defines the value to be set
  85278. */
  85279. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  85280. /**
  85281. * Set various states to the webGL context
  85282. * @param culling defines backface culling state
  85283. * @param zOffset defines the value to apply to zOffset (0 by default)
  85284. * @param force defines if states must be applied even if cache is up to date
  85285. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  85286. */
  85287. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  85288. /**
  85289. * Set the z offset to apply to current rendering
  85290. * @param value defines the offset to apply
  85291. */
  85292. setZOffset(value: number): void;
  85293. /**
  85294. * Gets the current value of the zOffset
  85295. * @returns the current zOffset state
  85296. */
  85297. getZOffset(): number;
  85298. /**
  85299. * Enable or disable depth buffering
  85300. * @param enable defines the state to set
  85301. */
  85302. setDepthBuffer(enable: boolean): void;
  85303. /**
  85304. * Gets a boolean indicating if depth writing is enabled
  85305. * @returns the current depth writing state
  85306. */
  85307. getDepthWrite(): boolean;
  85308. /**
  85309. * Enable or disable depth writing
  85310. * @param enable defines the state to set
  85311. */
  85312. setDepthWrite(enable: boolean): void;
  85313. /**
  85314. * Enable or disable color writing
  85315. * @param enable defines the state to set
  85316. */
  85317. setColorWrite(enable: boolean): void;
  85318. /**
  85319. * Gets a boolean indicating if color writing is enabled
  85320. * @returns the current color writing state
  85321. */
  85322. getColorWrite(): boolean;
  85323. /**
  85324. * Sets alpha constants used by some alpha blending modes
  85325. * @param r defines the red component
  85326. * @param g defines the green component
  85327. * @param b defines the blue component
  85328. * @param a defines the alpha component
  85329. */
  85330. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  85331. /**
  85332. * Sets the current alpha mode
  85333. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  85334. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  85335. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85336. */
  85337. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  85338. /**
  85339. * Gets the current alpha mode
  85340. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85341. * @returns the current alpha mode
  85342. */
  85343. getAlphaMode(): number;
  85344. /**
  85345. * Clears the list of texture accessible through engine.
  85346. * This can help preventing texture load conflict due to name collision.
  85347. */
  85348. clearInternalTexturesCache(): void;
  85349. /**
  85350. * Force the entire cache to be cleared
  85351. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  85352. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  85353. */
  85354. wipeCaches(bruteForce?: boolean): void;
  85355. /**
  85356. * Set the compressed texture format to use, based on the formats you have, and the formats
  85357. * supported by the hardware / browser.
  85358. *
  85359. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  85360. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  85361. * to API arguments needed to compressed textures. This puts the burden on the container
  85362. * generator to house the arcane code for determining these for current & future formats.
  85363. *
  85364. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  85365. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  85366. *
  85367. * Note: The result of this call is not taken into account when a texture is base64.
  85368. *
  85369. * @param formatsAvailable defines the list of those format families you have created
  85370. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  85371. *
  85372. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  85373. * @returns The extension selected.
  85374. */
  85375. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  85376. private _getSamplingParameters;
  85377. private _partialLoadImg;
  85378. private _cascadeLoadImgs;
  85379. /** @hidden */
  85380. _createTexture(): WebGLTexture;
  85381. /**
  85382. * Usually called from Texture.ts.
  85383. * Passed information to create a WebGLTexture
  85384. * @param urlArg defines a value which contains one of the following:
  85385. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  85386. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  85387. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  85388. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  85389. * @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)
  85390. * @param scene needed for loading to the correct scene
  85391. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  85392. * @param onLoad optional callback to be called upon successful completion
  85393. * @param onError optional callback to be called upon failure
  85394. * @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
  85395. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  85396. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  85397. * @param forcedExtension defines the extension to use to pick the right loader
  85398. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  85399. * @returns a InternalTexture for assignment back into BABYLON.Texture
  85400. */
  85401. 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;
  85402. private _rescaleTexture;
  85403. /**
  85404. * Update a raw texture
  85405. * @param texture defines the texture to update
  85406. * @param data defines the data to store in the texture
  85407. * @param format defines the format of the data
  85408. * @param invertY defines if data must be stored with Y axis inverted
  85409. * @param compression defines the compression used (null by default)
  85410. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85411. */
  85412. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  85413. /**
  85414. * Creates a raw texture
  85415. * @param data defines the data to store in the texture
  85416. * @param width defines the width of the texture
  85417. * @param height defines the height of the texture
  85418. * @param format defines the format of the data
  85419. * @param generateMipMaps defines if the engine should generate the mip levels
  85420. * @param invertY defines if data must be stored with Y axis inverted
  85421. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85422. * @param compression defines the compression used (null by default)
  85423. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85424. * @returns the raw texture inside an InternalTexture
  85425. */
  85426. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  85427. private _unpackFlipYCached;
  85428. /**
  85429. * In case you are sharing the context with other applications, it might
  85430. * be interested to not cache the unpack flip y state to ensure a consistent
  85431. * value would be set.
  85432. */
  85433. enableUnpackFlipYCached: boolean;
  85434. /** @hidden */
  85435. _unpackFlipY(value: boolean): void;
  85436. /** @hidden */
  85437. _getUnpackAlignement(): number;
  85438. /**
  85439. * Creates a dynamic texture
  85440. * @param width defines the width of the texture
  85441. * @param height defines the height of the texture
  85442. * @param generateMipMaps defines if the engine should generate the mip levels
  85443. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85444. * @returns the dynamic texture inside an InternalTexture
  85445. */
  85446. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  85447. /**
  85448. * Update the sampling mode of a given texture
  85449. * @param samplingMode defines the required sampling mode
  85450. * @param texture defines the texture to update
  85451. */
  85452. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  85453. /**
  85454. * Update the content of a dynamic texture
  85455. * @param texture defines the texture to update
  85456. * @param canvas defines the canvas containing the source
  85457. * @param invertY defines if data must be stored with Y axis inverted
  85458. * @param premulAlpha defines if alpha is stored as premultiplied
  85459. * @param format defines the format of the data
  85460. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  85461. */
  85462. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  85463. /**
  85464. * Update a video texture
  85465. * @param texture defines the texture to update
  85466. * @param video defines the video element to use
  85467. * @param invertY defines if data must be stored with Y axis inverted
  85468. */
  85469. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  85470. /**
  85471. * Updates a depth texture Comparison Mode and Function.
  85472. * If the comparison Function is equal to 0, the mode will be set to none.
  85473. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  85474. * @param texture The texture to set the comparison function for
  85475. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  85476. */
  85477. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  85478. private _setupDepthStencilTexture;
  85479. /**
  85480. * Creates a depth stencil texture.
  85481. * This is only available in WebGL 2 or with the depth texture extension available.
  85482. * @param size The size of face edge in the texture.
  85483. * @param options The options defining the texture.
  85484. * @returns The texture
  85485. */
  85486. createDepthStencilTexture(size: number | {
  85487. width: number;
  85488. height: number;
  85489. }, options: DepthTextureCreationOptions): InternalTexture;
  85490. /**
  85491. * Creates a depth stencil texture.
  85492. * This is only available in WebGL 2 or with the depth texture extension available.
  85493. * @param size The size of face edge in the texture.
  85494. * @param options The options defining the texture.
  85495. * @returns The texture
  85496. */
  85497. private _createDepthStencilTexture;
  85498. /**
  85499. * Creates a depth stencil cube texture.
  85500. * This is only available in WebGL 2.
  85501. * @param size The size of face edge in the cube texture.
  85502. * @param options The options defining the cube texture.
  85503. * @returns The cube texture
  85504. */
  85505. private _createDepthStencilCubeTexture;
  85506. /**
  85507. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  85508. * @param renderTarget The render target to set the frame buffer for
  85509. */
  85510. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  85511. /**
  85512. * Creates a new render target texture
  85513. * @param size defines the size of the texture
  85514. * @param options defines the options used to create the texture
  85515. * @returns a new render target texture stored in an InternalTexture
  85516. */
  85517. createRenderTargetTexture(size: number | {
  85518. width: number;
  85519. height: number;
  85520. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  85521. /**
  85522. * Create a multi render target texture
  85523. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  85524. * @param size defines the size of the texture
  85525. * @param options defines the creation options
  85526. * @returns the cube texture as an InternalTexture
  85527. */
  85528. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  85529. private _setupFramebufferDepthAttachments;
  85530. /**
  85531. * Updates the sample count of a render target texture
  85532. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85533. * @param texture defines the texture to update
  85534. * @param samples defines the sample count to set
  85535. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85536. */
  85537. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  85538. /**
  85539. * Update the sample count for a given multiple render target texture
  85540. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85541. * @param textures defines the textures to update
  85542. * @param samples defines the sample count to set
  85543. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85544. */
  85545. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  85546. /** @hidden */
  85547. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85548. /** @hidden */
  85549. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85550. /** @hidden */
  85551. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85552. /** @hidden */
  85553. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  85554. /**
  85555. * Creates a new render target cube texture
  85556. * @param size defines the size of the texture
  85557. * @param options defines the options used to create the texture
  85558. * @returns a new render target cube texture stored in an InternalTexture
  85559. */
  85560. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85561. /**
  85562. * Creates a cube texture
  85563. * @param rootUrl defines the url where the files to load is located
  85564. * @param scene defines the current scene
  85565. * @param files defines the list of files to load (1 per face)
  85566. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85567. * @param onLoad defines an optional callback raised when the texture is loaded
  85568. * @param onError defines an optional callback raised if there is an issue to load the texture
  85569. * @param format defines the format of the data
  85570. * @param forcedExtension defines the extension to use to pick the right loader
  85571. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85572. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85573. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85574. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85575. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  85576. * @returns the cube texture as an InternalTexture
  85577. */
  85578. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  85579. /**
  85580. * @hidden
  85581. */
  85582. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85583. /**
  85584. * Update a raw cube texture
  85585. * @param texture defines the texture to udpdate
  85586. * @param data defines the data to store
  85587. * @param format defines the data format
  85588. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85589. * @param invertY defines if data must be stored with Y axis inverted
  85590. * @param compression defines the compression used (null by default)
  85591. * @param level defines which level of the texture to update
  85592. */
  85593. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  85594. /**
  85595. * Creates a new raw cube texture
  85596. * @param data defines the array of data to use to create each face
  85597. * @param size defines the size of the textures
  85598. * @param format defines the format of the data
  85599. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85600. * @param generateMipMaps defines if the engine should generate the mip levels
  85601. * @param invertY defines if data must be stored with Y axis inverted
  85602. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85603. * @param compression defines the compression used (null by default)
  85604. * @returns the cube texture as an InternalTexture
  85605. */
  85606. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  85607. /**
  85608. * Creates a new raw cube texture from a specified url
  85609. * @param url defines the url where the data is located
  85610. * @param scene defines the current scene
  85611. * @param size defines the size of the textures
  85612. * @param format defines the format of the data
  85613. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85614. * @param noMipmap defines if the engine should avoid generating the mip levels
  85615. * @param callback defines a callback used to extract texture data from loaded data
  85616. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85617. * @param onLoad defines a callback called when texture is loaded
  85618. * @param onError defines a callback called if there is an error
  85619. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85620. * @param invertY defines if data must be stored with Y axis inverted
  85621. * @returns the cube texture as an InternalTexture
  85622. */
  85623. 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;
  85624. /**
  85625. * Update a raw 3D texture
  85626. * @param texture defines the texture to update
  85627. * @param data defines the data to store
  85628. * @param format defines the data format
  85629. * @param invertY defines if data must be stored with Y axis inverted
  85630. * @param compression defines the used compression (can be null)
  85631. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85632. */
  85633. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  85634. /**
  85635. * Creates a new raw 3D texture
  85636. * @param data defines the data used to create the texture
  85637. * @param width defines the width of the texture
  85638. * @param height defines the height of the texture
  85639. * @param depth defines the depth of the texture
  85640. * @param format defines the format of the texture
  85641. * @param generateMipMaps defines if the engine must generate mip levels
  85642. * @param invertY defines if data must be stored with Y axis inverted
  85643. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85644. * @param compression defines the compressed used (can be null)
  85645. * @param textureType defines the compressed used (can be null)
  85646. * @returns a new raw 3D texture (stored in an InternalTexture)
  85647. */
  85648. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  85649. private _prepareWebGLTextureContinuation;
  85650. private _prepareWebGLTexture;
  85651. private _convertRGBtoRGBATextureData;
  85652. /** @hidden */
  85653. _releaseFramebufferObjects(texture: InternalTexture): void;
  85654. /** @hidden */
  85655. _releaseTexture(texture: InternalTexture): void;
  85656. private setProgram;
  85657. private _boundUniforms;
  85658. /**
  85659. * Binds an effect to the webGL context
  85660. * @param effect defines the effect to bind
  85661. */
  85662. bindSamplers(effect: Effect): void;
  85663. private _moveBoundTextureOnTop;
  85664. private _getCorrectTextureChannel;
  85665. private _linkTrackers;
  85666. private _removeDesignatedSlot;
  85667. private _activateCurrentTexture;
  85668. /** @hidden */
  85669. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  85670. /** @hidden */
  85671. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  85672. /**
  85673. * Sets a texture to the webGL context from a postprocess
  85674. * @param channel defines the channel to use
  85675. * @param postProcess defines the source postprocess
  85676. */
  85677. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  85678. /**
  85679. * Binds the output of the passed in post process to the texture channel specified
  85680. * @param channel The channel the texture should be bound to
  85681. * @param postProcess The post process which's output should be bound
  85682. */
  85683. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  85684. /**
  85685. * Unbind all textures from the webGL context
  85686. */
  85687. unbindAllTextures(): void;
  85688. /**
  85689. * Sets a texture to the according uniform.
  85690. * @param channel The texture channel
  85691. * @param uniform The uniform to set
  85692. * @param texture The texture to apply
  85693. */
  85694. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  85695. /**
  85696. * Sets a depth stencil texture from a render target to the according uniform.
  85697. * @param channel The texture channel
  85698. * @param uniform The uniform to set
  85699. * @param texture The render target texture containing the depth stencil texture to apply
  85700. */
  85701. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  85702. private _bindSamplerUniformToChannel;
  85703. private _getTextureWrapMode;
  85704. private _setTexture;
  85705. /**
  85706. * Sets an array of texture to the webGL context
  85707. * @param channel defines the channel where the texture array must be set
  85708. * @param uniform defines the associated uniform location
  85709. * @param textures defines the array of textures to bind
  85710. */
  85711. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  85712. /** @hidden */
  85713. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  85714. private _setTextureParameterFloat;
  85715. private _setTextureParameterInteger;
  85716. /**
  85717. * Reads pixels from the current frame buffer. Please note that this function can be slow
  85718. * @param x defines the x coordinate of the rectangle where pixels must be read
  85719. * @param y defines the y coordinate of the rectangle where pixels must be read
  85720. * @param width defines the width of the rectangle where pixels must be read
  85721. * @param height defines the height of the rectangle where pixels must be read
  85722. * @returns a Uint8Array containing RGBA colors
  85723. */
  85724. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  85725. /**
  85726. * Add an externaly attached data from its key.
  85727. * This method call will fail and return false, if such key already exists.
  85728. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  85729. * @param key the unique key that identifies the data
  85730. * @param data the data object to associate to the key for this Engine instance
  85731. * @return true if no such key were already present and the data was added successfully, false otherwise
  85732. */
  85733. addExternalData<T>(key: string, data: T): boolean;
  85734. /**
  85735. * Get an externaly attached data from its key
  85736. * @param key the unique key that identifies the data
  85737. * @return the associated data, if present (can be null), or undefined if not present
  85738. */
  85739. getExternalData<T>(key: string): T;
  85740. /**
  85741. * Get an externaly attached data from its key, create it using a factory if it's not already present
  85742. * @param key the unique key that identifies the data
  85743. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  85744. * @return the associated data, can be null if the factory returned null.
  85745. */
  85746. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  85747. /**
  85748. * Remove an externaly attached data from the Engine instance
  85749. * @param key the unique key that identifies the data
  85750. * @return true if the data was successfully removed, false if it doesn't exist
  85751. */
  85752. removeExternalData(key: string): boolean;
  85753. /**
  85754. * Unbind all vertex attributes from the webGL context
  85755. */
  85756. unbindAllAttributes(): void;
  85757. /**
  85758. * 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
  85759. */
  85760. releaseEffects(): void;
  85761. /**
  85762. * Dispose and release all associated resources
  85763. */
  85764. dispose(): void;
  85765. /**
  85766. * Display the loading screen
  85767. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85768. */
  85769. displayLoadingUI(): void;
  85770. /**
  85771. * Hide the loading screen
  85772. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85773. */
  85774. hideLoadingUI(): void;
  85775. /**
  85776. * Gets the current loading screen object
  85777. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85778. */
  85779. /**
  85780. * Sets the current loading screen object
  85781. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85782. */
  85783. loadingScreen: ILoadingScreen;
  85784. /**
  85785. * Sets the current loading screen text
  85786. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85787. */
  85788. loadingUIText: string;
  85789. /**
  85790. * Sets the current loading screen background color
  85791. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85792. */
  85793. loadingUIBackgroundColor: string;
  85794. /**
  85795. * Attach a new callback raised when context lost event is fired
  85796. * @param callback defines the callback to call
  85797. */
  85798. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85799. /**
  85800. * Attach a new callback raised when context restored event is fired
  85801. * @param callback defines the callback to call
  85802. */
  85803. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85804. /**
  85805. * Gets the source code of the vertex shader associated with a specific webGL program
  85806. * @param program defines the program to use
  85807. * @returns a string containing the source code of the vertex shader associated with the program
  85808. */
  85809. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  85810. /**
  85811. * Gets the source code of the fragment shader associated with a specific webGL program
  85812. * @param program defines the program to use
  85813. * @returns a string containing the source code of the fragment shader associated with the program
  85814. */
  85815. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  85816. /**
  85817. * Get the current error code of the webGL context
  85818. * @returns the error code
  85819. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  85820. */
  85821. getError(): number;
  85822. /**
  85823. * Gets the current framerate
  85824. * @returns a number representing the framerate
  85825. */
  85826. getFps(): number;
  85827. /**
  85828. * Gets the time spent between current and previous frame
  85829. * @returns a number representing the delta time in ms
  85830. */
  85831. getDeltaTime(): number;
  85832. private _measureFps;
  85833. /** @hidden */
  85834. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  85835. private _canRenderToFloatFramebuffer;
  85836. private _canRenderToHalfFloatFramebuffer;
  85837. private _canRenderToFramebuffer;
  85838. /** @hidden */
  85839. _getWebGLTextureType(type: number): number;
  85840. private _getInternalFormat;
  85841. /** @hidden */
  85842. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  85843. /** @hidden */
  85844. _getRGBAMultiSampleBufferFormat(type: number): number;
  85845. /** @hidden */
  85846. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  85847. /** @hidden */
  85848. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  85849. private _partialLoadFile;
  85850. private _cascadeLoadFiles;
  85851. /**
  85852. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  85853. * @returns true if the engine can be created
  85854. * @ignorenaming
  85855. */
  85856. static isSupported(): boolean;
  85857. }
  85858. }
  85859. declare module BABYLON {
  85860. /**
  85861. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  85862. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  85863. */
  85864. export class EffectFallbacks {
  85865. private _defines;
  85866. private _currentRank;
  85867. private _maxRank;
  85868. private _mesh;
  85869. /**
  85870. * Removes the fallback from the bound mesh.
  85871. */
  85872. unBindMesh(): void;
  85873. /**
  85874. * Adds a fallback on the specified property.
  85875. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85876. * @param define The name of the define in the shader
  85877. */
  85878. addFallback(rank: number, define: string): void;
  85879. /**
  85880. * Sets the mesh to use CPU skinning when needing to fallback.
  85881. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85882. * @param mesh The mesh to use the fallbacks.
  85883. */
  85884. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  85885. /**
  85886. * Checks to see if more fallbacks are still availible.
  85887. */
  85888. readonly isMoreFallbacks: boolean;
  85889. /**
  85890. * Removes the defines that shoould be removed when falling back.
  85891. * @param currentDefines defines the current define statements for the shader.
  85892. * @param effect defines the current effect we try to compile
  85893. * @returns The resulting defines with defines of the current rank removed.
  85894. */
  85895. reduce(currentDefines: string, effect: Effect): string;
  85896. }
  85897. /**
  85898. * Options to be used when creating an effect.
  85899. */
  85900. export class EffectCreationOptions {
  85901. /**
  85902. * Atrributes that will be used in the shader.
  85903. */
  85904. attributes: string[];
  85905. /**
  85906. * Uniform varible names that will be set in the shader.
  85907. */
  85908. uniformsNames: string[];
  85909. /**
  85910. * Uniform buffer varible names that will be set in the shader.
  85911. */
  85912. uniformBuffersNames: string[];
  85913. /**
  85914. * Sampler texture variable names that will be set in the shader.
  85915. */
  85916. samplers: string[];
  85917. /**
  85918. * Define statements that will be set in the shader.
  85919. */
  85920. defines: any;
  85921. /**
  85922. * Possible fallbacks for this effect to improve performance when needed.
  85923. */
  85924. fallbacks: Nullable<EffectFallbacks>;
  85925. /**
  85926. * Callback that will be called when the shader is compiled.
  85927. */
  85928. onCompiled: Nullable<(effect: Effect) => void>;
  85929. /**
  85930. * Callback that will be called if an error occurs during shader compilation.
  85931. */
  85932. onError: Nullable<(effect: Effect, errors: string) => void>;
  85933. /**
  85934. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  85935. */
  85936. indexParameters: any;
  85937. /**
  85938. * Max number of lights that can be used in the shader.
  85939. */
  85940. maxSimultaneousLights: number;
  85941. /**
  85942. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  85943. */
  85944. transformFeedbackVaryings: Nullable<string[]>;
  85945. }
  85946. /**
  85947. * Effect containing vertex and fragment shader that can be executed on an object.
  85948. */
  85949. export class Effect {
  85950. /**
  85951. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  85952. */
  85953. static ShadersRepository: string;
  85954. /**
  85955. * Name of the effect.
  85956. */
  85957. name: any;
  85958. /**
  85959. * String container all the define statements that should be set on the shader.
  85960. */
  85961. defines: string;
  85962. /**
  85963. * Callback that will be called when the shader is compiled.
  85964. */
  85965. onCompiled: Nullable<(effect: Effect) => void>;
  85966. /**
  85967. * Callback that will be called if an error occurs during shader compilation.
  85968. */
  85969. onError: Nullable<(effect: Effect, errors: string) => void>;
  85970. /**
  85971. * Callback that will be called when effect is bound.
  85972. */
  85973. onBind: Nullable<(effect: Effect) => void>;
  85974. /**
  85975. * Unique ID of the effect.
  85976. */
  85977. uniqueId: number;
  85978. /**
  85979. * Observable that will be called when the shader is compiled.
  85980. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  85981. */
  85982. onCompileObservable: Observable<Effect>;
  85983. /**
  85984. * Observable that will be called if an error occurs during shader compilation.
  85985. */
  85986. onErrorObservable: Observable<Effect>;
  85987. /** @hidden */
  85988. _onBindObservable: Nullable<Observable<Effect>>;
  85989. /**
  85990. * Observable that will be called when effect is bound.
  85991. */
  85992. readonly onBindObservable: Observable<Effect>;
  85993. /** @hidden */
  85994. _bonesComputationForcedToCPU: boolean;
  85995. private static _uniqueIdSeed;
  85996. private _engine;
  85997. private _uniformBuffersNames;
  85998. private _uniformsNames;
  85999. private _samplers;
  86000. private _isReady;
  86001. private _compilationError;
  86002. private _attributesNames;
  86003. private _attributes;
  86004. private _uniforms;
  86005. /**
  86006. * Key for the effect.
  86007. * @hidden
  86008. */
  86009. _key: string;
  86010. private _indexParameters;
  86011. private _fallbacks;
  86012. private _vertexSourceCode;
  86013. private _fragmentSourceCode;
  86014. private _vertexSourceCodeOverride;
  86015. private _fragmentSourceCodeOverride;
  86016. private _transformFeedbackVaryings;
  86017. /**
  86018. * Compiled shader to webGL program.
  86019. * @hidden
  86020. */
  86021. _program: WebGLProgram;
  86022. private _valueCache;
  86023. private static _baseCache;
  86024. /**
  86025. * Instantiates an effect.
  86026. * An effect can be used to create/manage/execute vertex and fragment shaders.
  86027. * @param baseName Name of the effect.
  86028. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  86029. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  86030. * @param samplers List of sampler variables that will be passed to the shader.
  86031. * @param engine Engine to be used to render the effect
  86032. * @param defines Define statements to be added to the shader.
  86033. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  86034. * @param onCompiled Callback that will be called when the shader is compiled.
  86035. * @param onError Callback that will be called if an error occurs during shader compilation.
  86036. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  86037. */
  86038. 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);
  86039. /**
  86040. * Unique key for this effect
  86041. */
  86042. readonly key: string;
  86043. /**
  86044. * If the effect has been compiled and prepared.
  86045. * @returns if the effect is compiled and prepared.
  86046. */
  86047. isReady(): boolean;
  86048. /**
  86049. * The engine the effect was initialized with.
  86050. * @returns the engine.
  86051. */
  86052. getEngine(): Engine;
  86053. /**
  86054. * The compiled webGL program for the effect
  86055. * @returns the webGL program.
  86056. */
  86057. getProgram(): WebGLProgram;
  86058. /**
  86059. * The set of names of attribute variables for the shader.
  86060. * @returns An array of attribute names.
  86061. */
  86062. getAttributesNames(): string[];
  86063. /**
  86064. * Returns the attribute at the given index.
  86065. * @param index The index of the attribute.
  86066. * @returns The location of the attribute.
  86067. */
  86068. getAttributeLocation(index: number): number;
  86069. /**
  86070. * Returns the attribute based on the name of the variable.
  86071. * @param name of the attribute to look up.
  86072. * @returns the attribute location.
  86073. */
  86074. getAttributeLocationByName(name: string): number;
  86075. /**
  86076. * The number of attributes.
  86077. * @returns the numnber of attributes.
  86078. */
  86079. getAttributesCount(): number;
  86080. /**
  86081. * Gets the index of a uniform variable.
  86082. * @param uniformName of the uniform to look up.
  86083. * @returns the index.
  86084. */
  86085. getUniformIndex(uniformName: string): number;
  86086. /**
  86087. * Returns the attribute based on the name of the variable.
  86088. * @param uniformName of the uniform to look up.
  86089. * @returns the location of the uniform.
  86090. */
  86091. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  86092. /**
  86093. * Returns an array of sampler variable names
  86094. * @returns The array of sampler variable neames.
  86095. */
  86096. getSamplers(): string[];
  86097. /**
  86098. * The error from the last compilation.
  86099. * @returns the error string.
  86100. */
  86101. getCompilationError(): string;
  86102. /**
  86103. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  86104. * @param func The callback to be used.
  86105. */
  86106. executeWhenCompiled(func: (effect: Effect) => void): void;
  86107. private _checkIsReady;
  86108. /** @hidden */
  86109. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  86110. /** @hidden */
  86111. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  86112. /** @hidden */
  86113. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  86114. private _processShaderConversion;
  86115. private _processIncludes;
  86116. private _processPrecision;
  86117. /**
  86118. * Recompiles the webGL program
  86119. * @param vertexSourceCode The source code for the vertex shader.
  86120. * @param fragmentSourceCode The source code for the fragment shader.
  86121. * @param onCompiled Callback called when completed.
  86122. * @param onError Callback called on error.
  86123. * @hidden
  86124. */
  86125. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  86126. /**
  86127. * Gets the uniform locations of the the specified variable names
  86128. * @param names THe names of the variables to lookup.
  86129. * @returns Array of locations in the same order as variable names.
  86130. */
  86131. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  86132. /**
  86133. * Prepares the effect
  86134. * @hidden
  86135. */
  86136. _prepareEffect(): void;
  86137. /**
  86138. * Checks if the effect is supported. (Must be called after compilation)
  86139. */
  86140. readonly isSupported: boolean;
  86141. /**
  86142. * Binds a texture to the engine to be used as output of the shader.
  86143. * @param channel Name of the output variable.
  86144. * @param texture Texture to bind.
  86145. * @hidden
  86146. */
  86147. _bindTexture(channel: string, texture: InternalTexture): void;
  86148. /**
  86149. * Sets a texture on the engine to be used in the shader.
  86150. * @param channel Name of the sampler variable.
  86151. * @param texture Texture to set.
  86152. */
  86153. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  86154. /**
  86155. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  86156. * @param channel Name of the sampler variable.
  86157. * @param texture Texture to set.
  86158. */
  86159. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  86160. /**
  86161. * Sets an array of textures on the engine to be used in the shader.
  86162. * @param channel Name of the variable.
  86163. * @param textures Textures to set.
  86164. */
  86165. setTextureArray(channel: string, textures: BaseTexture[]): void;
  86166. /**
  86167. * 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)
  86168. * @param channel Name of the sampler variable.
  86169. * @param postProcess Post process to get the input texture from.
  86170. */
  86171. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  86172. /**
  86173. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  86174. * 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)
  86175. * @param channel Name of the sampler variable.
  86176. * @param postProcess Post process to get the output texture from.
  86177. */
  86178. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  86179. /** @hidden */
  86180. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  86181. /** @hidden */
  86182. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  86183. /** @hidden */
  86184. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  86185. /** @hidden */
  86186. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  86187. /**
  86188. * Binds a buffer to a uniform.
  86189. * @param buffer Buffer to bind.
  86190. * @param name Name of the uniform variable to bind to.
  86191. */
  86192. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  86193. /**
  86194. * Binds block to a uniform.
  86195. * @param blockName Name of the block to bind.
  86196. * @param index Index to bind.
  86197. */
  86198. bindUniformBlock(blockName: string, index: number): void;
  86199. /**
  86200. * Sets an interger value on a uniform variable.
  86201. * @param uniformName Name of the variable.
  86202. * @param value Value to be set.
  86203. * @returns this effect.
  86204. */
  86205. setInt(uniformName: string, value: number): Effect;
  86206. /**
  86207. * Sets an int array on a uniform variable.
  86208. * @param uniformName Name of the variable.
  86209. * @param array array to be set.
  86210. * @returns this effect.
  86211. */
  86212. setIntArray(uniformName: string, array: Int32Array): Effect;
  86213. /**
  86214. * 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)
  86215. * @param uniformName Name of the variable.
  86216. * @param array array to be set.
  86217. * @returns this effect.
  86218. */
  86219. setIntArray2(uniformName: string, array: Int32Array): Effect;
  86220. /**
  86221. * 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)
  86222. * @param uniformName Name of the variable.
  86223. * @param array array to be set.
  86224. * @returns this effect.
  86225. */
  86226. setIntArray3(uniformName: string, array: Int32Array): Effect;
  86227. /**
  86228. * 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)
  86229. * @param uniformName Name of the variable.
  86230. * @param array array to be set.
  86231. * @returns this effect.
  86232. */
  86233. setIntArray4(uniformName: string, array: Int32Array): Effect;
  86234. /**
  86235. * Sets an float array on a uniform variable.
  86236. * @param uniformName Name of the variable.
  86237. * @param array array to be set.
  86238. * @returns this effect.
  86239. */
  86240. setFloatArray(uniformName: string, array: Float32Array): Effect;
  86241. /**
  86242. * 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)
  86243. * @param uniformName Name of the variable.
  86244. * @param array array to be set.
  86245. * @returns this effect.
  86246. */
  86247. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  86248. /**
  86249. * 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)
  86250. * @param uniformName Name of the variable.
  86251. * @param array array to be set.
  86252. * @returns this effect.
  86253. */
  86254. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  86255. /**
  86256. * 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)
  86257. * @param uniformName Name of the variable.
  86258. * @param array array to be set.
  86259. * @returns this effect.
  86260. */
  86261. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  86262. /**
  86263. * Sets an array on a uniform variable.
  86264. * @param uniformName Name of the variable.
  86265. * @param array array to be set.
  86266. * @returns this effect.
  86267. */
  86268. setArray(uniformName: string, array: number[]): Effect;
  86269. /**
  86270. * 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)
  86271. * @param uniformName Name of the variable.
  86272. * @param array array to be set.
  86273. * @returns this effect.
  86274. */
  86275. setArray2(uniformName: string, array: number[]): Effect;
  86276. /**
  86277. * 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)
  86278. * @param uniformName Name of the variable.
  86279. * @param array array to be set.
  86280. * @returns this effect.
  86281. */
  86282. setArray3(uniformName: string, array: number[]): Effect;
  86283. /**
  86284. * 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)
  86285. * @param uniformName Name of the variable.
  86286. * @param array array to be set.
  86287. * @returns this effect.
  86288. */
  86289. setArray4(uniformName: string, array: number[]): Effect;
  86290. /**
  86291. * Sets matrices on a uniform variable.
  86292. * @param uniformName Name of the variable.
  86293. * @param matrices matrices to be set.
  86294. * @returns this effect.
  86295. */
  86296. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  86297. /**
  86298. * Sets matrix on a uniform variable.
  86299. * @param uniformName Name of the variable.
  86300. * @param matrix matrix to be set.
  86301. * @returns this effect.
  86302. */
  86303. setMatrix(uniformName: string, matrix: Matrix): Effect;
  86304. /**
  86305. * 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)
  86306. * @param uniformName Name of the variable.
  86307. * @param matrix matrix to be set.
  86308. * @returns this effect.
  86309. */
  86310. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  86311. /**
  86312. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  86313. * @param uniformName Name of the variable.
  86314. * @param matrix matrix to be set.
  86315. * @returns this effect.
  86316. */
  86317. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  86318. /**
  86319. * Sets a float on a uniform variable.
  86320. * @param uniformName Name of the variable.
  86321. * @param value value to be set.
  86322. * @returns this effect.
  86323. */
  86324. setFloat(uniformName: string, value: number): Effect;
  86325. /**
  86326. * Sets a boolean on a uniform variable.
  86327. * @param uniformName Name of the variable.
  86328. * @param bool value to be set.
  86329. * @returns this effect.
  86330. */
  86331. setBool(uniformName: string, bool: boolean): Effect;
  86332. /**
  86333. * Sets a Vector2 on a uniform variable.
  86334. * @param uniformName Name of the variable.
  86335. * @param vector2 vector2 to be set.
  86336. * @returns this effect.
  86337. */
  86338. setVector2(uniformName: string, vector2: Vector2): Effect;
  86339. /**
  86340. * Sets a float2 on a uniform variable.
  86341. * @param uniformName Name of the variable.
  86342. * @param x First float in float2.
  86343. * @param y Second float in float2.
  86344. * @returns this effect.
  86345. */
  86346. setFloat2(uniformName: string, x: number, y: number): Effect;
  86347. /**
  86348. * Sets a Vector3 on a uniform variable.
  86349. * @param uniformName Name of the variable.
  86350. * @param vector3 Value to be set.
  86351. * @returns this effect.
  86352. */
  86353. setVector3(uniformName: string, vector3: Vector3): Effect;
  86354. /**
  86355. * Sets a float3 on a uniform variable.
  86356. * @param uniformName Name of the variable.
  86357. * @param x First float in float3.
  86358. * @param y Second float in float3.
  86359. * @param z Third float in float3.
  86360. * @returns this effect.
  86361. */
  86362. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  86363. /**
  86364. * Sets a Vector4 on a uniform variable.
  86365. * @param uniformName Name of the variable.
  86366. * @param vector4 Value to be set.
  86367. * @returns this effect.
  86368. */
  86369. setVector4(uniformName: string, vector4: Vector4): Effect;
  86370. /**
  86371. * Sets a float4 on a uniform variable.
  86372. * @param uniformName Name of the variable.
  86373. * @param x First float in float4.
  86374. * @param y Second float in float4.
  86375. * @param z Third float in float4.
  86376. * @param w Fourth float in float4.
  86377. * @returns this effect.
  86378. */
  86379. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  86380. /**
  86381. * Sets a Color3 on a uniform variable.
  86382. * @param uniformName Name of the variable.
  86383. * @param color3 Value to be set.
  86384. * @returns this effect.
  86385. */
  86386. setColor3(uniformName: string, color3: Color3): Effect;
  86387. /**
  86388. * Sets a Color4 on a uniform variable.
  86389. * @param uniformName Name of the variable.
  86390. * @param color3 Value to be set.
  86391. * @param alpha Alpha value to be set.
  86392. * @returns this effect.
  86393. */
  86394. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  86395. /**
  86396. * Sets a Color4 on a uniform variable
  86397. * @param uniformName defines the name of the variable
  86398. * @param color4 defines the value to be set
  86399. * @returns this effect.
  86400. */
  86401. setDirectColor4(uniformName: string, color4: Color4): Effect;
  86402. /**
  86403. * This function will add a new shader to the shader store
  86404. * @param name the name of the shader
  86405. * @param pixelShader optional pixel shader content
  86406. * @param vertexShader optional vertex shader content
  86407. */
  86408. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  86409. /**
  86410. * Store of each shader (The can be looked up using effect.key)
  86411. */
  86412. static ShadersStore: {
  86413. [key: string]: string;
  86414. };
  86415. /**
  86416. * Store of each included file for a shader (The can be looked up using effect.key)
  86417. */
  86418. static IncludesShadersStore: {
  86419. [key: string]: string;
  86420. };
  86421. /**
  86422. * Resets the cache of effects.
  86423. */
  86424. static ResetCache(): void;
  86425. }
  86426. }
  86427. declare module BABYLON {
  86428. /**
  86429. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86430. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86431. * 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;
  86432. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86433. */
  86434. export class ColorCurves {
  86435. private _dirty;
  86436. private _tempColor;
  86437. private _globalCurve;
  86438. private _highlightsCurve;
  86439. private _midtonesCurve;
  86440. private _shadowsCurve;
  86441. private _positiveCurve;
  86442. private _negativeCurve;
  86443. private _globalHue;
  86444. private _globalDensity;
  86445. private _globalSaturation;
  86446. private _globalExposure;
  86447. /**
  86448. * Gets the global Hue value.
  86449. * 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).
  86450. */
  86451. /**
  86452. * Sets the global Hue value.
  86453. * 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).
  86454. */
  86455. globalHue: number;
  86456. /**
  86457. * Gets the global Density value.
  86458. * 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.
  86459. * Values less than zero provide a filter of opposite hue.
  86460. */
  86461. /**
  86462. * Sets the global Density value.
  86463. * 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.
  86464. * Values less than zero provide a filter of opposite hue.
  86465. */
  86466. globalDensity: number;
  86467. /**
  86468. * Gets the global Saturation value.
  86469. * 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.
  86470. */
  86471. /**
  86472. * Sets the global Saturation value.
  86473. * 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.
  86474. */
  86475. globalSaturation: number;
  86476. /**
  86477. * Gets the global Exposure value.
  86478. * 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.
  86479. */
  86480. /**
  86481. * Sets the global Exposure value.
  86482. * 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.
  86483. */
  86484. globalExposure: number;
  86485. private _highlightsHue;
  86486. private _highlightsDensity;
  86487. private _highlightsSaturation;
  86488. private _highlightsExposure;
  86489. /**
  86490. * Gets the highlights Hue value.
  86491. * 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).
  86492. */
  86493. /**
  86494. * Sets the highlights Hue value.
  86495. * 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).
  86496. */
  86497. highlightsHue: number;
  86498. /**
  86499. * Gets the highlights Density value.
  86500. * 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.
  86501. * Values less than zero provide a filter of opposite hue.
  86502. */
  86503. /**
  86504. * Sets the highlights Density value.
  86505. * 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.
  86506. * Values less than zero provide a filter of opposite hue.
  86507. */
  86508. highlightsDensity: number;
  86509. /**
  86510. * Gets the highlights Saturation value.
  86511. * 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.
  86512. */
  86513. /**
  86514. * Sets the highlights Saturation value.
  86515. * 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.
  86516. */
  86517. highlightsSaturation: number;
  86518. /**
  86519. * Gets the highlights Exposure value.
  86520. * 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.
  86521. */
  86522. /**
  86523. * Sets the highlights Exposure value.
  86524. * 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.
  86525. */
  86526. highlightsExposure: number;
  86527. private _midtonesHue;
  86528. private _midtonesDensity;
  86529. private _midtonesSaturation;
  86530. private _midtonesExposure;
  86531. /**
  86532. * Gets the midtones Hue value.
  86533. * 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).
  86534. */
  86535. /**
  86536. * Sets the midtones Hue value.
  86537. * 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).
  86538. */
  86539. midtonesHue: number;
  86540. /**
  86541. * Gets the midtones Density value.
  86542. * 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.
  86543. * Values less than zero provide a filter of opposite hue.
  86544. */
  86545. /**
  86546. * Sets the midtones Density value.
  86547. * 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.
  86548. * Values less than zero provide a filter of opposite hue.
  86549. */
  86550. midtonesDensity: number;
  86551. /**
  86552. * Gets the midtones Saturation value.
  86553. * 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.
  86554. */
  86555. /**
  86556. * Sets the midtones Saturation value.
  86557. * 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.
  86558. */
  86559. midtonesSaturation: number;
  86560. /**
  86561. * Gets the midtones Exposure value.
  86562. * 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.
  86563. */
  86564. /**
  86565. * Sets the midtones Exposure value.
  86566. * 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.
  86567. */
  86568. midtonesExposure: number;
  86569. private _shadowsHue;
  86570. private _shadowsDensity;
  86571. private _shadowsSaturation;
  86572. private _shadowsExposure;
  86573. /**
  86574. * Gets the shadows Hue value.
  86575. * 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).
  86576. */
  86577. /**
  86578. * Sets the shadows Hue value.
  86579. * 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).
  86580. */
  86581. shadowsHue: number;
  86582. /**
  86583. * Gets the shadows Density value.
  86584. * 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.
  86585. * Values less than zero provide a filter of opposite hue.
  86586. */
  86587. /**
  86588. * Sets the shadows Density value.
  86589. * 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.
  86590. * Values less than zero provide a filter of opposite hue.
  86591. */
  86592. shadowsDensity: number;
  86593. /**
  86594. * Gets the shadows Saturation value.
  86595. * 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.
  86596. */
  86597. /**
  86598. * Sets the shadows Saturation value.
  86599. * 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.
  86600. */
  86601. shadowsSaturation: number;
  86602. /**
  86603. * Gets the shadows Exposure value.
  86604. * 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.
  86605. */
  86606. /**
  86607. * Sets the shadows Exposure value.
  86608. * 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.
  86609. */
  86610. shadowsExposure: number;
  86611. /**
  86612. * Returns the class name
  86613. * @returns The class name
  86614. */
  86615. getClassName(): string;
  86616. /**
  86617. * Binds the color curves to the shader.
  86618. * @param colorCurves The color curve to bind
  86619. * @param effect The effect to bind to
  86620. * @param positiveUniform The positive uniform shader parameter
  86621. * @param neutralUniform The neutral uniform shader parameter
  86622. * @param negativeUniform The negative uniform shader parameter
  86623. */
  86624. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  86625. /**
  86626. * Prepare the list of uniforms associated with the ColorCurves effects.
  86627. * @param uniformsList The list of uniforms used in the effect
  86628. */
  86629. static PrepareUniforms(uniformsList: string[]): void;
  86630. /**
  86631. * Returns color grading data based on a hue, density, saturation and exposure value.
  86632. * @param filterHue The hue of the color filter.
  86633. * @param filterDensity The density of the color filter.
  86634. * @param saturation The saturation.
  86635. * @param exposure The exposure.
  86636. * @param result The result data container.
  86637. */
  86638. private getColorGradingDataToRef;
  86639. /**
  86640. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  86641. * @param value The input slider value in range [-100,100].
  86642. * @returns Adjusted value.
  86643. */
  86644. private static applyColorGradingSliderNonlinear;
  86645. /**
  86646. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  86647. * @param hue The hue (H) input.
  86648. * @param saturation The saturation (S) input.
  86649. * @param brightness The brightness (B) input.
  86650. * @result An RGBA color represented as Vector4.
  86651. */
  86652. private static fromHSBToRef;
  86653. /**
  86654. * Returns a value clamped between min and max
  86655. * @param value The value to clamp
  86656. * @param min The minimum of value
  86657. * @param max The maximum of value
  86658. * @returns The clamped value.
  86659. */
  86660. private static clamp;
  86661. /**
  86662. * Clones the current color curve instance.
  86663. * @return The cloned curves
  86664. */
  86665. clone(): ColorCurves;
  86666. /**
  86667. * Serializes the current color curve instance to a json representation.
  86668. * @return a JSON representation
  86669. */
  86670. serialize(): any;
  86671. /**
  86672. * Parses the color curve from a json representation.
  86673. * @param source the JSON source to parse
  86674. * @return The parsed curves
  86675. */
  86676. static Parse(source: any): ColorCurves;
  86677. }
  86678. }
  86679. declare module BABYLON {
  86680. /**
  86681. * Interface to follow in your material defines to integrate easily the
  86682. * Image proccessing functions.
  86683. * @hidden
  86684. */
  86685. export interface IImageProcessingConfigurationDefines {
  86686. IMAGEPROCESSING: boolean;
  86687. VIGNETTE: boolean;
  86688. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86689. VIGNETTEBLENDMODEOPAQUE: boolean;
  86690. TONEMAPPING: boolean;
  86691. TONEMAPPING_ACES: boolean;
  86692. CONTRAST: boolean;
  86693. EXPOSURE: boolean;
  86694. COLORCURVES: boolean;
  86695. COLORGRADING: boolean;
  86696. COLORGRADING3D: boolean;
  86697. SAMPLER3DGREENDEPTH: boolean;
  86698. SAMPLER3DBGRMAP: boolean;
  86699. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86700. }
  86701. /**
  86702. * @hidden
  86703. */
  86704. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  86705. IMAGEPROCESSING: boolean;
  86706. VIGNETTE: boolean;
  86707. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86708. VIGNETTEBLENDMODEOPAQUE: boolean;
  86709. TONEMAPPING: boolean;
  86710. TONEMAPPING_ACES: boolean;
  86711. CONTRAST: boolean;
  86712. COLORCURVES: boolean;
  86713. COLORGRADING: boolean;
  86714. COLORGRADING3D: boolean;
  86715. SAMPLER3DGREENDEPTH: boolean;
  86716. SAMPLER3DBGRMAP: boolean;
  86717. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86718. EXPOSURE: boolean;
  86719. constructor();
  86720. }
  86721. /**
  86722. * This groups together the common properties used for image processing either in direct forward pass
  86723. * or through post processing effect depending on the use of the image processing pipeline in your scene
  86724. * or not.
  86725. */
  86726. export class ImageProcessingConfiguration {
  86727. /**
  86728. * Default tone mapping applied in BabylonJS.
  86729. */
  86730. static readonly TONEMAPPING_STANDARD: number;
  86731. /**
  86732. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  86733. * to other engines rendering to increase portability.
  86734. */
  86735. static readonly TONEMAPPING_ACES: number;
  86736. /**
  86737. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  86738. */
  86739. colorCurves: Nullable<ColorCurves>;
  86740. private _colorCurvesEnabled;
  86741. /**
  86742. * Gets wether the color curves effect is enabled.
  86743. */
  86744. /**
  86745. * Sets wether the color curves effect is enabled.
  86746. */
  86747. colorCurvesEnabled: boolean;
  86748. private _colorGradingTexture;
  86749. /**
  86750. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86751. */
  86752. /**
  86753. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86754. */
  86755. colorGradingTexture: Nullable<BaseTexture>;
  86756. private _colorGradingEnabled;
  86757. /**
  86758. * Gets wether the color grading effect is enabled.
  86759. */
  86760. /**
  86761. * Sets wether the color grading effect is enabled.
  86762. */
  86763. colorGradingEnabled: boolean;
  86764. private _colorGradingWithGreenDepth;
  86765. /**
  86766. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86767. */
  86768. /**
  86769. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86770. */
  86771. colorGradingWithGreenDepth: boolean;
  86772. private _colorGradingBGR;
  86773. /**
  86774. * Gets wether the color grading texture contains BGR values.
  86775. */
  86776. /**
  86777. * Sets wether the color grading texture contains BGR values.
  86778. */
  86779. colorGradingBGR: boolean;
  86780. /** @hidden */
  86781. _exposure: number;
  86782. /**
  86783. * Gets the Exposure used in the effect.
  86784. */
  86785. /**
  86786. * Sets the Exposure used in the effect.
  86787. */
  86788. exposure: number;
  86789. private _toneMappingEnabled;
  86790. /**
  86791. * Gets wether the tone mapping effect is enabled.
  86792. */
  86793. /**
  86794. * Sets wether the tone mapping effect is enabled.
  86795. */
  86796. toneMappingEnabled: boolean;
  86797. private _toneMappingType;
  86798. /**
  86799. * Gets the type of tone mapping effect.
  86800. */
  86801. /**
  86802. * Sets the type of tone mapping effect used in BabylonJS.
  86803. */
  86804. toneMappingType: number;
  86805. protected _contrast: number;
  86806. /**
  86807. * Gets the contrast used in the effect.
  86808. */
  86809. /**
  86810. * Sets the contrast used in the effect.
  86811. */
  86812. contrast: number;
  86813. /**
  86814. * Vignette stretch size.
  86815. */
  86816. vignetteStretch: number;
  86817. /**
  86818. * Vignette centre X Offset.
  86819. */
  86820. vignetteCentreX: number;
  86821. /**
  86822. * Vignette centre Y Offset.
  86823. */
  86824. vignetteCentreY: number;
  86825. /**
  86826. * Vignette weight or intensity of the vignette effect.
  86827. */
  86828. vignetteWeight: number;
  86829. /**
  86830. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86831. * if vignetteEnabled is set to true.
  86832. */
  86833. vignetteColor: Color4;
  86834. /**
  86835. * Camera field of view used by the Vignette effect.
  86836. */
  86837. vignetteCameraFov: number;
  86838. private _vignetteBlendMode;
  86839. /**
  86840. * Gets the vignette blend mode allowing different kind of effect.
  86841. */
  86842. /**
  86843. * Sets the vignette blend mode allowing different kind of effect.
  86844. */
  86845. vignetteBlendMode: number;
  86846. private _vignetteEnabled;
  86847. /**
  86848. * Gets wether the vignette effect is enabled.
  86849. */
  86850. /**
  86851. * Sets wether the vignette effect is enabled.
  86852. */
  86853. vignetteEnabled: boolean;
  86854. private _applyByPostProcess;
  86855. /**
  86856. * Gets wether the image processing is applied through a post process or not.
  86857. */
  86858. /**
  86859. * Sets wether the image processing is applied through a post process or not.
  86860. */
  86861. applyByPostProcess: boolean;
  86862. private _isEnabled;
  86863. /**
  86864. * Gets wether the image processing is enabled or not.
  86865. */
  86866. /**
  86867. * Sets wether the image processing is enabled or not.
  86868. */
  86869. isEnabled: boolean;
  86870. /**
  86871. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86872. */
  86873. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86874. /**
  86875. * Method called each time the image processing information changes requires to recompile the effect.
  86876. */
  86877. protected _updateParameters(): void;
  86878. /**
  86879. * Gets the current class name.
  86880. * @return "ImageProcessingConfiguration"
  86881. */
  86882. getClassName(): string;
  86883. /**
  86884. * Prepare the list of uniforms associated with the Image Processing effects.
  86885. * @param uniforms The list of uniforms used in the effect
  86886. * @param defines the list of defines currently in use
  86887. */
  86888. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86889. /**
  86890. * Prepare the list of samplers associated with the Image Processing effects.
  86891. * @param samplersList The list of uniforms used in the effect
  86892. * @param defines the list of defines currently in use
  86893. */
  86894. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86895. /**
  86896. * Prepare the list of defines associated to the shader.
  86897. * @param defines the list of defines to complete
  86898. * @param forPostProcess Define if we are currently in post process mode or not
  86899. */
  86900. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86901. /**
  86902. * Returns true if all the image processing information are ready.
  86903. * @returns True if ready, otherwise, false
  86904. */
  86905. isReady(): boolean;
  86906. /**
  86907. * Binds the image processing to the shader.
  86908. * @param effect The effect to bind to
  86909. * @param aspectRatio Define the current aspect ratio of the effect
  86910. */
  86911. bind(effect: Effect, aspectRatio?: number): void;
  86912. /**
  86913. * Clones the current image processing instance.
  86914. * @return The cloned image processing
  86915. */
  86916. clone(): ImageProcessingConfiguration;
  86917. /**
  86918. * Serializes the current image processing instance to a json representation.
  86919. * @return a JSON representation
  86920. */
  86921. serialize(): any;
  86922. /**
  86923. * Parses the image processing from a json representation.
  86924. * @param source the JSON source to parse
  86925. * @return The parsed image processing
  86926. */
  86927. static Parse(source: any): ImageProcessingConfiguration;
  86928. private static _VIGNETTEMODE_MULTIPLY;
  86929. private static _VIGNETTEMODE_OPAQUE;
  86930. /**
  86931. * Used to apply the vignette as a mix with the pixel color.
  86932. */
  86933. static readonly VIGNETTEMODE_MULTIPLY: number;
  86934. /**
  86935. * Used to apply the vignette as a replacement of the pixel color.
  86936. */
  86937. static readonly VIGNETTEMODE_OPAQUE: number;
  86938. }
  86939. }
  86940. declare module BABYLON {
  86941. /**
  86942. * This represents all the required information to add a fresnel effect on a material:
  86943. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  86944. */
  86945. export class FresnelParameters {
  86946. private _isEnabled;
  86947. /**
  86948. * Define if the fresnel effect is enable or not.
  86949. */
  86950. isEnabled: boolean;
  86951. /**
  86952. * Define the color used on edges (grazing angle)
  86953. */
  86954. leftColor: Color3;
  86955. /**
  86956. * Define the color used on center
  86957. */
  86958. rightColor: Color3;
  86959. /**
  86960. * Define bias applied to computed fresnel term
  86961. */
  86962. bias: number;
  86963. /**
  86964. * Defined the power exponent applied to fresnel term
  86965. */
  86966. power: number;
  86967. /**
  86968. * Clones the current fresnel and its valuues
  86969. * @returns a clone fresnel configuration
  86970. */
  86971. clone(): FresnelParameters;
  86972. /**
  86973. * Serializes the current fresnel parameters to a JSON representation.
  86974. * @return the JSON serialization
  86975. */
  86976. serialize(): any;
  86977. /**
  86978. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  86979. * @param parsedFresnelParameters Define the JSON representation
  86980. * @returns the parsed parameters
  86981. */
  86982. static Parse(parsedFresnelParameters: any): FresnelParameters;
  86983. }
  86984. }
  86985. declare module BABYLON {
  86986. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  86987. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86988. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86989. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86990. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86991. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86992. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86993. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86994. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86995. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86996. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86997. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86998. /**
  86999. * Decorator used to define property that can be serialized as reference to a camera
  87000. * @param sourceName defines the name of the property to decorate
  87001. */
  87002. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87003. /**
  87004. * Class used to help serialization objects
  87005. */
  87006. export class SerializationHelper {
  87007. /** hidden */
  87008. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  87009. /** hidden */
  87010. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  87011. /** hidden */
  87012. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  87013. /** hidden */
  87014. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  87015. /**
  87016. * Appends the serialized animations from the source animations
  87017. * @param source Source containing the animations
  87018. * @param destination Target to store the animations
  87019. */
  87020. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  87021. /**
  87022. * Static function used to serialized a specific entity
  87023. * @param entity defines the entity to serialize
  87024. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  87025. * @returns a JSON compatible object representing the serialization of the entity
  87026. */
  87027. static Serialize<T>(entity: T, serializationObject?: any): any;
  87028. /**
  87029. * Creates a new entity from a serialization data object
  87030. * @param creationFunction defines a function used to instanciated the new entity
  87031. * @param source defines the source serialization data
  87032. * @param scene defines the hosting scene
  87033. * @param rootUrl defines the root url for resources
  87034. * @returns a new entity
  87035. */
  87036. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  87037. /**
  87038. * Clones an object
  87039. * @param creationFunction defines the function used to instanciate the new object
  87040. * @param source defines the source object
  87041. * @returns the cloned object
  87042. */
  87043. static Clone<T>(creationFunction: () => T, source: T): T;
  87044. /**
  87045. * Instanciates a new object based on a source one (some data will be shared between both object)
  87046. * @param creationFunction defines the function used to instanciate the new object
  87047. * @param source defines the source object
  87048. * @returns the new object
  87049. */
  87050. static Instanciate<T>(creationFunction: () => T, source: T): T;
  87051. }
  87052. }
  87053. declare module BABYLON {
  87054. /**
  87055. * This is the base class of all the camera used in the application.
  87056. * @see http://doc.babylonjs.com/features/cameras
  87057. */
  87058. export class Camera extends Node {
  87059. /** @hidden */
  87060. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  87061. /**
  87062. * This is the default projection mode used by the cameras.
  87063. * It helps recreating a feeling of perspective and better appreciate depth.
  87064. * This is the best way to simulate real life cameras.
  87065. */
  87066. static readonly PERSPECTIVE_CAMERA: number;
  87067. /**
  87068. * This helps creating camera with an orthographic mode.
  87069. * 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.
  87070. */
  87071. static readonly ORTHOGRAPHIC_CAMERA: number;
  87072. /**
  87073. * This is the default FOV mode for perspective cameras.
  87074. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  87075. */
  87076. static readonly FOVMODE_VERTICAL_FIXED: number;
  87077. /**
  87078. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  87079. */
  87080. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  87081. /**
  87082. * This specifies ther is no need for a camera rig.
  87083. * Basically only one eye is rendered corresponding to the camera.
  87084. */
  87085. static readonly RIG_MODE_NONE: number;
  87086. /**
  87087. * Simulates a camera Rig with one blue eye and one red eye.
  87088. * This can be use with 3d blue and red glasses.
  87089. */
  87090. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  87091. /**
  87092. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  87093. */
  87094. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  87095. /**
  87096. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  87097. */
  87098. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  87099. /**
  87100. * Defines that both eyes of the camera will be rendered over under each other.
  87101. */
  87102. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  87103. /**
  87104. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  87105. */
  87106. static readonly RIG_MODE_VR: number;
  87107. /**
  87108. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  87109. */
  87110. static readonly RIG_MODE_WEBVR: number;
  87111. /**
  87112. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  87113. */
  87114. static readonly RIG_MODE_CUSTOM: number;
  87115. /**
  87116. * Defines if by default attaching controls should prevent the default javascript event to continue.
  87117. */
  87118. static ForceAttachControlToAlwaysPreventDefault: boolean;
  87119. /**
  87120. * @hidden
  87121. * Might be removed once multiview will be a thing
  87122. */
  87123. static UseAlternateWebVRRendering: boolean;
  87124. /**
  87125. * Define the input manager associated with the camera.
  87126. */
  87127. inputs: CameraInputsManager<Camera>;
  87128. /** @hidden */
  87129. _position: Vector3;
  87130. /**
  87131. * Define the current local position of the camera in the scene
  87132. */
  87133. position: Vector3;
  87134. /**
  87135. * The vector the camera should consider as up.
  87136. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  87137. */
  87138. upVector: Vector3;
  87139. /**
  87140. * Define the current limit on the left side for an orthographic camera
  87141. * In scene unit
  87142. */
  87143. orthoLeft: Nullable<number>;
  87144. /**
  87145. * Define the current limit on the right side for an orthographic camera
  87146. * In scene unit
  87147. */
  87148. orthoRight: Nullable<number>;
  87149. /**
  87150. * Define the current limit on the bottom side for an orthographic camera
  87151. * In scene unit
  87152. */
  87153. orthoBottom: Nullable<number>;
  87154. /**
  87155. * Define the current limit on the top side for an orthographic camera
  87156. * In scene unit
  87157. */
  87158. orthoTop: Nullable<number>;
  87159. /**
  87160. * Field Of View is set in Radians. (default is 0.8)
  87161. */
  87162. fov: number;
  87163. /**
  87164. * Define the minimum distance the camera can see from.
  87165. * This is important to note that the depth buffer are not infinite and the closer it starts
  87166. * the more your scene might encounter depth fighting issue.
  87167. */
  87168. minZ: number;
  87169. /**
  87170. * Define the maximum distance the camera can see to.
  87171. * This is important to note that the depth buffer are not infinite and the further it end
  87172. * the more your scene might encounter depth fighting issue.
  87173. */
  87174. maxZ: number;
  87175. /**
  87176. * Define the default inertia of the camera.
  87177. * This helps giving a smooth feeling to the camera movement.
  87178. */
  87179. inertia: number;
  87180. /**
  87181. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  87182. */
  87183. mode: number;
  87184. /**
  87185. * Define wether the camera is intermediate.
  87186. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  87187. */
  87188. isIntermediate: boolean;
  87189. /**
  87190. * Define the viewport of the camera.
  87191. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  87192. */
  87193. viewport: Viewport;
  87194. /**
  87195. * Restricts the camera to viewing objects with the same layerMask.
  87196. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  87197. */
  87198. layerMask: number;
  87199. /**
  87200. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  87201. */
  87202. fovMode: number;
  87203. /**
  87204. * Rig mode of the camera.
  87205. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  87206. * This is normally controlled byt the camera themselves as internal use.
  87207. */
  87208. cameraRigMode: number;
  87209. /**
  87210. * Defines the distance between both "eyes" in case of a RIG
  87211. */
  87212. interaxialDistance: number;
  87213. /**
  87214. * Defines if stereoscopic rendering is done side by side or over under.
  87215. */
  87216. isStereoscopicSideBySide: boolean;
  87217. /**
  87218. * 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
  87219. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  87220. * else in the scene.
  87221. */
  87222. customRenderTargets: RenderTargetTexture[];
  87223. /**
  87224. * When set, the camera will render to this render target instead of the default canvas
  87225. */
  87226. outputRenderTarget: Nullable<RenderTargetTexture>;
  87227. /**
  87228. * Observable triggered when the camera view matrix has changed.
  87229. */
  87230. onViewMatrixChangedObservable: Observable<Camera>;
  87231. /**
  87232. * Observable triggered when the camera Projection matrix has changed.
  87233. */
  87234. onProjectionMatrixChangedObservable: Observable<Camera>;
  87235. /**
  87236. * Observable triggered when the inputs have been processed.
  87237. */
  87238. onAfterCheckInputsObservable: Observable<Camera>;
  87239. /**
  87240. * Observable triggered when reset has been called and applied to the camera.
  87241. */
  87242. onRestoreStateObservable: Observable<Camera>;
  87243. /** @hidden */
  87244. _cameraRigParams: any;
  87245. /** @hidden */
  87246. _rigCameras: Camera[];
  87247. /** @hidden */
  87248. _rigPostProcess: Nullable<PostProcess>;
  87249. protected _webvrViewMatrix: Matrix;
  87250. /** @hidden */
  87251. _skipRendering: boolean;
  87252. /** @hidden */
  87253. _alternateCamera: Camera;
  87254. /** @hidden */
  87255. _projectionMatrix: Matrix;
  87256. /** @hidden */
  87257. _postProcesses: Nullable<PostProcess>[];
  87258. /** @hidden */
  87259. _activeMeshes: SmartArray<AbstractMesh>;
  87260. protected _globalPosition: Vector3;
  87261. /** hidden */
  87262. _computedViewMatrix: Matrix;
  87263. private _doNotComputeProjectionMatrix;
  87264. private _transformMatrix;
  87265. private _frustumPlanes;
  87266. private _refreshFrustumPlanes;
  87267. private _storedFov;
  87268. private _stateStored;
  87269. /**
  87270. * Instantiates a new camera object.
  87271. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  87272. * @see http://doc.babylonjs.com/features/cameras
  87273. * @param name Defines the name of the camera in the scene
  87274. * @param position Defines the position of the camera
  87275. * @param scene Defines the scene the camera belongs too
  87276. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  87277. */
  87278. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  87279. /**
  87280. * Store current camera state (fov, position, etc..)
  87281. * @returns the camera
  87282. */
  87283. storeState(): Camera;
  87284. /**
  87285. * Restores the camera state values if it has been stored. You must call storeState() first
  87286. */
  87287. protected _restoreStateValues(): boolean;
  87288. /**
  87289. * Restored camera state. You must call storeState() first.
  87290. * @returns true if restored and false otherwise
  87291. */
  87292. restoreState(): boolean;
  87293. /**
  87294. * Gets the class name of the camera.
  87295. * @returns the class name
  87296. */
  87297. getClassName(): string;
  87298. /** @hidden */
  87299. readonly _isCamera: boolean;
  87300. /**
  87301. * Gets a string representation of the camera useful for debug purpose.
  87302. * @param fullDetails Defines that a more verboe level of logging is required
  87303. * @returns the string representation
  87304. */
  87305. toString(fullDetails?: boolean): string;
  87306. /**
  87307. * Gets the current world space position of the camera.
  87308. */
  87309. readonly globalPosition: Vector3;
  87310. /**
  87311. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  87312. * @returns the active meshe list
  87313. */
  87314. getActiveMeshes(): SmartArray<AbstractMesh>;
  87315. /**
  87316. * Check wether a mesh is part of the current active mesh list of the camera
  87317. * @param mesh Defines the mesh to check
  87318. * @returns true if active, false otherwise
  87319. */
  87320. isActiveMesh(mesh: Mesh): boolean;
  87321. /**
  87322. * Is this camera ready to be used/rendered
  87323. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  87324. * @return true if the camera is ready
  87325. */
  87326. isReady(completeCheck?: boolean): boolean;
  87327. /** @hidden */
  87328. _initCache(): void;
  87329. /** @hidden */
  87330. _updateCache(ignoreParentClass?: boolean): void;
  87331. /** @hidden */
  87332. _isSynchronized(): boolean;
  87333. /** @hidden */
  87334. _isSynchronizedViewMatrix(): boolean;
  87335. /** @hidden */
  87336. _isSynchronizedProjectionMatrix(): boolean;
  87337. /**
  87338. * Attach the input controls to a specific dom element to get the input from.
  87339. * @param element Defines the element the controls should be listened from
  87340. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87341. */
  87342. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87343. /**
  87344. * Detach the current controls from the specified dom element.
  87345. * @param element Defines the element to stop listening the inputs from
  87346. */
  87347. detachControl(element: HTMLElement): void;
  87348. /**
  87349. * Update the camera state according to the different inputs gathered during the frame.
  87350. */
  87351. update(): void;
  87352. /** @hidden */
  87353. _checkInputs(): void;
  87354. /** @hidden */
  87355. readonly rigCameras: Camera[];
  87356. /**
  87357. * Gets the post process used by the rig cameras
  87358. */
  87359. readonly rigPostProcess: Nullable<PostProcess>;
  87360. /**
  87361. * Internal, gets the first post proces.
  87362. * @returns the first post process to be run on this camera.
  87363. */
  87364. _getFirstPostProcess(): Nullable<PostProcess>;
  87365. private _cascadePostProcessesToRigCams;
  87366. /**
  87367. * Attach a post process to the camera.
  87368. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87369. * @param postProcess The post process to attach to the camera
  87370. * @param insertAt The position of the post process in case several of them are in use in the scene
  87371. * @returns the position the post process has been inserted at
  87372. */
  87373. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  87374. /**
  87375. * Detach a post process to the camera.
  87376. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87377. * @param postProcess The post process to detach from the camera
  87378. */
  87379. detachPostProcess(postProcess: PostProcess): void;
  87380. /**
  87381. * Gets the current world matrix of the camera
  87382. */
  87383. getWorldMatrix(): Matrix;
  87384. /** @hidden */
  87385. _getViewMatrix(): Matrix;
  87386. /**
  87387. * Gets the current view matrix of the camera.
  87388. * @param force forces the camera to recompute the matrix without looking at the cached state
  87389. * @returns the view matrix
  87390. */
  87391. getViewMatrix(force?: boolean): Matrix;
  87392. /**
  87393. * Freeze the projection matrix.
  87394. * It will prevent the cache check of the camera projection compute and can speed up perf
  87395. * if no parameter of the camera are meant to change
  87396. * @param projection Defines manually a projection if necessary
  87397. */
  87398. freezeProjectionMatrix(projection?: Matrix): void;
  87399. /**
  87400. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  87401. */
  87402. unfreezeProjectionMatrix(): void;
  87403. /**
  87404. * Gets the current projection matrix of the camera.
  87405. * @param force forces the camera to recompute the matrix without looking at the cached state
  87406. * @returns the projection matrix
  87407. */
  87408. getProjectionMatrix(force?: boolean): Matrix;
  87409. /**
  87410. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  87411. * @returns a Matrix
  87412. */
  87413. getTransformationMatrix(): Matrix;
  87414. private _updateFrustumPlanes;
  87415. /**
  87416. * Checks if a cullable object (mesh...) is in the camera frustum
  87417. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  87418. * @param target The object to check
  87419. * @returns true if the object is in frustum otherwise false
  87420. */
  87421. isInFrustum(target: ICullable): boolean;
  87422. /**
  87423. * Checks if a cullable object (mesh...) is in the camera frustum
  87424. * Unlike isInFrustum this cheks the full bounding box
  87425. * @param target The object to check
  87426. * @returns true if the object is in frustum otherwise false
  87427. */
  87428. isCompletelyInFrustum(target: ICullable): boolean;
  87429. /**
  87430. * Gets a ray in the forward direction from the camera.
  87431. * @param length Defines the length of the ray to create
  87432. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  87433. * @param origin Defines the start point of the ray which defaults to the camera position
  87434. * @returns the forward ray
  87435. */
  87436. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  87437. /**
  87438. * Releases resources associated with this node.
  87439. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87440. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87441. */
  87442. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87443. /** @hidden */
  87444. _isLeftCamera: boolean;
  87445. /**
  87446. * Gets the left camera of a rig setup in case of Rigged Camera
  87447. */
  87448. readonly isLeftCamera: boolean;
  87449. /** @hidden */
  87450. _isRightCamera: boolean;
  87451. /**
  87452. * Gets the right camera of a rig setup in case of Rigged Camera
  87453. */
  87454. readonly isRightCamera: boolean;
  87455. /**
  87456. * Gets the left camera of a rig setup in case of Rigged Camera
  87457. */
  87458. readonly leftCamera: Nullable<FreeCamera>;
  87459. /**
  87460. * Gets the right camera of a rig setup in case of Rigged Camera
  87461. */
  87462. readonly rightCamera: Nullable<FreeCamera>;
  87463. /**
  87464. * Gets the left camera target of a rig setup in case of Rigged Camera
  87465. * @returns the target position
  87466. */
  87467. getLeftTarget(): Nullable<Vector3>;
  87468. /**
  87469. * Gets the right camera target of a rig setup in case of Rigged Camera
  87470. * @returns the target position
  87471. */
  87472. getRightTarget(): Nullable<Vector3>;
  87473. /**
  87474. * @hidden
  87475. */
  87476. setCameraRigMode(mode: number, rigParams: any): void;
  87477. /** @hidden */
  87478. static _setStereoscopicRigMode(camera: Camera): void;
  87479. /** @hidden */
  87480. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  87481. /** @hidden */
  87482. static _setVRRigMode(camera: Camera, rigParams: any): void;
  87483. /** @hidden */
  87484. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  87485. /** @hidden */
  87486. _getVRProjectionMatrix(): Matrix;
  87487. protected _updateCameraRotationMatrix(): void;
  87488. protected _updateWebVRCameraRotationMatrix(): void;
  87489. /**
  87490. * This function MUST be overwritten by the different WebVR cameras available.
  87491. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87492. * @hidden
  87493. */
  87494. _getWebVRProjectionMatrix(): Matrix;
  87495. /**
  87496. * This function MUST be overwritten by the different WebVR cameras available.
  87497. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87498. * @hidden
  87499. */
  87500. _getWebVRViewMatrix(): Matrix;
  87501. /** @hidden */
  87502. setCameraRigParameter(name: string, value: any): void;
  87503. /**
  87504. * needs to be overridden by children so sub has required properties to be copied
  87505. * @hidden
  87506. */
  87507. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  87508. /**
  87509. * May need to be overridden by children
  87510. * @hidden
  87511. */
  87512. _updateRigCameras(): void;
  87513. /** @hidden */
  87514. _setupInputs(): void;
  87515. /**
  87516. * Serialiaze the camera setup to a json represention
  87517. * @returns the JSON representation
  87518. */
  87519. serialize(): any;
  87520. /**
  87521. * Clones the current camera.
  87522. * @param name The cloned camera name
  87523. * @returns the cloned camera
  87524. */
  87525. clone(name: string): Camera;
  87526. /**
  87527. * Gets the direction of the camera relative to a given local axis.
  87528. * @param localAxis Defines the reference axis to provide a relative direction.
  87529. * @return the direction
  87530. */
  87531. getDirection(localAxis: Vector3): Vector3;
  87532. /**
  87533. * Gets the direction of the camera relative to a given local axis into a passed vector.
  87534. * @param localAxis Defines the reference axis to provide a relative direction.
  87535. * @param result Defines the vector to store the result in
  87536. */
  87537. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  87538. /**
  87539. * Gets a camera constructor for a given camera type
  87540. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  87541. * @param name The name of the camera the result will be able to instantiate
  87542. * @param scene The scene the result will construct the camera in
  87543. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  87544. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  87545. * @returns a factory method to construc the camera
  87546. */
  87547. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  87548. /**
  87549. * Compute the world matrix of the camera.
  87550. * @returns the camera workd matrix
  87551. */
  87552. computeWorldMatrix(): Matrix;
  87553. /**
  87554. * Parse a JSON and creates the camera from the parsed information
  87555. * @param parsedCamera The JSON to parse
  87556. * @param scene The scene to instantiate the camera in
  87557. * @returns the newly constructed camera
  87558. */
  87559. static Parse(parsedCamera: any, scene: Scene): Camera;
  87560. }
  87561. }
  87562. declare module BABYLON {
  87563. /**
  87564. * Interface for any object that can request an animation frame
  87565. */
  87566. export interface ICustomAnimationFrameRequester {
  87567. /**
  87568. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  87569. */
  87570. renderFunction?: Function;
  87571. /**
  87572. * Called to request the next frame to render to
  87573. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  87574. */
  87575. requestAnimationFrame: Function;
  87576. /**
  87577. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  87578. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  87579. */
  87580. requestID?: number;
  87581. }
  87582. /**
  87583. * Interface containing an array of animations
  87584. */
  87585. export interface IAnimatable {
  87586. /**
  87587. * Array of animations
  87588. */
  87589. animations: Array<Animation>;
  87590. }
  87591. /** Interface used by value gradients (color, factor, ...) */
  87592. export interface IValueGradient {
  87593. /**
  87594. * Gets or sets the gradient value (between 0 and 1)
  87595. */
  87596. gradient: number;
  87597. }
  87598. /** Class used to store color4 gradient */
  87599. export class ColorGradient implements IValueGradient {
  87600. /**
  87601. * Gets or sets the gradient value (between 0 and 1)
  87602. */
  87603. gradient: number;
  87604. /**
  87605. * Gets or sets first associated color
  87606. */
  87607. color1: Color4;
  87608. /**
  87609. * Gets or sets second associated color
  87610. */
  87611. color2?: Color4;
  87612. /**
  87613. * Will get a color picked randomly between color1 and color2.
  87614. * If color2 is undefined then color1 will be used
  87615. * @param result defines the target Color4 to store the result in
  87616. */
  87617. getColorToRef(result: Color4): void;
  87618. }
  87619. /** Class used to store color 3 gradient */
  87620. export class Color3Gradient implements IValueGradient {
  87621. /**
  87622. * Gets or sets the gradient value (between 0 and 1)
  87623. */
  87624. gradient: number;
  87625. /**
  87626. * Gets or sets the associated color
  87627. */
  87628. color: Color3;
  87629. }
  87630. /** Class used to store factor gradient */
  87631. export class FactorGradient implements IValueGradient {
  87632. /**
  87633. * Gets or sets the gradient value (between 0 and 1)
  87634. */
  87635. gradient: number;
  87636. /**
  87637. * Gets or sets first associated factor
  87638. */
  87639. factor1: number;
  87640. /**
  87641. * Gets or sets second associated factor
  87642. */
  87643. factor2?: number;
  87644. /**
  87645. * Will get a number picked randomly between factor1 and factor2.
  87646. * If factor2 is undefined then factor1 will be used
  87647. * @returns the picked number
  87648. */
  87649. getFactor(): number;
  87650. }
  87651. /**
  87652. * @ignore
  87653. * Application error to support additional information when loading a file
  87654. */
  87655. export class LoadFileError extends Error {
  87656. /** defines the optional XHR request */
  87657. request?: XMLHttpRequest | undefined;
  87658. private static _setPrototypeOf;
  87659. /**
  87660. * Creates a new LoadFileError
  87661. * @param message defines the message of the error
  87662. * @param request defines the optional XHR request
  87663. */
  87664. constructor(message: string,
  87665. /** defines the optional XHR request */
  87666. request?: XMLHttpRequest | undefined);
  87667. }
  87668. /**
  87669. * Class used to define a retry strategy when error happens while loading assets
  87670. */
  87671. export class RetryStrategy {
  87672. /**
  87673. * Function used to defines an exponential back off strategy
  87674. * @param maxRetries defines the maximum number of retries (3 by default)
  87675. * @param baseInterval defines the interval between retries
  87676. * @returns the strategy function to use
  87677. */
  87678. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  87679. }
  87680. /**
  87681. * File request interface
  87682. */
  87683. export interface IFileRequest {
  87684. /**
  87685. * Raised when the request is complete (success or error).
  87686. */
  87687. onCompleteObservable: Observable<IFileRequest>;
  87688. /**
  87689. * Aborts the request for a file.
  87690. */
  87691. abort: () => void;
  87692. }
  87693. /**
  87694. * Class containing a set of static utilities functions
  87695. */
  87696. export class Tools {
  87697. /**
  87698. * Gets or sets the base URL to use to load assets
  87699. */
  87700. static BaseUrl: string;
  87701. /**
  87702. * Enable/Disable Custom HTTP Request Headers globally.
  87703. * default = false
  87704. * @see CustomRequestHeaders
  87705. */
  87706. static UseCustomRequestHeaders: boolean;
  87707. /**
  87708. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  87709. * i.e. when loading files, where the server/service expects an Authorization header.
  87710. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  87711. */
  87712. static CustomRequestHeaders: {
  87713. [key: string]: string;
  87714. };
  87715. /**
  87716. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  87717. */
  87718. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  87719. /**
  87720. * Default behaviour for cors in the application.
  87721. * It can be a string if the expected behavior is identical in the entire app.
  87722. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  87723. */
  87724. static CorsBehavior: string | ((url: string | string[]) => string);
  87725. /**
  87726. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  87727. * @ignorenaming
  87728. */
  87729. static UseFallbackTexture: boolean;
  87730. /**
  87731. * Use this object to register external classes like custom textures or material
  87732. * to allow the laoders to instantiate them
  87733. */
  87734. static RegisteredExternalClasses: {
  87735. [key: string]: Object;
  87736. };
  87737. /**
  87738. * Texture content used if a texture cannot loaded
  87739. * @ignorenaming
  87740. */
  87741. static fallbackTexture: string;
  87742. /**
  87743. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  87744. * @param u defines the coordinate on X axis
  87745. * @param v defines the coordinate on Y axis
  87746. * @param width defines the width of the source data
  87747. * @param height defines the height of the source data
  87748. * @param pixels defines the source byte array
  87749. * @param color defines the output color
  87750. */
  87751. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  87752. /**
  87753. * Interpolates between a and b via alpha
  87754. * @param a The lower value (returned when alpha = 0)
  87755. * @param b The upper value (returned when alpha = 1)
  87756. * @param alpha The interpolation-factor
  87757. * @return The mixed value
  87758. */
  87759. static Mix(a: number, b: number, alpha: number): number;
  87760. /**
  87761. * Tries to instantiate a new object from a given class name
  87762. * @param className defines the class name to instantiate
  87763. * @returns the new object or null if the system was not able to do the instantiation
  87764. */
  87765. static Instantiate(className: string): any;
  87766. /**
  87767. * Provides a slice function that will work even on IE
  87768. * @param data defines the array to slice
  87769. * @param start defines the start of the data (optional)
  87770. * @param end defines the end of the data (optional)
  87771. * @returns the new sliced array
  87772. */
  87773. static Slice<T>(data: T, start?: number, end?: number): T;
  87774. /**
  87775. * Polyfill for setImmediate
  87776. * @param action defines the action to execute after the current execution block
  87777. */
  87778. static SetImmediate(action: () => void): void;
  87779. /**
  87780. * Function indicating if a number is an exponent of 2
  87781. * @param value defines the value to test
  87782. * @returns true if the value is an exponent of 2
  87783. */
  87784. static IsExponentOfTwo(value: number): boolean;
  87785. private static _tmpFloatArray;
  87786. /**
  87787. * Returns the nearest 32-bit single precision float representation of a Number
  87788. * @param value A Number. If the parameter is of a different type, it will get converted
  87789. * to a number or to NaN if it cannot be converted
  87790. * @returns number
  87791. */
  87792. static FloatRound(value: number): number;
  87793. /**
  87794. * Find the next highest power of two.
  87795. * @param x Number to start search from.
  87796. * @return Next highest power of two.
  87797. */
  87798. static CeilingPOT(x: number): number;
  87799. /**
  87800. * Find the next lowest power of two.
  87801. * @param x Number to start search from.
  87802. * @return Next lowest power of two.
  87803. */
  87804. static FloorPOT(x: number): number;
  87805. /**
  87806. * Find the nearest power of two.
  87807. * @param x Number to start search from.
  87808. * @return Next nearest power of two.
  87809. */
  87810. static NearestPOT(x: number): number;
  87811. /**
  87812. * Get the closest exponent of two
  87813. * @param value defines the value to approximate
  87814. * @param max defines the maximum value to return
  87815. * @param mode defines how to define the closest value
  87816. * @returns closest exponent of two of the given value
  87817. */
  87818. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  87819. /**
  87820. * Extracts the filename from a path
  87821. * @param path defines the path to use
  87822. * @returns the filename
  87823. */
  87824. static GetFilename(path: string): string;
  87825. /**
  87826. * Extracts the "folder" part of a path (everything before the filename).
  87827. * @param uri The URI to extract the info from
  87828. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  87829. * @returns The "folder" part of the path
  87830. */
  87831. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  87832. /**
  87833. * Extracts text content from a DOM element hierarchy
  87834. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  87835. */
  87836. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  87837. /**
  87838. * Convert an angle in radians to degrees
  87839. * @param angle defines the angle to convert
  87840. * @returns the angle in degrees
  87841. */
  87842. static ToDegrees(angle: number): number;
  87843. /**
  87844. * Convert an angle in degrees to radians
  87845. * @param angle defines the angle to convert
  87846. * @returns the angle in radians
  87847. */
  87848. static ToRadians(angle: number): number;
  87849. /**
  87850. * Encode a buffer to a base64 string
  87851. * @param buffer defines the buffer to encode
  87852. * @returns the encoded string
  87853. */
  87854. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  87855. /**
  87856. * Extracts minimum and maximum values from a list of indexed positions
  87857. * @param positions defines the positions to use
  87858. * @param indices defines the indices to the positions
  87859. * @param indexStart defines the start index
  87860. * @param indexCount defines the end index
  87861. * @param bias defines bias value to add to the result
  87862. * @return minimum and maximum values
  87863. */
  87864. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87865. minimum: Vector3;
  87866. maximum: Vector3;
  87867. };
  87868. /**
  87869. * Extracts minimum and maximum values from a list of positions
  87870. * @param positions defines the positions to use
  87871. * @param start defines the start index in the positions array
  87872. * @param count defines the number of positions to handle
  87873. * @param bias defines bias value to add to the result
  87874. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87875. * @return minimum and maximum values
  87876. */
  87877. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87878. minimum: Vector3;
  87879. maximum: Vector3;
  87880. };
  87881. /**
  87882. * Returns an array if obj is not an array
  87883. * @param obj defines the object to evaluate as an array
  87884. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  87885. * @returns either obj directly if obj is an array or a new array containing obj
  87886. */
  87887. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  87888. /**
  87889. * Gets the pointer prefix to use
  87890. * @returns "pointer" if touch is enabled. Else returns "mouse"
  87891. */
  87892. static GetPointerPrefix(): string;
  87893. /**
  87894. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  87895. * @param func - the function to be called
  87896. * @param requester - the object that will request the next frame. Falls back to window.
  87897. * @returns frame number
  87898. */
  87899. static QueueNewFrame(func: () => void, requester?: any): number;
  87900. /**
  87901. * Ask the browser to promote the current element to fullscreen rendering mode
  87902. * @param element defines the DOM element to promote
  87903. */
  87904. static RequestFullscreen(element: HTMLElement): void;
  87905. /**
  87906. * Asks the browser to exit fullscreen mode
  87907. */
  87908. static ExitFullscreen(): void;
  87909. /**
  87910. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  87911. * @param url define the url we are trying
  87912. * @param element define the dom element where to configure the cors policy
  87913. */
  87914. static SetCorsBehavior(url: string | string[], element: {
  87915. crossOrigin: string | null;
  87916. }): void;
  87917. /**
  87918. * Removes unwanted characters from an url
  87919. * @param url defines the url to clean
  87920. * @returns the cleaned url
  87921. */
  87922. static CleanUrl(url: string): string;
  87923. /**
  87924. * Gets or sets a function used to pre-process url before using them to load assets
  87925. */
  87926. static PreprocessUrl: (url: string) => string;
  87927. /**
  87928. * Loads an image as an HTMLImageElement.
  87929. * @param input url string, ArrayBuffer, or Blob to load
  87930. * @param onLoad callback called when the image successfully loads
  87931. * @param onError callback called when the image fails to load
  87932. * @param offlineProvider offline provider for caching
  87933. * @returns the HTMLImageElement of the loaded image
  87934. */
  87935. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  87936. /**
  87937. * Loads a file
  87938. * @param url url string, ArrayBuffer, or Blob to load
  87939. * @param onSuccess callback called when the file successfully loads
  87940. * @param onProgress callback called while file is loading (if the server supports this mode)
  87941. * @param offlineProvider defines the offline provider for caching
  87942. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  87943. * @param onError callback called when the file fails to load
  87944. * @returns a file request object
  87945. */
  87946. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  87947. /**
  87948. * Load a script (identified by an url). When the url returns, the
  87949. * content of this file is added into a new script element, attached to the DOM (body element)
  87950. * @param scriptUrl defines the url of the script to laod
  87951. * @param onSuccess defines the callback called when the script is loaded
  87952. * @param onError defines the callback to call if an error occurs
  87953. */
  87954. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  87955. /**
  87956. * Loads a file from a blob
  87957. * @param fileToLoad defines the blob to use
  87958. * @param callback defines the callback to call when data is loaded
  87959. * @param progressCallback defines the callback to call during loading process
  87960. * @returns a file request object
  87961. */
  87962. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  87963. /**
  87964. * Loads a file
  87965. * @param fileToLoad defines the file to load
  87966. * @param callback defines the callback to call when data is loaded
  87967. * @param progressCallBack defines the callback to call during loading process
  87968. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  87969. * @returns a file request object
  87970. */
  87971. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  87972. /**
  87973. * Creates a data url from a given string content
  87974. * @param content defines the content to convert
  87975. * @returns the new data url link
  87976. */
  87977. static FileAsURL(content: string): string;
  87978. /**
  87979. * Format the given number to a specific decimal format
  87980. * @param value defines the number to format
  87981. * @param decimals defines the number of decimals to use
  87982. * @returns the formatted string
  87983. */
  87984. static Format(value: number, decimals?: number): string;
  87985. /**
  87986. * Checks if a given vector is inside a specific range
  87987. * @param v defines the vector to test
  87988. * @param min defines the minimum range
  87989. * @param max defines the maximum range
  87990. */
  87991. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  87992. /**
  87993. * Tries to copy an object by duplicating every property
  87994. * @param source defines the source object
  87995. * @param destination defines the target object
  87996. * @param doNotCopyList defines a list of properties to avoid
  87997. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  87998. */
  87999. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  88000. /**
  88001. * Gets a boolean indicating if the given object has no own property
  88002. * @param obj defines the object to test
  88003. * @returns true if object has no own property
  88004. */
  88005. static IsEmpty(obj: any): boolean;
  88006. /**
  88007. * Function used to register events at window level
  88008. * @param events defines the events to register
  88009. */
  88010. static RegisterTopRootEvents(events: {
  88011. name: string;
  88012. handler: Nullable<(e: FocusEvent) => any>;
  88013. }[]): void;
  88014. /**
  88015. * Function used to unregister events from window level
  88016. * @param events defines the events to unregister
  88017. */
  88018. static UnregisterTopRootEvents(events: {
  88019. name: string;
  88020. handler: Nullable<(e: FocusEvent) => any>;
  88021. }[]): void;
  88022. /**
  88023. * @ignore
  88024. */
  88025. static _ScreenshotCanvas: HTMLCanvasElement;
  88026. /**
  88027. * Dumps the current bound framebuffer
  88028. * @param width defines the rendering width
  88029. * @param height defines the rendering height
  88030. * @param engine defines the hosting engine
  88031. * @param successCallback defines the callback triggered once the data are available
  88032. * @param mimeType defines the mime type of the result
  88033. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  88034. */
  88035. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  88036. /**
  88037. * Converts the canvas data to blob.
  88038. * This acts as a polyfill for browsers not supporting the to blob function.
  88039. * @param canvas Defines the canvas to extract the data from
  88040. * @param successCallback Defines the callback triggered once the data are available
  88041. * @param mimeType Defines the mime type of the result
  88042. */
  88043. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  88044. /**
  88045. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  88046. * @param successCallback defines the callback triggered once the data are available
  88047. * @param mimeType defines the mime type of the result
  88048. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  88049. */
  88050. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  88051. /**
  88052. * Downloads a blob in the browser
  88053. * @param blob defines the blob to download
  88054. * @param fileName defines the name of the downloaded file
  88055. */
  88056. static Download(blob: Blob, fileName: string): void;
  88057. /**
  88058. * Captures a screenshot of the current rendering
  88059. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  88060. * @param engine defines the rendering engine
  88061. * @param camera defines the source camera
  88062. * @param size This parameter can be set to a single number or to an object with the
  88063. * following (optional) properties: precision, width, height. If a single number is passed,
  88064. * it will be used for both width and height. If an object is passed, the screenshot size
  88065. * will be derived from the parameters. The precision property is a multiplier allowing
  88066. * rendering at a higher or lower resolution
  88067. * @param successCallback defines the callback receives a single parameter which contains the
  88068. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  88069. * src parameter of an <img> to display it
  88070. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  88071. * Check your browser for supported MIME types
  88072. */
  88073. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  88074. /**
  88075. * Generates an image screenshot from the specified camera.
  88076. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  88077. * @param engine The engine to use for rendering
  88078. * @param camera The camera to use for rendering
  88079. * @param size This parameter can be set to a single number or to an object with the
  88080. * following (optional) properties: precision, width, height. If a single number is passed,
  88081. * it will be used for both width and height. If an object is passed, the screenshot size
  88082. * will be derived from the parameters. The precision property is a multiplier allowing
  88083. * rendering at a higher or lower resolution
  88084. * @param successCallback The callback receives a single parameter which contains the
  88085. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  88086. * src parameter of an <img> to display it
  88087. * @param mimeType The MIME type of the screenshot image (default: image/png).
  88088. * Check your browser for supported MIME types
  88089. * @param samples Texture samples (default: 1)
  88090. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  88091. * @param fileName A name for for the downloaded file.
  88092. */
  88093. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  88094. /**
  88095. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88096. * Be aware Math.random() could cause collisions, but:
  88097. * "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"
  88098. * @returns a pseudo random id
  88099. */
  88100. static RandomId(): string;
  88101. /**
  88102. * Test if the given uri is a base64 string
  88103. * @param uri The uri to test
  88104. * @return True if the uri is a base64 string or false otherwise
  88105. */
  88106. static IsBase64(uri: string): boolean;
  88107. /**
  88108. * Decode the given base64 uri.
  88109. * @param uri The uri to decode
  88110. * @return The decoded base64 data.
  88111. */
  88112. static DecodeBase64(uri: string): ArrayBuffer;
  88113. /**
  88114. * No log
  88115. */
  88116. static readonly NoneLogLevel: number;
  88117. /**
  88118. * Only message logs
  88119. */
  88120. static readonly MessageLogLevel: number;
  88121. /**
  88122. * Only warning logs
  88123. */
  88124. static readonly WarningLogLevel: number;
  88125. /**
  88126. * Only error logs
  88127. */
  88128. static readonly ErrorLogLevel: number;
  88129. /**
  88130. * All logs
  88131. */
  88132. static readonly AllLogLevel: number;
  88133. /**
  88134. * Gets a value indicating the number of loading errors
  88135. * @ignorenaming
  88136. */
  88137. static readonly errorsCount: number;
  88138. /**
  88139. * Callback called when a new log is added
  88140. */
  88141. static OnNewCacheEntry: (entry: string) => void;
  88142. /**
  88143. * Log a message to the console
  88144. * @param message defines the message to log
  88145. */
  88146. static Log(message: string): void;
  88147. /**
  88148. * Write a warning message to the console
  88149. * @param message defines the message to log
  88150. */
  88151. static Warn(message: string): void;
  88152. /**
  88153. * Write an error message to the console
  88154. * @param message defines the message to log
  88155. */
  88156. static Error(message: string): void;
  88157. /**
  88158. * Gets current log cache (list of logs)
  88159. */
  88160. static readonly LogCache: string;
  88161. /**
  88162. * Clears the log cache
  88163. */
  88164. static ClearLogCache(): void;
  88165. /**
  88166. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  88167. */
  88168. static LogLevels: number;
  88169. /**
  88170. * Checks if the loaded document was accessed via `file:`-Protocol.
  88171. * @returns boolean
  88172. */
  88173. static IsFileURL(): boolean;
  88174. /**
  88175. * Checks if the window object exists
  88176. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  88177. */
  88178. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  88179. /**
  88180. * No performance log
  88181. */
  88182. static readonly PerformanceNoneLogLevel: number;
  88183. /**
  88184. * Use user marks to log performance
  88185. */
  88186. static readonly PerformanceUserMarkLogLevel: number;
  88187. /**
  88188. * Log performance to the console
  88189. */
  88190. static readonly PerformanceConsoleLogLevel: number;
  88191. private static _performance;
  88192. /**
  88193. * Sets the current performance log level
  88194. */
  88195. static PerformanceLogLevel: number;
  88196. private static _StartPerformanceCounterDisabled;
  88197. private static _EndPerformanceCounterDisabled;
  88198. private static _StartUserMark;
  88199. private static _EndUserMark;
  88200. private static _StartPerformanceConsole;
  88201. private static _EndPerformanceConsole;
  88202. /**
  88203. * Injects the @see CustomRequestHeaders into the given request
  88204. * @param request the request that should be used for injection
  88205. */
  88206. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  88207. /**
  88208. * Starts a performance counter
  88209. */
  88210. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  88211. /**
  88212. * Ends a specific performance coutner
  88213. */
  88214. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  88215. /**
  88216. * Gets either window.performance.now() if supported or Date.now() else
  88217. */
  88218. static readonly Now: number;
  88219. /**
  88220. * This method will return the name of the class used to create the instance of the given object.
  88221. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  88222. * @param object the object to get the class name from
  88223. * @param isType defines if the object is actually a type
  88224. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  88225. */
  88226. static GetClassName(object: any, isType?: boolean): string;
  88227. /**
  88228. * Gets the first element of an array satisfying a given predicate
  88229. * @param array defines the array to browse
  88230. * @param predicate defines the predicate to use
  88231. * @returns null if not found or the element
  88232. */
  88233. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  88234. /**
  88235. * This method will return the name of the full name of the class, including its owning module (if any).
  88236. * 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).
  88237. * @param object the object to get the class name from
  88238. * @param isType defines if the object is actually a type
  88239. * @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.
  88240. * @ignorenaming
  88241. */
  88242. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  88243. /**
  88244. * Returns a promise that resolves after the given amount of time.
  88245. * @param delay Number of milliseconds to delay
  88246. * @returns Promise that resolves after the given amount of time
  88247. */
  88248. static DelayAsync(delay: number): Promise<void>;
  88249. /**
  88250. * Gets the current gradient from an array of IValueGradient
  88251. * @param ratio defines the current ratio to get
  88252. * @param gradients defines the array of IValueGradient
  88253. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88254. */
  88255. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88256. }
  88257. /**
  88258. * This class is used to track a performance counter which is number based.
  88259. * The user has access to many properties which give statistics of different nature.
  88260. *
  88261. * The implementer can track two kinds of Performance Counter: time and count.
  88262. * 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.
  88263. * 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.
  88264. */
  88265. export class PerfCounter {
  88266. /**
  88267. * Gets or sets a global boolean to turn on and off all the counters
  88268. */
  88269. static Enabled: boolean;
  88270. /**
  88271. * Returns the smallest value ever
  88272. */
  88273. readonly min: number;
  88274. /**
  88275. * Returns the biggest value ever
  88276. */
  88277. readonly max: number;
  88278. /**
  88279. * Returns the average value since the performance counter is running
  88280. */
  88281. readonly average: number;
  88282. /**
  88283. * Returns the average value of the last second the counter was monitored
  88284. */
  88285. readonly lastSecAverage: number;
  88286. /**
  88287. * Returns the current value
  88288. */
  88289. readonly current: number;
  88290. /**
  88291. * Gets the accumulated total
  88292. */
  88293. readonly total: number;
  88294. /**
  88295. * Gets the total value count
  88296. */
  88297. readonly count: number;
  88298. /**
  88299. * Creates a new counter
  88300. */
  88301. constructor();
  88302. /**
  88303. * Call this method to start monitoring a new frame.
  88304. * 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.
  88305. */
  88306. fetchNewFrame(): void;
  88307. /**
  88308. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  88309. * @param newCount the count value to add to the monitored count
  88310. * @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.
  88311. */
  88312. addCount(newCount: number, fetchResult: boolean): void;
  88313. /**
  88314. * Start monitoring this performance counter
  88315. */
  88316. beginMonitoring(): void;
  88317. /**
  88318. * Compute the time lapsed since the previous beginMonitoring() call.
  88319. * @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
  88320. */
  88321. endMonitoring(newFrame?: boolean): void;
  88322. private _fetchResult;
  88323. private _startMonitoringTime;
  88324. private _min;
  88325. private _max;
  88326. private _average;
  88327. private _current;
  88328. private _totalValueCount;
  88329. private _totalAccumulated;
  88330. private _lastSecAverage;
  88331. private _lastSecAccumulated;
  88332. private _lastSecTime;
  88333. private _lastSecValueCount;
  88334. }
  88335. /**
  88336. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  88337. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  88338. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  88339. * @param name The name of the class, case should be preserved
  88340. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  88341. */
  88342. export function className(name: string, module?: string): (target: Object) => void;
  88343. /**
  88344. * An implementation of a loop for asynchronous functions.
  88345. */
  88346. export class AsyncLoop {
  88347. /**
  88348. * Defines the number of iterations for the loop
  88349. */
  88350. iterations: number;
  88351. /**
  88352. * Defines the current index of the loop.
  88353. */
  88354. index: number;
  88355. private _done;
  88356. private _fn;
  88357. private _successCallback;
  88358. /**
  88359. * Constructor.
  88360. * @param iterations the number of iterations.
  88361. * @param func the function to run each iteration
  88362. * @param successCallback the callback that will be called upon succesful execution
  88363. * @param offset starting offset.
  88364. */
  88365. constructor(
  88366. /**
  88367. * Defines the number of iterations for the loop
  88368. */
  88369. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  88370. /**
  88371. * Execute the next iteration. Must be called after the last iteration was finished.
  88372. */
  88373. executeNext(): void;
  88374. /**
  88375. * Break the loop and run the success callback.
  88376. */
  88377. breakLoop(): void;
  88378. /**
  88379. * Create and run an async loop.
  88380. * @param iterations the number of iterations.
  88381. * @param fn the function to run each iteration
  88382. * @param successCallback the callback that will be called upon succesful execution
  88383. * @param offset starting offset.
  88384. * @returns the created async loop object
  88385. */
  88386. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  88387. /**
  88388. * A for-loop that will run a given number of iterations synchronous and the rest async.
  88389. * @param iterations total number of iterations
  88390. * @param syncedIterations number of synchronous iterations in each async iteration.
  88391. * @param fn the function to call each iteration.
  88392. * @param callback a success call back that will be called when iterating stops.
  88393. * @param breakFunction a break condition (optional)
  88394. * @param timeout timeout settings for the setTimeout function. default - 0.
  88395. * @returns the created async loop object
  88396. */
  88397. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  88398. }
  88399. }
  88400. declare module BABYLON {
  88401. /** @hidden */
  88402. export interface ICollisionCoordinator {
  88403. createCollider(): Collider;
  88404. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88405. init(scene: Scene): void;
  88406. }
  88407. /** @hidden */
  88408. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  88409. private _scene;
  88410. private _scaledPosition;
  88411. private _scaledVelocity;
  88412. private _finalPosition;
  88413. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88414. createCollider(): Collider;
  88415. init(scene: Scene): void;
  88416. private _collideWithWorld;
  88417. }
  88418. }
  88419. declare module BABYLON {
  88420. /**
  88421. * This class defines the direct association between an animation and a target
  88422. */
  88423. export class TargetedAnimation {
  88424. /**
  88425. * Animation to perform
  88426. */
  88427. animation: Animation;
  88428. /**
  88429. * Target to animate
  88430. */
  88431. target: any;
  88432. }
  88433. /**
  88434. * Use this class to create coordinated animations on multiple targets
  88435. */
  88436. export class AnimationGroup implements IDisposable {
  88437. /** The name of the animation group */
  88438. name: string;
  88439. private _scene;
  88440. private _targetedAnimations;
  88441. private _animatables;
  88442. private _from;
  88443. private _to;
  88444. private _isStarted;
  88445. private _isPaused;
  88446. private _speedRatio;
  88447. /**
  88448. * Gets or sets the unique id of the node
  88449. */
  88450. uniqueId: number;
  88451. /**
  88452. * This observable will notify when one animation have ended
  88453. */
  88454. onAnimationEndObservable: Observable<TargetedAnimation>;
  88455. /**
  88456. * Observer raised when one animation loops
  88457. */
  88458. onAnimationLoopObservable: Observable<TargetedAnimation>;
  88459. /**
  88460. * This observable will notify when all animations have ended.
  88461. */
  88462. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  88463. /**
  88464. * This observable will notify when all animations have paused.
  88465. */
  88466. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  88467. /**
  88468. * This observable will notify when all animations are playing.
  88469. */
  88470. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  88471. /**
  88472. * Gets the first frame
  88473. */
  88474. readonly from: number;
  88475. /**
  88476. * Gets the last frame
  88477. */
  88478. readonly to: number;
  88479. /**
  88480. * Define if the animations are started
  88481. */
  88482. readonly isStarted: boolean;
  88483. /**
  88484. * Gets a value indicating that the current group is playing
  88485. */
  88486. readonly isPlaying: boolean;
  88487. /**
  88488. * Gets or sets the speed ratio to use for all animations
  88489. */
  88490. /**
  88491. * Gets or sets the speed ratio to use for all animations
  88492. */
  88493. speedRatio: number;
  88494. /**
  88495. * Gets the targeted animations for this animation group
  88496. */
  88497. readonly targetedAnimations: Array<TargetedAnimation>;
  88498. /**
  88499. * returning the list of animatables controlled by this animation group.
  88500. */
  88501. readonly animatables: Array<Animatable>;
  88502. /**
  88503. * Instantiates a new Animation Group.
  88504. * This helps managing several animations at once.
  88505. * @see http://doc.babylonjs.com/how_to/group
  88506. * @param name Defines the name of the group
  88507. * @param scene Defines the scene the group belongs to
  88508. */
  88509. constructor(
  88510. /** The name of the animation group */
  88511. name: string, scene?: Nullable<Scene>);
  88512. /**
  88513. * Add an animation (with its target) in the group
  88514. * @param animation defines the animation we want to add
  88515. * @param target defines the target of the animation
  88516. * @returns the TargetedAnimation object
  88517. */
  88518. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  88519. /**
  88520. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  88521. * It can add constant keys at begin or end
  88522. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  88523. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  88524. * @returns the animation group
  88525. */
  88526. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  88527. /**
  88528. * Start all animations on given targets
  88529. * @param loop defines if animations must loop
  88530. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  88531. * @param from defines the from key (optional)
  88532. * @param to defines the to key (optional)
  88533. * @returns the current animation group
  88534. */
  88535. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  88536. /**
  88537. * Pause all animations
  88538. * @returns the animation group
  88539. */
  88540. pause(): AnimationGroup;
  88541. /**
  88542. * Play all animations to initial state
  88543. * This function will start() the animations if they were not started or will restart() them if they were paused
  88544. * @param loop defines if animations must loop
  88545. * @returns the animation group
  88546. */
  88547. play(loop?: boolean): AnimationGroup;
  88548. /**
  88549. * Reset all animations to initial state
  88550. * @returns the animation group
  88551. */
  88552. reset(): AnimationGroup;
  88553. /**
  88554. * Restart animations from key 0
  88555. * @returns the animation group
  88556. */
  88557. restart(): AnimationGroup;
  88558. /**
  88559. * Stop all animations
  88560. * @returns the animation group
  88561. */
  88562. stop(): AnimationGroup;
  88563. /**
  88564. * Set animation weight for all animatables
  88565. * @param weight defines the weight to use
  88566. * @return the animationGroup
  88567. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88568. */
  88569. setWeightForAllAnimatables(weight: number): AnimationGroup;
  88570. /**
  88571. * Synchronize and normalize all animatables with a source animatable
  88572. * @param root defines the root animatable to synchronize with
  88573. * @return the animationGroup
  88574. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88575. */
  88576. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  88577. /**
  88578. * Goes to a specific frame in this animation group
  88579. * @param frame the frame number to go to
  88580. * @return the animationGroup
  88581. */
  88582. goToFrame(frame: number): AnimationGroup;
  88583. /**
  88584. * Dispose all associated resources
  88585. */
  88586. dispose(): void;
  88587. private _checkAnimationGroupEnded;
  88588. /**
  88589. * Clone the current animation group and returns a copy
  88590. * @param newName defines the name of the new group
  88591. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  88592. * @returns the new aniamtion group
  88593. */
  88594. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  88595. /**
  88596. * Returns a new AnimationGroup object parsed from the source provided.
  88597. * @param parsedAnimationGroup defines the source
  88598. * @param scene defines the scene that will receive the animationGroup
  88599. * @returns a new AnimationGroup
  88600. */
  88601. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  88602. /**
  88603. * Returns the string "AnimationGroup"
  88604. * @returns "AnimationGroup"
  88605. */
  88606. getClassName(): string;
  88607. /**
  88608. * Creates a detailled string about the object
  88609. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  88610. * @returns a string representing the object
  88611. */
  88612. toString(fullDetails?: boolean): string;
  88613. }
  88614. }
  88615. declare module BABYLON {
  88616. /**
  88617. * Define an interface for all classes that will hold resources
  88618. */
  88619. export interface IDisposable {
  88620. /**
  88621. * Releases all held resources
  88622. */
  88623. dispose(): void;
  88624. }
  88625. /** Interface defining initialization parameters for Scene class */
  88626. export interface SceneOptions {
  88627. /**
  88628. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  88629. * It will improve performance when the number of geometries becomes important.
  88630. */
  88631. useGeometryUniqueIdsMap?: boolean;
  88632. /**
  88633. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  88634. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88635. */
  88636. useMaterialMeshMap?: boolean;
  88637. /**
  88638. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  88639. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88640. */
  88641. useClonedMeshhMap?: boolean;
  88642. }
  88643. /**
  88644. * Represents a scene to be rendered by the engine.
  88645. * @see http://doc.babylonjs.com/features/scene
  88646. */
  88647. export class Scene extends AbstractScene implements IAnimatable {
  88648. private static _uniqueIdCounter;
  88649. /** The fog is deactivated */
  88650. static readonly FOGMODE_NONE: number;
  88651. /** The fog density is following an exponential function */
  88652. static readonly FOGMODE_EXP: number;
  88653. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  88654. static readonly FOGMODE_EXP2: number;
  88655. /** The fog density is following a linear function. */
  88656. static readonly FOGMODE_LINEAR: number;
  88657. /**
  88658. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  88659. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88660. */
  88661. static MinDeltaTime: number;
  88662. /**
  88663. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  88664. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88665. */
  88666. static MaxDeltaTime: number;
  88667. /**
  88668. * Factory used to create the default material.
  88669. * @param name The name of the material to create
  88670. * @param scene The scene to create the material for
  88671. * @returns The default material
  88672. */
  88673. static DefaultMaterialFactory(scene: Scene): Material;
  88674. /**
  88675. * Factory used to create the a collision coordinator.
  88676. * @returns The collision coordinator
  88677. */
  88678. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  88679. /** @hidden */
  88680. readonly _isScene: boolean;
  88681. /**
  88682. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  88683. */
  88684. autoClear: boolean;
  88685. /**
  88686. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  88687. */
  88688. autoClearDepthAndStencil: boolean;
  88689. /**
  88690. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  88691. */
  88692. clearColor: Color4;
  88693. /**
  88694. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  88695. */
  88696. ambientColor: Color3;
  88697. /** @hidden */
  88698. _environmentBRDFTexture: BaseTexture;
  88699. /** @hidden */
  88700. protected _environmentTexture: Nullable<BaseTexture>;
  88701. /**
  88702. * Texture used in all pbr material as the reflection texture.
  88703. * As in the majority of the scene they are the same (exception for multi room and so on),
  88704. * this is easier to reference from here than from all the materials.
  88705. */
  88706. /**
  88707. * Texture used in all pbr material as the reflection texture.
  88708. * As in the majority of the scene they are the same (exception for multi room and so on),
  88709. * this is easier to set here than in all the materials.
  88710. */
  88711. environmentTexture: Nullable<BaseTexture>;
  88712. /** @hidden */
  88713. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  88714. /**
  88715. * Default image processing configuration used either in the rendering
  88716. * Forward main pass or through the imageProcessingPostProcess if present.
  88717. * As in the majority of the scene they are the same (exception for multi camera),
  88718. * this is easier to reference from here than from all the materials and post process.
  88719. *
  88720. * No setter as we it is a shared configuration, you can set the values instead.
  88721. */
  88722. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  88723. private _forceWireframe;
  88724. /**
  88725. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  88726. */
  88727. forceWireframe: boolean;
  88728. private _forcePointsCloud;
  88729. /**
  88730. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  88731. */
  88732. forcePointsCloud: boolean;
  88733. /**
  88734. * Gets or sets the active clipplane 1
  88735. */
  88736. clipPlane: Nullable<Plane>;
  88737. /**
  88738. * Gets or sets the active clipplane 2
  88739. */
  88740. clipPlane2: Nullable<Plane>;
  88741. /**
  88742. * Gets or sets the active clipplane 3
  88743. */
  88744. clipPlane3: Nullable<Plane>;
  88745. /**
  88746. * Gets or sets the active clipplane 4
  88747. */
  88748. clipPlane4: Nullable<Plane>;
  88749. /**
  88750. * Gets or sets a boolean indicating if animations are enabled
  88751. */
  88752. animationsEnabled: boolean;
  88753. private _animationPropertiesOverride;
  88754. /**
  88755. * Gets or sets the animation properties override
  88756. */
  88757. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88758. /**
  88759. * Gets or sets a boolean indicating if a constant deltatime has to be used
  88760. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  88761. */
  88762. useConstantAnimationDeltaTime: boolean;
  88763. /**
  88764. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  88765. * Please note that it requires to run a ray cast through the scene on every frame
  88766. */
  88767. constantlyUpdateMeshUnderPointer: boolean;
  88768. /**
  88769. * Defines the HTML cursor to use when hovering over interactive elements
  88770. */
  88771. hoverCursor: string;
  88772. /**
  88773. * Defines the HTML default cursor to use (empty by default)
  88774. */
  88775. defaultCursor: string;
  88776. /**
  88777. * This is used to call preventDefault() on pointer down
  88778. * in order to block unwanted artifacts like system double clicks
  88779. */
  88780. preventDefaultOnPointerDown: boolean;
  88781. /**
  88782. * This is used to call preventDefault() on pointer up
  88783. * in order to block unwanted artifacts like system double clicks
  88784. */
  88785. preventDefaultOnPointerUp: boolean;
  88786. /**
  88787. * Gets or sets user defined metadata
  88788. */
  88789. metadata: any;
  88790. /**
  88791. * For internal use only. Please do not use.
  88792. */
  88793. reservedDataStore: any;
  88794. /**
  88795. * Gets the name of the plugin used to load this scene (null by default)
  88796. */
  88797. loadingPluginName: string;
  88798. /**
  88799. * Use this array to add regular expressions used to disable offline support for specific urls
  88800. */
  88801. disableOfflineSupportExceptionRules: RegExp[];
  88802. /**
  88803. * An event triggered when the scene is disposed.
  88804. */
  88805. onDisposeObservable: Observable<Scene>;
  88806. private _onDisposeObserver;
  88807. /** Sets a function to be executed when this scene is disposed. */
  88808. onDispose: () => void;
  88809. /**
  88810. * An event triggered before rendering the scene (right after animations and physics)
  88811. */
  88812. onBeforeRenderObservable: Observable<Scene>;
  88813. private _onBeforeRenderObserver;
  88814. /** Sets a function to be executed before rendering this scene */
  88815. beforeRender: Nullable<() => void>;
  88816. /**
  88817. * An event triggered after rendering the scene
  88818. */
  88819. onAfterRenderObservable: Observable<Scene>;
  88820. private _onAfterRenderObserver;
  88821. /** Sets a function to be executed after rendering this scene */
  88822. afterRender: Nullable<() => void>;
  88823. /**
  88824. * An event triggered before animating the scene
  88825. */
  88826. onBeforeAnimationsObservable: Observable<Scene>;
  88827. /**
  88828. * An event triggered after animations processing
  88829. */
  88830. onAfterAnimationsObservable: Observable<Scene>;
  88831. /**
  88832. * An event triggered before draw calls are ready to be sent
  88833. */
  88834. onBeforeDrawPhaseObservable: Observable<Scene>;
  88835. /**
  88836. * An event triggered after draw calls have been sent
  88837. */
  88838. onAfterDrawPhaseObservable: Observable<Scene>;
  88839. /**
  88840. * An event triggered when the scene is ready
  88841. */
  88842. onReadyObservable: Observable<Scene>;
  88843. /**
  88844. * An event triggered before rendering a camera
  88845. */
  88846. onBeforeCameraRenderObservable: Observable<Camera>;
  88847. private _onBeforeCameraRenderObserver;
  88848. /** Sets a function to be executed before rendering a camera*/
  88849. beforeCameraRender: () => void;
  88850. /**
  88851. * An event triggered after rendering a camera
  88852. */
  88853. onAfterCameraRenderObservable: Observable<Camera>;
  88854. private _onAfterCameraRenderObserver;
  88855. /** Sets a function to be executed after rendering a camera*/
  88856. afterCameraRender: () => void;
  88857. /**
  88858. * An event triggered when active meshes evaluation is about to start
  88859. */
  88860. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  88861. /**
  88862. * An event triggered when active meshes evaluation is done
  88863. */
  88864. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  88865. /**
  88866. * An event triggered when particles rendering is about to start
  88867. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88868. */
  88869. onBeforeParticlesRenderingObservable: Observable<Scene>;
  88870. /**
  88871. * An event triggered when particles rendering is done
  88872. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88873. */
  88874. onAfterParticlesRenderingObservable: Observable<Scene>;
  88875. /**
  88876. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  88877. */
  88878. onDataLoadedObservable: Observable<Scene>;
  88879. /**
  88880. * An event triggered when a camera is created
  88881. */
  88882. onNewCameraAddedObservable: Observable<Camera>;
  88883. /**
  88884. * An event triggered when a camera is removed
  88885. */
  88886. onCameraRemovedObservable: Observable<Camera>;
  88887. /**
  88888. * An event triggered when a light is created
  88889. */
  88890. onNewLightAddedObservable: Observable<Light>;
  88891. /**
  88892. * An event triggered when a light is removed
  88893. */
  88894. onLightRemovedObservable: Observable<Light>;
  88895. /**
  88896. * An event triggered when a geometry is created
  88897. */
  88898. onNewGeometryAddedObservable: Observable<Geometry>;
  88899. /**
  88900. * An event triggered when a geometry is removed
  88901. */
  88902. onGeometryRemovedObservable: Observable<Geometry>;
  88903. /**
  88904. * An event triggered when a transform node is created
  88905. */
  88906. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  88907. /**
  88908. * An event triggered when a transform node is removed
  88909. */
  88910. onTransformNodeRemovedObservable: Observable<TransformNode>;
  88911. /**
  88912. * An event triggered when a mesh is created
  88913. */
  88914. onNewMeshAddedObservable: Observable<AbstractMesh>;
  88915. /**
  88916. * An event triggered when a mesh is removed
  88917. */
  88918. onMeshRemovedObservable: Observable<AbstractMesh>;
  88919. /**
  88920. * An event triggered when a material is created
  88921. */
  88922. onNewMaterialAddedObservable: Observable<Material>;
  88923. /**
  88924. * An event triggered when a material is removed
  88925. */
  88926. onMaterialRemovedObservable: Observable<Material>;
  88927. /**
  88928. * An event triggered when a texture is created
  88929. */
  88930. onNewTextureAddedObservable: Observable<BaseTexture>;
  88931. /**
  88932. * An event triggered when a texture is removed
  88933. */
  88934. onTextureRemovedObservable: Observable<BaseTexture>;
  88935. /**
  88936. * An event triggered when render targets are about to be rendered
  88937. * Can happen multiple times per frame.
  88938. */
  88939. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  88940. /**
  88941. * An event triggered when render targets were rendered.
  88942. * Can happen multiple times per frame.
  88943. */
  88944. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  88945. /**
  88946. * An event triggered before calculating deterministic simulation step
  88947. */
  88948. onBeforeStepObservable: Observable<Scene>;
  88949. /**
  88950. * An event triggered after calculating deterministic simulation step
  88951. */
  88952. onAfterStepObservable: Observable<Scene>;
  88953. /**
  88954. * An event triggered when the activeCamera property is updated
  88955. */
  88956. onActiveCameraChanged: Observable<Scene>;
  88957. /**
  88958. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  88959. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88960. * 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)
  88961. */
  88962. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88963. /**
  88964. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  88965. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88966. * 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)
  88967. */
  88968. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88969. /**
  88970. * This Observable will when a mesh has been imported into the scene.
  88971. */
  88972. onMeshImportedObservable: Observable<AbstractMesh>;
  88973. /**
  88974. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  88975. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  88976. */
  88977. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  88978. /** @hidden */
  88979. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  88980. /**
  88981. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  88982. */
  88983. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  88984. /**
  88985. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  88986. */
  88987. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  88988. /**
  88989. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  88990. */
  88991. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  88992. private _onPointerMove;
  88993. private _onPointerDown;
  88994. private _onPointerUp;
  88995. /** Callback called when a pointer move is detected */
  88996. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  88997. /** Callback called when a pointer down is detected */
  88998. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  88999. /** Callback called when a pointer up is detected */
  89000. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  89001. /** Callback called when a pointer pick is detected */
  89002. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  89003. /**
  89004. * 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).
  89005. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  89006. */
  89007. onPrePointerObservable: Observable<PointerInfoPre>;
  89008. /**
  89009. * Observable event triggered each time an input event is received from the rendering canvas
  89010. */
  89011. onPointerObservable: Observable<PointerInfo>;
  89012. /**
  89013. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  89014. */
  89015. readonly unTranslatedPointer: Vector2;
  89016. /** The distance in pixel that you have to move to prevent some events */
  89017. static DragMovementThreshold: number;
  89018. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  89019. static LongPressDelay: number;
  89020. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  89021. static DoubleClickDelay: number;
  89022. /** If you need to check double click without raising a single click at first click, enable this flag */
  89023. static ExclusiveDoubleClickMode: boolean;
  89024. private _initClickEvent;
  89025. private _initActionManager;
  89026. private _delayedSimpleClick;
  89027. private _delayedSimpleClickTimeout;
  89028. private _previousDelayedSimpleClickTimeout;
  89029. private _meshPickProceed;
  89030. private _previousButtonPressed;
  89031. private _currentPickResult;
  89032. private _previousPickResult;
  89033. private _totalPointersPressed;
  89034. private _doubleClickOccured;
  89035. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  89036. cameraToUseForPointers: Nullable<Camera>;
  89037. private _pointerX;
  89038. private _pointerY;
  89039. private _unTranslatedPointerX;
  89040. private _unTranslatedPointerY;
  89041. private _startingPointerPosition;
  89042. private _previousStartingPointerPosition;
  89043. private _startingPointerTime;
  89044. private _previousStartingPointerTime;
  89045. private _pointerCaptures;
  89046. private _timeAccumulator;
  89047. private _currentStepId;
  89048. private _currentInternalStep;
  89049. /** @hidden */
  89050. _mirroredCameraPosition: Nullable<Vector3>;
  89051. /**
  89052. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  89053. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  89054. */
  89055. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  89056. /**
  89057. * Observable event triggered each time an keyboard event is received from the hosting window
  89058. */
  89059. onKeyboardObservable: Observable<KeyboardInfo>;
  89060. private _onKeyDown;
  89061. private _onKeyUp;
  89062. private _onCanvasFocusObserver;
  89063. private _onCanvasBlurObserver;
  89064. private _useRightHandedSystem;
  89065. /**
  89066. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  89067. */
  89068. useRightHandedSystem: boolean;
  89069. /**
  89070. * Sets the step Id used by deterministic lock step
  89071. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89072. * @param newStepId defines the step Id
  89073. */
  89074. setStepId(newStepId: number): void;
  89075. /**
  89076. * Gets the step Id used by deterministic lock step
  89077. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89078. * @returns the step Id
  89079. */
  89080. getStepId(): number;
  89081. /**
  89082. * Gets the internal step used by deterministic lock step
  89083. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89084. * @returns the internal step
  89085. */
  89086. getInternalStep(): number;
  89087. private _fogEnabled;
  89088. /**
  89089. * Gets or sets a boolean indicating if fog is enabled on this scene
  89090. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89091. * (Default is true)
  89092. */
  89093. fogEnabled: boolean;
  89094. private _fogMode;
  89095. /**
  89096. * Gets or sets the fog mode to use
  89097. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89098. * | mode | value |
  89099. * | --- | --- |
  89100. * | FOGMODE_NONE | 0 |
  89101. * | FOGMODE_EXP | 1 |
  89102. * | FOGMODE_EXP2 | 2 |
  89103. * | FOGMODE_LINEAR | 3 |
  89104. */
  89105. fogMode: number;
  89106. /**
  89107. * Gets or sets the fog color to use
  89108. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89109. * (Default is Color3(0.2, 0.2, 0.3))
  89110. */
  89111. fogColor: Color3;
  89112. /**
  89113. * Gets or sets the fog density to use
  89114. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89115. * (Default is 0.1)
  89116. */
  89117. fogDensity: number;
  89118. /**
  89119. * Gets or sets the fog start distance to use
  89120. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89121. * (Default is 0)
  89122. */
  89123. fogStart: number;
  89124. /**
  89125. * Gets or sets the fog end distance to use
  89126. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89127. * (Default is 1000)
  89128. */
  89129. fogEnd: number;
  89130. private _shadowsEnabled;
  89131. /**
  89132. * Gets or sets a boolean indicating if shadows are enabled on this scene
  89133. */
  89134. shadowsEnabled: boolean;
  89135. private _lightsEnabled;
  89136. /**
  89137. * Gets or sets a boolean indicating if lights are enabled on this scene
  89138. */
  89139. lightsEnabled: boolean;
  89140. /** All of the active cameras added to this scene. */
  89141. activeCameras: Camera[];
  89142. private _activeCamera;
  89143. /** Gets or sets the current active camera */
  89144. activeCamera: Nullable<Camera>;
  89145. private _defaultMaterial;
  89146. /** The default material used on meshes when no material is affected */
  89147. /** The default material used on meshes when no material is affected */
  89148. defaultMaterial: Material;
  89149. private _texturesEnabled;
  89150. /**
  89151. * Gets or sets a boolean indicating if textures are enabled on this scene
  89152. */
  89153. texturesEnabled: boolean;
  89154. /**
  89155. * Gets or sets a boolean indicating if particles are enabled on this scene
  89156. */
  89157. particlesEnabled: boolean;
  89158. /**
  89159. * Gets or sets a boolean indicating if sprites are enabled on this scene
  89160. */
  89161. spritesEnabled: boolean;
  89162. private _skeletonsEnabled;
  89163. /**
  89164. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  89165. */
  89166. skeletonsEnabled: boolean;
  89167. /**
  89168. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  89169. */
  89170. lensFlaresEnabled: boolean;
  89171. /**
  89172. * Gets or sets a boolean indicating if collisions are enabled on this scene
  89173. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89174. */
  89175. collisionsEnabled: boolean;
  89176. private _collisionCoordinator;
  89177. /** @hidden */
  89178. readonly collisionCoordinator: ICollisionCoordinator;
  89179. /**
  89180. * Defines the gravity applied to this scene (used only for collisions)
  89181. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89182. */
  89183. gravity: Vector3;
  89184. /**
  89185. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  89186. */
  89187. postProcessesEnabled: boolean;
  89188. /**
  89189. * The list of postprocesses added to the scene
  89190. */
  89191. postProcesses: PostProcess[];
  89192. /**
  89193. * Gets the current postprocess manager
  89194. */
  89195. postProcessManager: PostProcessManager;
  89196. /**
  89197. * Gets or sets a boolean indicating if render targets are enabled on this scene
  89198. */
  89199. renderTargetsEnabled: boolean;
  89200. /**
  89201. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  89202. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  89203. */
  89204. dumpNextRenderTargets: boolean;
  89205. /**
  89206. * The list of user defined render targets added to the scene
  89207. */
  89208. customRenderTargets: RenderTargetTexture[];
  89209. /**
  89210. * Defines if texture loading must be delayed
  89211. * If true, textures will only be loaded when they need to be rendered
  89212. */
  89213. useDelayedTextureLoading: boolean;
  89214. /**
  89215. * Gets the list of meshes imported to the scene through SceneLoader
  89216. */
  89217. importedMeshesFiles: String[];
  89218. /**
  89219. * Gets or sets a boolean indicating if probes are enabled on this scene
  89220. */
  89221. probesEnabled: boolean;
  89222. /**
  89223. * Gets or sets the current offline provider to use to store scene data
  89224. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  89225. */
  89226. offlineProvider: IOfflineProvider;
  89227. /**
  89228. * Gets or sets the action manager associated with the scene
  89229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89230. */
  89231. actionManager: AbstractActionManager;
  89232. private _meshesForIntersections;
  89233. /**
  89234. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  89235. */
  89236. proceduralTexturesEnabled: boolean;
  89237. private _engine;
  89238. private _totalVertices;
  89239. /** @hidden */
  89240. _activeIndices: PerfCounter;
  89241. /** @hidden */
  89242. _activeParticles: PerfCounter;
  89243. /** @hidden */
  89244. _activeBones: PerfCounter;
  89245. private _animationRatio;
  89246. /** @hidden */
  89247. _animationTimeLast: number;
  89248. /** @hidden */
  89249. _animationTime: number;
  89250. /**
  89251. * Gets or sets a general scale for animation speed
  89252. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  89253. */
  89254. animationTimeScale: number;
  89255. /** @hidden */
  89256. _cachedMaterial: Nullable<Material>;
  89257. /** @hidden */
  89258. _cachedEffect: Nullable<Effect>;
  89259. /** @hidden */
  89260. _cachedVisibility: Nullable<number>;
  89261. private _renderId;
  89262. private _frameId;
  89263. private _executeWhenReadyTimeoutId;
  89264. private _intermediateRendering;
  89265. private _viewUpdateFlag;
  89266. private _projectionUpdateFlag;
  89267. private _alternateViewUpdateFlag;
  89268. private _alternateProjectionUpdateFlag;
  89269. /** @hidden */
  89270. _toBeDisposed: Nullable<IDisposable>[];
  89271. private _activeRequests;
  89272. /** @hidden */
  89273. _pendingData: any[];
  89274. private _isDisposed;
  89275. /**
  89276. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  89277. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  89278. */
  89279. dispatchAllSubMeshesOfActiveMeshes: boolean;
  89280. private _activeMeshes;
  89281. private _processedMaterials;
  89282. private _renderTargets;
  89283. /** @hidden */
  89284. _activeParticleSystems: SmartArray<IParticleSystem>;
  89285. private _activeSkeletons;
  89286. private _softwareSkinnedMeshes;
  89287. private _renderingManager;
  89288. /** @hidden */
  89289. _activeAnimatables: Animatable[];
  89290. private _transformMatrix;
  89291. private _sceneUbo;
  89292. private _alternateSceneUbo;
  89293. private _viewMatrix;
  89294. private _projectionMatrix;
  89295. private _alternateViewMatrix;
  89296. private _alternateProjectionMatrix;
  89297. private _alternateTransformMatrix;
  89298. private _useAlternateCameraConfiguration;
  89299. private _alternateRendering;
  89300. private _wheelEventName;
  89301. /** @hidden */
  89302. _forcedViewPosition: Nullable<Vector3>;
  89303. /** @hidden */
  89304. readonly _isAlternateRenderingEnabled: boolean;
  89305. private _frustumPlanes;
  89306. /**
  89307. * Gets the list of frustum planes (built from the active camera)
  89308. */
  89309. readonly frustumPlanes: Plane[];
  89310. /**
  89311. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  89312. * This is useful if there are more lights that the maximum simulteanous authorized
  89313. */
  89314. requireLightSorting: boolean;
  89315. /** @hidden */
  89316. readonly useMaterialMeshMap: boolean;
  89317. /** @hidden */
  89318. readonly useClonedMeshhMap: boolean;
  89319. private _pointerOverMesh;
  89320. private _pickedDownMesh;
  89321. private _pickedUpMesh;
  89322. private _externalData;
  89323. private _uid;
  89324. /**
  89325. * @hidden
  89326. * Backing store of defined scene components.
  89327. */
  89328. _components: ISceneComponent[];
  89329. /**
  89330. * @hidden
  89331. * Backing store of defined scene components.
  89332. */
  89333. _serializableComponents: ISceneSerializableComponent[];
  89334. /**
  89335. * List of components to register on the next registration step.
  89336. */
  89337. private _transientComponents;
  89338. /**
  89339. * Registers the transient components if needed.
  89340. */
  89341. private _registerTransientComponents;
  89342. /**
  89343. * @hidden
  89344. * Add a component to the scene.
  89345. * Note that the ccomponent could be registered on th next frame if this is called after
  89346. * the register component stage.
  89347. * @param component Defines the component to add to the scene
  89348. */
  89349. _addComponent(component: ISceneComponent): void;
  89350. /**
  89351. * @hidden
  89352. * Gets a component from the scene.
  89353. * @param name defines the name of the component to retrieve
  89354. * @returns the component or null if not present
  89355. */
  89356. _getComponent(name: string): Nullable<ISceneComponent>;
  89357. /**
  89358. * @hidden
  89359. * Defines the actions happening before camera updates.
  89360. */
  89361. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  89362. /**
  89363. * @hidden
  89364. * Defines the actions happening before clear the canvas.
  89365. */
  89366. _beforeClearStage: Stage<SimpleStageAction>;
  89367. /**
  89368. * @hidden
  89369. * Defines the actions when collecting render targets for the frame.
  89370. */
  89371. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89372. /**
  89373. * @hidden
  89374. * Defines the actions happening for one camera in the frame.
  89375. */
  89376. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89377. /**
  89378. * @hidden
  89379. * Defines the actions happening during the per mesh ready checks.
  89380. */
  89381. _isReadyForMeshStage: Stage<MeshStageAction>;
  89382. /**
  89383. * @hidden
  89384. * Defines the actions happening before evaluate active mesh checks.
  89385. */
  89386. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  89387. /**
  89388. * @hidden
  89389. * Defines the actions happening during the evaluate sub mesh checks.
  89390. */
  89391. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  89392. /**
  89393. * @hidden
  89394. * Defines the actions happening during the active mesh stage.
  89395. */
  89396. _activeMeshStage: Stage<ActiveMeshStageAction>;
  89397. /**
  89398. * @hidden
  89399. * Defines the actions happening during the per camera render target step.
  89400. */
  89401. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  89402. /**
  89403. * @hidden
  89404. * Defines the actions happening just before the active camera is drawing.
  89405. */
  89406. _beforeCameraDrawStage: Stage<CameraStageAction>;
  89407. /**
  89408. * @hidden
  89409. * Defines the actions happening just before a render target is drawing.
  89410. */
  89411. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89412. /**
  89413. * @hidden
  89414. * Defines the actions happening just before a rendering group is drawing.
  89415. */
  89416. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89417. /**
  89418. * @hidden
  89419. * Defines the actions happening just before a mesh is drawing.
  89420. */
  89421. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89422. /**
  89423. * @hidden
  89424. * Defines the actions happening just after a mesh has been drawn.
  89425. */
  89426. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89427. /**
  89428. * @hidden
  89429. * Defines the actions happening just after a rendering group has been drawn.
  89430. */
  89431. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89432. /**
  89433. * @hidden
  89434. * Defines the actions happening just after the active camera has been drawn.
  89435. */
  89436. _afterCameraDrawStage: Stage<CameraStageAction>;
  89437. /**
  89438. * @hidden
  89439. * Defines the actions happening just after a render target has been drawn.
  89440. */
  89441. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89442. /**
  89443. * @hidden
  89444. * Defines the actions happening just after rendering all cameras and computing intersections.
  89445. */
  89446. _afterRenderStage: Stage<SimpleStageAction>;
  89447. /**
  89448. * @hidden
  89449. * Defines the actions happening when a pointer move event happens.
  89450. */
  89451. _pointerMoveStage: Stage<PointerMoveStageAction>;
  89452. /**
  89453. * @hidden
  89454. * Defines the actions happening when a pointer down event happens.
  89455. */
  89456. _pointerDownStage: Stage<PointerUpDownStageAction>;
  89457. /**
  89458. * @hidden
  89459. * Defines the actions happening when a pointer up event happens.
  89460. */
  89461. _pointerUpStage: Stage<PointerUpDownStageAction>;
  89462. /**
  89463. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  89464. */
  89465. private geometriesByUniqueId;
  89466. /**
  89467. * Creates a new Scene
  89468. * @param engine defines the engine to use to render this scene
  89469. * @param options defines the scene options
  89470. */
  89471. constructor(engine: Engine, options?: SceneOptions);
  89472. private _defaultMeshCandidates;
  89473. /**
  89474. * @hidden
  89475. */
  89476. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  89477. private _defaultSubMeshCandidates;
  89478. /**
  89479. * @hidden
  89480. */
  89481. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  89482. /**
  89483. * Sets the default candidate providers for the scene.
  89484. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  89485. * and getCollidingSubMeshCandidates to their default function
  89486. */
  89487. setDefaultCandidateProviders(): void;
  89488. /**
  89489. * Gets the mesh that is currently under the pointer
  89490. */
  89491. readonly meshUnderPointer: Nullable<AbstractMesh>;
  89492. /**
  89493. * Gets or sets the current on-screen X position of the pointer
  89494. */
  89495. pointerX: number;
  89496. /**
  89497. * Gets or sets the current on-screen Y position of the pointer
  89498. */
  89499. pointerY: number;
  89500. /**
  89501. * Gets the cached material (ie. the latest rendered one)
  89502. * @returns the cached material
  89503. */
  89504. getCachedMaterial(): Nullable<Material>;
  89505. /**
  89506. * Gets the cached effect (ie. the latest rendered one)
  89507. * @returns the cached effect
  89508. */
  89509. getCachedEffect(): Nullable<Effect>;
  89510. /**
  89511. * Gets the cached visibility state (ie. the latest rendered one)
  89512. * @returns the cached visibility state
  89513. */
  89514. getCachedVisibility(): Nullable<number>;
  89515. /**
  89516. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  89517. * @param material defines the current material
  89518. * @param effect defines the current effect
  89519. * @param visibility defines the current visibility state
  89520. * @returns true if one parameter is not cached
  89521. */
  89522. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  89523. /**
  89524. * Gets the engine associated with the scene
  89525. * @returns an Engine
  89526. */
  89527. getEngine(): Engine;
  89528. /**
  89529. * Gets the total number of vertices rendered per frame
  89530. * @returns the total number of vertices rendered per frame
  89531. */
  89532. getTotalVertices(): number;
  89533. /**
  89534. * Gets the performance counter for total vertices
  89535. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89536. */
  89537. readonly totalVerticesPerfCounter: PerfCounter;
  89538. /**
  89539. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  89540. * @returns the total number of active indices rendered per frame
  89541. */
  89542. getActiveIndices(): number;
  89543. /**
  89544. * Gets the performance counter for active indices
  89545. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89546. */
  89547. readonly totalActiveIndicesPerfCounter: PerfCounter;
  89548. /**
  89549. * Gets the total number of active particles rendered per frame
  89550. * @returns the total number of active particles rendered per frame
  89551. */
  89552. getActiveParticles(): number;
  89553. /**
  89554. * Gets the performance counter for active particles
  89555. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89556. */
  89557. readonly activeParticlesPerfCounter: PerfCounter;
  89558. /**
  89559. * Gets the total number of active bones rendered per frame
  89560. * @returns the total number of active bones rendered per frame
  89561. */
  89562. getActiveBones(): number;
  89563. /**
  89564. * Gets the performance counter for active bones
  89565. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89566. */
  89567. readonly activeBonesPerfCounter: PerfCounter;
  89568. /**
  89569. * Gets the array of active meshes
  89570. * @returns an array of AbstractMesh
  89571. */
  89572. getActiveMeshes(): SmartArray<AbstractMesh>;
  89573. /**
  89574. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  89575. * @returns a number
  89576. */
  89577. getAnimationRatio(): number;
  89578. /**
  89579. * Gets an unique Id for the current render phase
  89580. * @returns a number
  89581. */
  89582. getRenderId(): number;
  89583. /**
  89584. * Gets an unique Id for the current frame
  89585. * @returns a number
  89586. */
  89587. getFrameId(): number;
  89588. /** Call this function if you want to manually increment the render Id*/
  89589. incrementRenderId(): void;
  89590. private _updatePointerPosition;
  89591. private _createUbo;
  89592. private _createAlternateUbo;
  89593. private _setRayOnPointerInfo;
  89594. /**
  89595. * Use this method to simulate a pointer move on a mesh
  89596. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89597. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89598. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89599. * @returns the current scene
  89600. */
  89601. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89602. private _processPointerMove;
  89603. private _checkPrePointerObservable;
  89604. /**
  89605. * Use this method to simulate a pointer down on a mesh
  89606. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89607. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89608. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89609. * @returns the current scene
  89610. */
  89611. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89612. private _processPointerDown;
  89613. /**
  89614. * Use this method to simulate a pointer up on a mesh
  89615. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89616. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89617. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89618. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  89619. * @returns the current scene
  89620. */
  89621. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  89622. private _processPointerUp;
  89623. /**
  89624. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  89625. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  89626. * @returns true if the pointer was captured
  89627. */
  89628. isPointerCaptured(pointerId?: number): boolean;
  89629. /** @hidden */
  89630. _isPointerSwiping(): boolean;
  89631. /**
  89632. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  89633. * @param attachUp defines if you want to attach events to pointerup
  89634. * @param attachDown defines if you want to attach events to pointerdown
  89635. * @param attachMove defines if you want to attach events to pointermove
  89636. */
  89637. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  89638. /** Detaches all event handlers*/
  89639. detachControl(): void;
  89640. /**
  89641. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  89642. * Delay loaded resources are not taking in account
  89643. * @return true if all required resources are ready
  89644. */
  89645. isReady(): boolean;
  89646. /** Resets all cached information relative to material (including effect and visibility) */
  89647. resetCachedMaterial(): void;
  89648. /**
  89649. * Registers a function to be called before every frame render
  89650. * @param func defines the function to register
  89651. */
  89652. registerBeforeRender(func: () => void): void;
  89653. /**
  89654. * Unregisters a function called before every frame render
  89655. * @param func defines the function to unregister
  89656. */
  89657. unregisterBeforeRender(func: () => void): void;
  89658. /**
  89659. * Registers a function to be called after every frame render
  89660. * @param func defines the function to register
  89661. */
  89662. registerAfterRender(func: () => void): void;
  89663. /**
  89664. * Unregisters a function called after every frame render
  89665. * @param func defines the function to unregister
  89666. */
  89667. unregisterAfterRender(func: () => void): void;
  89668. private _executeOnceBeforeRender;
  89669. /**
  89670. * The provided function will run before render once and will be disposed afterwards.
  89671. * A timeout delay can be provided so that the function will be executed in N ms.
  89672. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  89673. * @param func The function to be executed.
  89674. * @param timeout optional delay in ms
  89675. */
  89676. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  89677. /** @hidden */
  89678. _addPendingData(data: any): void;
  89679. /** @hidden */
  89680. _removePendingData(data: any): void;
  89681. /**
  89682. * Returns the number of items waiting to be loaded
  89683. * @returns the number of items waiting to be loaded
  89684. */
  89685. getWaitingItemsCount(): number;
  89686. /**
  89687. * Returns a boolean indicating if the scene is still loading data
  89688. */
  89689. readonly isLoading: boolean;
  89690. /**
  89691. * Registers a function to be executed when the scene is ready
  89692. * @param {Function} func - the function to be executed
  89693. */
  89694. executeWhenReady(func: () => void): void;
  89695. /**
  89696. * Returns a promise that resolves when the scene is ready
  89697. * @returns A promise that resolves when the scene is ready
  89698. */
  89699. whenReadyAsync(): Promise<void>;
  89700. /** @hidden */
  89701. _checkIsReady(): void;
  89702. /**
  89703. * Gets all animatable attached to the scene
  89704. */
  89705. readonly animatables: Animatable[];
  89706. /**
  89707. * Resets the last animation time frame.
  89708. * Useful to override when animations start running when loading a scene for the first time.
  89709. */
  89710. resetLastAnimationTimeFrame(): void;
  89711. /** @hidden */
  89712. _switchToAlternateCameraConfiguration(active: boolean): void;
  89713. /**
  89714. * Gets the current view matrix
  89715. * @returns a Matrix
  89716. */
  89717. getViewMatrix(): Matrix;
  89718. /**
  89719. * Gets the current projection matrix
  89720. * @returns a Matrix
  89721. */
  89722. getProjectionMatrix(): Matrix;
  89723. /**
  89724. * Gets the current transform matrix
  89725. * @returns a Matrix made of View * Projection
  89726. */
  89727. getTransformMatrix(): Matrix;
  89728. /**
  89729. * Sets the current transform matrix
  89730. * @param view defines the View matrix to use
  89731. * @param projection defines the Projection matrix to use
  89732. */
  89733. setTransformMatrix(view: Matrix, projection: Matrix): void;
  89734. /** @hidden */
  89735. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  89736. /**
  89737. * Gets the uniform buffer used to store scene data
  89738. * @returns a UniformBuffer
  89739. */
  89740. getSceneUniformBuffer(): UniformBuffer;
  89741. /**
  89742. * Gets an unique (relatively to the current scene) Id
  89743. * @returns an unique number for the scene
  89744. */
  89745. getUniqueId(): number;
  89746. /**
  89747. * Add a mesh to the list of scene's meshes
  89748. * @param newMesh defines the mesh to add
  89749. * @param recursive if all child meshes should also be added to the scene
  89750. */
  89751. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  89752. /**
  89753. * Remove a mesh for the list of scene's meshes
  89754. * @param toRemove defines the mesh to remove
  89755. * @param recursive if all child meshes should also be removed from the scene
  89756. * @returns the index where the mesh was in the mesh list
  89757. */
  89758. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  89759. /**
  89760. * Add a transform node to the list of scene's transform nodes
  89761. * @param newTransformNode defines the transform node to add
  89762. */
  89763. addTransformNode(newTransformNode: TransformNode): void;
  89764. /**
  89765. * Remove a transform node for the list of scene's transform nodes
  89766. * @param toRemove defines the transform node to remove
  89767. * @returns the index where the transform node was in the transform node list
  89768. */
  89769. removeTransformNode(toRemove: TransformNode): number;
  89770. /**
  89771. * Remove a skeleton for the list of scene's skeletons
  89772. * @param toRemove defines the skeleton to remove
  89773. * @returns the index where the skeleton was in the skeleton list
  89774. */
  89775. removeSkeleton(toRemove: Skeleton): number;
  89776. /**
  89777. * Remove a morph target for the list of scene's morph targets
  89778. * @param toRemove defines the morph target to remove
  89779. * @returns the index where the morph target was in the morph target list
  89780. */
  89781. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  89782. /**
  89783. * Remove a light for the list of scene's lights
  89784. * @param toRemove defines the light to remove
  89785. * @returns the index where the light was in the light list
  89786. */
  89787. removeLight(toRemove: Light): number;
  89788. /**
  89789. * Remove a camera for the list of scene's cameras
  89790. * @param toRemove defines the camera to remove
  89791. * @returns the index where the camera was in the camera list
  89792. */
  89793. removeCamera(toRemove: Camera): number;
  89794. /**
  89795. * Remove a particle system for the list of scene's particle systems
  89796. * @param toRemove defines the particle system to remove
  89797. * @returns the index where the particle system was in the particle system list
  89798. */
  89799. removeParticleSystem(toRemove: IParticleSystem): number;
  89800. /**
  89801. * Remove a animation for the list of scene's animations
  89802. * @param toRemove defines the animation to remove
  89803. * @returns the index where the animation was in the animation list
  89804. */
  89805. removeAnimation(toRemove: Animation): number;
  89806. /**
  89807. * Removes the given animation group from this scene.
  89808. * @param toRemove The animation group to remove
  89809. * @returns The index of the removed animation group
  89810. */
  89811. removeAnimationGroup(toRemove: AnimationGroup): number;
  89812. /**
  89813. * Removes the given multi-material from this scene.
  89814. * @param toRemove The multi-material to remove
  89815. * @returns The index of the removed multi-material
  89816. */
  89817. removeMultiMaterial(toRemove: MultiMaterial): number;
  89818. /**
  89819. * Removes the given material from this scene.
  89820. * @param toRemove The material to remove
  89821. * @returns The index of the removed material
  89822. */
  89823. removeMaterial(toRemove: Material): number;
  89824. /**
  89825. * Removes the given action manager from this scene.
  89826. * @param toRemove The action manager to remove
  89827. * @returns The index of the removed action manager
  89828. */
  89829. removeActionManager(toRemove: AbstractActionManager): number;
  89830. /**
  89831. * Removes the given texture from this scene.
  89832. * @param toRemove The texture to remove
  89833. * @returns The index of the removed texture
  89834. */
  89835. removeTexture(toRemove: BaseTexture): number;
  89836. /**
  89837. * Adds the given light to this scene
  89838. * @param newLight The light to add
  89839. */
  89840. addLight(newLight: Light): void;
  89841. /**
  89842. * Sorts the list list based on light priorities
  89843. */
  89844. sortLightsByPriority(): void;
  89845. /**
  89846. * Adds the given camera to this scene
  89847. * @param newCamera The camera to add
  89848. */
  89849. addCamera(newCamera: Camera): void;
  89850. /**
  89851. * Adds the given skeleton to this scene
  89852. * @param newSkeleton The skeleton to add
  89853. */
  89854. addSkeleton(newSkeleton: Skeleton): void;
  89855. /**
  89856. * Adds the given particle system to this scene
  89857. * @param newParticleSystem The particle system to add
  89858. */
  89859. addParticleSystem(newParticleSystem: IParticleSystem): void;
  89860. /**
  89861. * Adds the given animation to this scene
  89862. * @param newAnimation The animation to add
  89863. */
  89864. addAnimation(newAnimation: Animation): void;
  89865. /**
  89866. * Adds the given animation group to this scene.
  89867. * @param newAnimationGroup The animation group to add
  89868. */
  89869. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  89870. /**
  89871. * Adds the given multi-material to this scene
  89872. * @param newMultiMaterial The multi-material to add
  89873. */
  89874. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  89875. /**
  89876. * Adds the given material to this scene
  89877. * @param newMaterial The material to add
  89878. */
  89879. addMaterial(newMaterial: Material): void;
  89880. /**
  89881. * Adds the given morph target to this scene
  89882. * @param newMorphTargetManager The morph target to add
  89883. */
  89884. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  89885. /**
  89886. * Adds the given geometry to this scene
  89887. * @param newGeometry The geometry to add
  89888. */
  89889. addGeometry(newGeometry: Geometry): void;
  89890. /**
  89891. * Adds the given action manager to this scene
  89892. * @param newActionManager The action manager to add
  89893. */
  89894. addActionManager(newActionManager: AbstractActionManager): void;
  89895. /**
  89896. * Adds the given texture to this scene.
  89897. * @param newTexture The texture to add
  89898. */
  89899. addTexture(newTexture: BaseTexture): void;
  89900. /**
  89901. * Switch active camera
  89902. * @param newCamera defines the new active camera
  89903. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  89904. */
  89905. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  89906. /**
  89907. * sets the active camera of the scene using its ID
  89908. * @param id defines the camera's ID
  89909. * @return the new active camera or null if none found.
  89910. */
  89911. setActiveCameraByID(id: string): Nullable<Camera>;
  89912. /**
  89913. * sets the active camera of the scene using its name
  89914. * @param name defines the camera's name
  89915. * @returns the new active camera or null if none found.
  89916. */
  89917. setActiveCameraByName(name: string): Nullable<Camera>;
  89918. /**
  89919. * get an animation group using its name
  89920. * @param name defines the material's name
  89921. * @return the animation group or null if none found.
  89922. */
  89923. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  89924. /**
  89925. * get a material using its id
  89926. * @param id defines the material's ID
  89927. * @return the material or null if none found.
  89928. */
  89929. getMaterialByID(id: string): Nullable<Material>;
  89930. /**
  89931. * Gets a material using its name
  89932. * @param name defines the material's name
  89933. * @return the material or null if none found.
  89934. */
  89935. getMaterialByName(name: string): Nullable<Material>;
  89936. /**
  89937. * Gets a camera using its id
  89938. * @param id defines the id to look for
  89939. * @returns the camera or null if not found
  89940. */
  89941. getCameraByID(id: string): Nullable<Camera>;
  89942. /**
  89943. * Gets a camera using its unique id
  89944. * @param uniqueId defines the unique id to look for
  89945. * @returns the camera or null if not found
  89946. */
  89947. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  89948. /**
  89949. * Gets a camera using its name
  89950. * @param name defines the camera's name
  89951. * @return the camera or null if none found.
  89952. */
  89953. getCameraByName(name: string): Nullable<Camera>;
  89954. /**
  89955. * Gets a bone using its id
  89956. * @param id defines the bone's id
  89957. * @return the bone or null if not found
  89958. */
  89959. getBoneByID(id: string): Nullable<Bone>;
  89960. /**
  89961. * Gets a bone using its id
  89962. * @param name defines the bone's name
  89963. * @return the bone or null if not found
  89964. */
  89965. getBoneByName(name: string): Nullable<Bone>;
  89966. /**
  89967. * Gets a light node using its name
  89968. * @param name defines the the light's name
  89969. * @return the light or null if none found.
  89970. */
  89971. getLightByName(name: string): Nullable<Light>;
  89972. /**
  89973. * Gets a light node using its id
  89974. * @param id defines the light's id
  89975. * @return the light or null if none found.
  89976. */
  89977. getLightByID(id: string): Nullable<Light>;
  89978. /**
  89979. * Gets a light node using its scene-generated unique ID
  89980. * @param uniqueId defines the light's unique id
  89981. * @return the light or null if none found.
  89982. */
  89983. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  89984. /**
  89985. * Gets a particle system by id
  89986. * @param id defines the particle system id
  89987. * @return the corresponding system or null if none found
  89988. */
  89989. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  89990. /**
  89991. * Gets a geometry using its ID
  89992. * @param id defines the geometry's id
  89993. * @return the geometry or null if none found.
  89994. */
  89995. getGeometryByID(id: string): Nullable<Geometry>;
  89996. private _getGeometryByUniqueID;
  89997. /**
  89998. * Add a new geometry to this scene
  89999. * @param geometry defines the geometry to be added to the scene.
  90000. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  90001. * @return a boolean defining if the geometry was added or not
  90002. */
  90003. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  90004. /**
  90005. * Removes an existing geometry
  90006. * @param geometry defines the geometry to be removed from the scene
  90007. * @return a boolean defining if the geometry was removed or not
  90008. */
  90009. removeGeometry(geometry: Geometry): boolean;
  90010. /**
  90011. * Gets the list of geometries attached to the scene
  90012. * @returns an array of Geometry
  90013. */
  90014. getGeometries(): Geometry[];
  90015. /**
  90016. * Gets the first added mesh found of a given ID
  90017. * @param id defines the id to search for
  90018. * @return the mesh found or null if not found at all
  90019. */
  90020. getMeshByID(id: string): Nullable<AbstractMesh>;
  90021. /**
  90022. * Gets a list of meshes using their id
  90023. * @param id defines the id to search for
  90024. * @returns a list of meshes
  90025. */
  90026. getMeshesByID(id: string): Array<AbstractMesh>;
  90027. /**
  90028. * Gets the first added transform node found of a given ID
  90029. * @param id defines the id to search for
  90030. * @return the found transform node or null if not found at all.
  90031. */
  90032. getTransformNodeByID(id: string): Nullable<TransformNode>;
  90033. /**
  90034. * Gets a list of transform nodes using their id
  90035. * @param id defines the id to search for
  90036. * @returns a list of transform nodes
  90037. */
  90038. getTransformNodesByID(id: string): Array<TransformNode>;
  90039. /**
  90040. * Gets a mesh with its auto-generated unique id
  90041. * @param uniqueId defines the unique id to search for
  90042. * @return the found mesh or null if not found at all.
  90043. */
  90044. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  90045. /**
  90046. * Gets a the last added mesh using a given id
  90047. * @param id defines the id to search for
  90048. * @return the found mesh or null if not found at all.
  90049. */
  90050. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  90051. /**
  90052. * Gets a the last added node (Mesh, Camera, Light) using a given id
  90053. * @param id defines the id to search for
  90054. * @return the found node or null if not found at all
  90055. */
  90056. getLastEntryByID(id: string): Nullable<Node>;
  90057. /**
  90058. * Gets a node (Mesh, Camera, Light) using a given id
  90059. * @param id defines the id to search for
  90060. * @return the found node or null if not found at all
  90061. */
  90062. getNodeByID(id: string): Nullable<Node>;
  90063. /**
  90064. * Gets a node (Mesh, Camera, Light) using a given name
  90065. * @param name defines the name to search for
  90066. * @return the found node or null if not found at all.
  90067. */
  90068. getNodeByName(name: string): Nullable<Node>;
  90069. /**
  90070. * Gets a mesh using a given name
  90071. * @param name defines the name to search for
  90072. * @return the found mesh or null if not found at all.
  90073. */
  90074. getMeshByName(name: string): Nullable<AbstractMesh>;
  90075. /**
  90076. * Gets a transform node using a given name
  90077. * @param name defines the name to search for
  90078. * @return the found transform node or null if not found at all.
  90079. */
  90080. getTransformNodeByName(name: string): Nullable<TransformNode>;
  90081. /**
  90082. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  90083. * @param id defines the id to search for
  90084. * @return the found skeleton or null if not found at all.
  90085. */
  90086. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  90087. /**
  90088. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  90089. * @param id defines the id to search for
  90090. * @return the found skeleton or null if not found at all.
  90091. */
  90092. getSkeletonById(id: string): Nullable<Skeleton>;
  90093. /**
  90094. * Gets a skeleton using a given name
  90095. * @param name defines the name to search for
  90096. * @return the found skeleton or null if not found at all.
  90097. */
  90098. getSkeletonByName(name: string): Nullable<Skeleton>;
  90099. /**
  90100. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  90101. * @param id defines the id to search for
  90102. * @return the found morph target manager or null if not found at all.
  90103. */
  90104. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  90105. /**
  90106. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  90107. * @param id defines the id to search for
  90108. * @return the found morph target or null if not found at all.
  90109. */
  90110. getMorphTargetById(id: string): Nullable<MorphTarget>;
  90111. /**
  90112. * Gets a boolean indicating if the given mesh is active
  90113. * @param mesh defines the mesh to look for
  90114. * @returns true if the mesh is in the active list
  90115. */
  90116. isActiveMesh(mesh: AbstractMesh): boolean;
  90117. /**
  90118. * Return a unique id as a string which can serve as an identifier for the scene
  90119. */
  90120. readonly uid: string;
  90121. /**
  90122. * Add an externaly attached data from its key.
  90123. * This method call will fail and return false, if such key already exists.
  90124. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  90125. * @param key the unique key that identifies the data
  90126. * @param data the data object to associate to the key for this Engine instance
  90127. * @return true if no such key were already present and the data was added successfully, false otherwise
  90128. */
  90129. addExternalData<T>(key: string, data: T): boolean;
  90130. /**
  90131. * Get an externaly attached data from its key
  90132. * @param key the unique key that identifies the data
  90133. * @return the associated data, if present (can be null), or undefined if not present
  90134. */
  90135. getExternalData<T>(key: string): Nullable<T>;
  90136. /**
  90137. * Get an externaly attached data from its key, create it using a factory if it's not already present
  90138. * @param key the unique key that identifies the data
  90139. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  90140. * @return the associated data, can be null if the factory returned null.
  90141. */
  90142. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  90143. /**
  90144. * Remove an externaly attached data from the Engine instance
  90145. * @param key the unique key that identifies the data
  90146. * @return true if the data was successfully removed, false if it doesn't exist
  90147. */
  90148. removeExternalData(key: string): boolean;
  90149. private _evaluateSubMesh;
  90150. /**
  90151. * Clear the processed materials smart array preventing retention point in material dispose.
  90152. */
  90153. freeProcessedMaterials(): void;
  90154. private _preventFreeActiveMeshesAndRenderingGroups;
  90155. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  90156. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  90157. * when disposing several meshes in a row or a hierarchy of meshes.
  90158. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  90159. */
  90160. blockfreeActiveMeshesAndRenderingGroups: boolean;
  90161. /**
  90162. * Clear the active meshes smart array preventing retention point in mesh dispose.
  90163. */
  90164. freeActiveMeshes(): void;
  90165. /**
  90166. * Clear the info related to rendering groups preventing retention points during dispose.
  90167. */
  90168. freeRenderingGroups(): void;
  90169. /** @hidden */
  90170. _isInIntermediateRendering(): boolean;
  90171. /**
  90172. * Lambda returning the list of potentially active meshes.
  90173. */
  90174. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  90175. /**
  90176. * Lambda returning the list of potentially active sub meshes.
  90177. */
  90178. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  90179. /**
  90180. * Lambda returning the list of potentially intersecting sub meshes.
  90181. */
  90182. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  90183. /**
  90184. * Lambda returning the list of potentially colliding sub meshes.
  90185. */
  90186. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  90187. private _activeMeshesFrozen;
  90188. /**
  90189. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  90190. * @returns the current scene
  90191. */
  90192. freezeActiveMeshes(): Scene;
  90193. /**
  90194. * Use this function to restart evaluating active meshes on every frame
  90195. * @returns the current scene
  90196. */
  90197. unfreezeActiveMeshes(): Scene;
  90198. private _evaluateActiveMeshes;
  90199. private _activeMesh;
  90200. /**
  90201. * Update the transform matrix to update from the current active camera
  90202. * @param force defines a boolean used to force the update even if cache is up to date
  90203. */
  90204. updateTransformMatrix(force?: boolean): void;
  90205. /**
  90206. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  90207. * @param alternateCamera defines the camera to use
  90208. */
  90209. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  90210. /** @hidden */
  90211. _allowPostProcessClearColor: boolean;
  90212. private _renderForCamera;
  90213. private _processSubCameras;
  90214. private _checkIntersections;
  90215. /** @hidden */
  90216. _advancePhysicsEngineStep(step: number): void;
  90217. /**
  90218. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  90219. */
  90220. getDeterministicFrameTime: () => number;
  90221. /** @hidden */
  90222. _animate(): void;
  90223. /**
  90224. * Render the scene
  90225. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  90226. */
  90227. render(updateCameras?: boolean): void;
  90228. /**
  90229. * Freeze all materials
  90230. * A frozen material will not be updatable but should be faster to render
  90231. */
  90232. freezeMaterials(): void;
  90233. /**
  90234. * Unfreeze all materials
  90235. * A frozen material will not be updatable but should be faster to render
  90236. */
  90237. unfreezeMaterials(): void;
  90238. /**
  90239. * Releases all held ressources
  90240. */
  90241. dispose(): void;
  90242. /**
  90243. * Gets if the scene is already disposed
  90244. */
  90245. readonly isDisposed: boolean;
  90246. /**
  90247. * Call this function to reduce memory footprint of the scene.
  90248. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  90249. */
  90250. clearCachedVertexData(): void;
  90251. /**
  90252. * This function will remove the local cached buffer data from texture.
  90253. * It will save memory but will prevent the texture from being rebuilt
  90254. */
  90255. cleanCachedTextureBuffer(): void;
  90256. /**
  90257. * Get the world extend vectors with an optional filter
  90258. *
  90259. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  90260. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  90261. */
  90262. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  90263. min: Vector3;
  90264. max: Vector3;
  90265. };
  90266. /**
  90267. * Creates a ray that can be used to pick in the scene
  90268. * @param x defines the x coordinate of the origin (on-screen)
  90269. * @param y defines the y coordinate of the origin (on-screen)
  90270. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90271. * @param camera defines the camera to use for the picking
  90272. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90273. * @returns a Ray
  90274. */
  90275. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  90276. /**
  90277. * Creates a ray that can be used to pick in the scene
  90278. * @param x defines the x coordinate of the origin (on-screen)
  90279. * @param y defines the y coordinate of the origin (on-screen)
  90280. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90281. * @param result defines the ray where to store the picking ray
  90282. * @param camera defines the camera to use for the picking
  90283. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90284. * @returns the current scene
  90285. */
  90286. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  90287. /**
  90288. * Creates a ray that can be used to pick in the scene
  90289. * @param x defines the x coordinate of the origin (on-screen)
  90290. * @param y defines the y coordinate of the origin (on-screen)
  90291. * @param camera defines the camera to use for the picking
  90292. * @returns a Ray
  90293. */
  90294. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  90295. /**
  90296. * Creates a ray that can be used to pick in the scene
  90297. * @param x defines the x coordinate of the origin (on-screen)
  90298. * @param y defines the y coordinate of the origin (on-screen)
  90299. * @param result defines the ray where to store the picking ray
  90300. * @param camera defines the camera to use for the picking
  90301. * @returns the current scene
  90302. */
  90303. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  90304. /** Launch a ray to try to pick a mesh in the scene
  90305. * @param x position on screen
  90306. * @param y position on screen
  90307. * @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
  90308. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  90309. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90310. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90311. * @returns a PickingInfo
  90312. */
  90313. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  90314. /** Use the given ray to pick a mesh in the scene
  90315. * @param ray The ray to use to pick meshes
  90316. * @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
  90317. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  90318. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90319. * @returns a PickingInfo
  90320. */
  90321. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90322. /**
  90323. * Launch a ray to try to pick a mesh in the scene
  90324. * @param x X position on screen
  90325. * @param y Y position on screen
  90326. * @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
  90327. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90328. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90329. * @returns an array of PickingInfo
  90330. */
  90331. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90332. /**
  90333. * Launch a ray to try to pick a mesh in the scene
  90334. * @param ray Ray to use
  90335. * @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
  90336. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90337. * @returns an array of PickingInfo
  90338. */
  90339. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90340. /**
  90341. * Force the value of meshUnderPointer
  90342. * @param mesh defines the mesh to use
  90343. */
  90344. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  90345. /**
  90346. * Gets the mesh under the pointer
  90347. * @returns a Mesh or null if no mesh is under the pointer
  90348. */
  90349. getPointerOverMesh(): Nullable<AbstractMesh>;
  90350. /** @hidden */
  90351. _rebuildGeometries(): void;
  90352. /** @hidden */
  90353. _rebuildTextures(): void;
  90354. private _getByTags;
  90355. /**
  90356. * Get a list of meshes by tags
  90357. * @param tagsQuery defines the tags query to use
  90358. * @param forEach defines a predicate used to filter results
  90359. * @returns an array of Mesh
  90360. */
  90361. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  90362. /**
  90363. * Get a list of cameras by tags
  90364. * @param tagsQuery defines the tags query to use
  90365. * @param forEach defines a predicate used to filter results
  90366. * @returns an array of Camera
  90367. */
  90368. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  90369. /**
  90370. * Get a list of lights by tags
  90371. * @param tagsQuery defines the tags query to use
  90372. * @param forEach defines a predicate used to filter results
  90373. * @returns an array of Light
  90374. */
  90375. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  90376. /**
  90377. * Get a list of materials by tags
  90378. * @param tagsQuery defines the tags query to use
  90379. * @param forEach defines a predicate used to filter results
  90380. * @returns an array of Material
  90381. */
  90382. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  90383. /**
  90384. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90385. * This allowed control for front to back rendering or reversly depending of the special needs.
  90386. *
  90387. * @param renderingGroupId The rendering group id corresponding to its index
  90388. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90389. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90390. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90391. */
  90392. 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;
  90393. /**
  90394. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90395. *
  90396. * @param renderingGroupId The rendering group id corresponding to its index
  90397. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90398. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90399. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90400. */
  90401. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90402. /**
  90403. * Gets the current auto clear configuration for one rendering group of the rendering
  90404. * manager.
  90405. * @param index the rendering group index to get the information for
  90406. * @returns The auto clear setup for the requested rendering group
  90407. */
  90408. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90409. private _blockMaterialDirtyMechanism;
  90410. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  90411. blockMaterialDirtyMechanism: boolean;
  90412. /**
  90413. * Will flag all materials as dirty to trigger new shader compilation
  90414. * @param flag defines the flag used to specify which material part must be marked as dirty
  90415. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  90416. */
  90417. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90418. /** @hidden */
  90419. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  90420. /** @hidden */
  90421. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  90422. }
  90423. }
  90424. declare module BABYLON {
  90425. /**
  90426. * Set of assets to keep when moving a scene into an asset container.
  90427. */
  90428. export class KeepAssets extends AbstractScene {
  90429. }
  90430. /**
  90431. * Container with a set of assets that can be added or removed from a scene.
  90432. */
  90433. export class AssetContainer extends AbstractScene {
  90434. /**
  90435. * The scene the AssetContainer belongs to.
  90436. */
  90437. scene: Scene;
  90438. /**
  90439. * Instantiates an AssetContainer.
  90440. * @param scene The scene the AssetContainer belongs to.
  90441. */
  90442. constructor(scene: Scene);
  90443. /**
  90444. * Adds all the assets from the container to the scene.
  90445. */
  90446. addAllToScene(): void;
  90447. /**
  90448. * Removes all the assets in the container from the scene
  90449. */
  90450. removeAllFromScene(): void;
  90451. /**
  90452. * Disposes all the assets in the container
  90453. */
  90454. dispose(): void;
  90455. private _moveAssets;
  90456. /**
  90457. * Removes all the assets contained in the scene and adds them to the container.
  90458. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  90459. */
  90460. moveAllFromScene(keepAssets?: KeepAssets): void;
  90461. /**
  90462. * 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.
  90463. * @returns the root mesh
  90464. */
  90465. createRootMesh(): Mesh;
  90466. }
  90467. }
  90468. declare module BABYLON {
  90469. /**
  90470. * Defines how the parser contract is defined.
  90471. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  90472. */
  90473. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  90474. /**
  90475. * Defines how the individual parser contract is defined.
  90476. * These parser can parse an individual asset
  90477. */
  90478. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  90479. /**
  90480. * Base class of the scene acting as a container for the different elements composing a scene.
  90481. * This class is dynamically extended by the different components of the scene increasing
  90482. * flexibility and reducing coupling
  90483. */
  90484. export abstract class AbstractScene {
  90485. /**
  90486. * Stores the list of available parsers in the application.
  90487. */
  90488. private static _BabylonFileParsers;
  90489. /**
  90490. * Stores the list of available individual parsers in the application.
  90491. */
  90492. private static _IndividualBabylonFileParsers;
  90493. /**
  90494. * Adds a parser in the list of available ones
  90495. * @param name Defines the name of the parser
  90496. * @param parser Defines the parser to add
  90497. */
  90498. static AddParser(name: string, parser: BabylonFileParser): void;
  90499. /**
  90500. * Gets a general parser from the list of avaialble ones
  90501. * @param name Defines the name of the parser
  90502. * @returns the requested parser or null
  90503. */
  90504. static GetParser(name: string): Nullable<BabylonFileParser>;
  90505. /**
  90506. * Adds n individual parser in the list of available ones
  90507. * @param name Defines the name of the parser
  90508. * @param parser Defines the parser to add
  90509. */
  90510. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  90511. /**
  90512. * Gets an individual parser from the list of avaialble ones
  90513. * @param name Defines the name of the parser
  90514. * @returns the requested parser or null
  90515. */
  90516. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  90517. /**
  90518. * Parser json data and populate both a scene and its associated container object
  90519. * @param jsonData Defines the data to parse
  90520. * @param scene Defines the scene to parse the data for
  90521. * @param container Defines the container attached to the parsing sequence
  90522. * @param rootUrl Defines the root url of the data
  90523. */
  90524. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  90525. /**
  90526. * Gets the list of root nodes (ie. nodes with no parent)
  90527. */
  90528. rootNodes: Node[];
  90529. /** All of the cameras added to this scene
  90530. * @see http://doc.babylonjs.com/babylon101/cameras
  90531. */
  90532. cameras: Camera[];
  90533. /**
  90534. * All of the lights added to this scene
  90535. * @see http://doc.babylonjs.com/babylon101/lights
  90536. */
  90537. lights: Light[];
  90538. /**
  90539. * All of the (abstract) meshes added to this scene
  90540. */
  90541. meshes: AbstractMesh[];
  90542. /**
  90543. * The list of skeletons added to the scene
  90544. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90545. */
  90546. skeletons: Skeleton[];
  90547. /**
  90548. * All of the particle systems added to this scene
  90549. * @see http://doc.babylonjs.com/babylon101/particles
  90550. */
  90551. particleSystems: IParticleSystem[];
  90552. /**
  90553. * Gets a list of Animations associated with the scene
  90554. */
  90555. animations: Animation[];
  90556. /**
  90557. * All of the animation groups added to this scene
  90558. * @see http://doc.babylonjs.com/how_to/group
  90559. */
  90560. animationGroups: AnimationGroup[];
  90561. /**
  90562. * All of the multi-materials added to this scene
  90563. * @see http://doc.babylonjs.com/how_to/multi_materials
  90564. */
  90565. multiMaterials: MultiMaterial[];
  90566. /**
  90567. * All of the materials added to this scene
  90568. * In the context of a Scene, it is not supposed to be modified manually.
  90569. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  90570. * Note also that the order of the Material wihin the array is not significant and might change.
  90571. * @see http://doc.babylonjs.com/babylon101/materials
  90572. */
  90573. materials: Material[];
  90574. /**
  90575. * The list of morph target managers added to the scene
  90576. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  90577. */
  90578. morphTargetManagers: MorphTargetManager[];
  90579. /**
  90580. * The list of geometries used in the scene.
  90581. */
  90582. geometries: Geometry[];
  90583. /**
  90584. * All of the tranform nodes added to this scene
  90585. * In the context of a Scene, it is not supposed to be modified manually.
  90586. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  90587. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  90588. * @see http://doc.babylonjs.com/how_to/transformnode
  90589. */
  90590. transformNodes: TransformNode[];
  90591. /**
  90592. * ActionManagers available on the scene.
  90593. */
  90594. actionManagers: AbstractActionManager[];
  90595. /**
  90596. * Textures to keep.
  90597. */
  90598. textures: BaseTexture[];
  90599. }
  90600. }
  90601. declare module BABYLON {
  90602. /**
  90603. * Defines a sound that can be played in the application.
  90604. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  90605. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90606. */
  90607. export class Sound {
  90608. /**
  90609. * The name of the sound in the scene.
  90610. */
  90611. name: string;
  90612. /**
  90613. * Does the sound autoplay once loaded.
  90614. */
  90615. autoplay: boolean;
  90616. /**
  90617. * Does the sound loop after it finishes playing once.
  90618. */
  90619. loop: boolean;
  90620. /**
  90621. * Does the sound use a custom attenuation curve to simulate the falloff
  90622. * happening when the source gets further away from the camera.
  90623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90624. */
  90625. useCustomAttenuation: boolean;
  90626. /**
  90627. * The sound track id this sound belongs to.
  90628. */
  90629. soundTrackId: number;
  90630. /**
  90631. * Is this sound currently played.
  90632. */
  90633. isPlaying: boolean;
  90634. /**
  90635. * Is this sound currently paused.
  90636. */
  90637. isPaused: boolean;
  90638. /**
  90639. * Does this sound enables spatial sound.
  90640. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90641. */
  90642. spatialSound: boolean;
  90643. /**
  90644. * Define the reference distance the sound should be heard perfectly.
  90645. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90646. */
  90647. refDistance: number;
  90648. /**
  90649. * Define the roll off factor of spatial sounds.
  90650. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90651. */
  90652. rolloffFactor: number;
  90653. /**
  90654. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  90655. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90656. */
  90657. maxDistance: number;
  90658. /**
  90659. * Define the distance attenuation model the sound will follow.
  90660. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90661. */
  90662. distanceModel: string;
  90663. /**
  90664. * @hidden
  90665. * Back Compat
  90666. **/
  90667. onended: () => any;
  90668. /**
  90669. * Observable event when the current playing sound finishes.
  90670. */
  90671. onEndedObservable: Observable<Sound>;
  90672. private _panningModel;
  90673. private _playbackRate;
  90674. private _streaming;
  90675. private _startTime;
  90676. private _startOffset;
  90677. private _position;
  90678. /** @hidden */
  90679. _positionInEmitterSpace: boolean;
  90680. private _localDirection;
  90681. private _volume;
  90682. private _isReadyToPlay;
  90683. private _isDirectional;
  90684. private _readyToPlayCallback;
  90685. private _audioBuffer;
  90686. private _soundSource;
  90687. private _streamingSource;
  90688. private _soundPanner;
  90689. private _soundGain;
  90690. private _inputAudioNode;
  90691. private _outputAudioNode;
  90692. private _coneInnerAngle;
  90693. private _coneOuterAngle;
  90694. private _coneOuterGain;
  90695. private _scene;
  90696. private _connectedTransformNode;
  90697. private _customAttenuationFunction;
  90698. private _registerFunc;
  90699. private _isOutputConnected;
  90700. private _htmlAudioElement;
  90701. private _urlType;
  90702. /** @hidden */
  90703. static _SceneComponentInitialization: (scene: Scene) => void;
  90704. /**
  90705. * Create a sound and attach it to a scene
  90706. * @param name Name of your sound
  90707. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  90708. * @param scene defines the scene the sound belongs to
  90709. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  90710. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  90711. */
  90712. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  90713. /**
  90714. * Release the sound and its associated resources
  90715. */
  90716. dispose(): void;
  90717. /**
  90718. * Gets if the sounds is ready to be played or not.
  90719. * @returns true if ready, otherwise false
  90720. */
  90721. isReady(): boolean;
  90722. private _soundLoaded;
  90723. /**
  90724. * Sets the data of the sound from an audiobuffer
  90725. * @param audioBuffer The audioBuffer containing the data
  90726. */
  90727. setAudioBuffer(audioBuffer: AudioBuffer): void;
  90728. /**
  90729. * Updates the current sounds options such as maxdistance, loop...
  90730. * @param options A JSON object containing values named as the object properties
  90731. */
  90732. updateOptions(options: any): void;
  90733. private _createSpatialParameters;
  90734. private _updateSpatialParameters;
  90735. /**
  90736. * Switch the panning model to HRTF:
  90737. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  90738. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90739. */
  90740. switchPanningModelToHRTF(): void;
  90741. /**
  90742. * Switch the panning model to Equal Power:
  90743. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  90744. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90745. */
  90746. switchPanningModelToEqualPower(): void;
  90747. private _switchPanningModel;
  90748. /**
  90749. * Connect this sound to a sound track audio node like gain...
  90750. * @param soundTrackAudioNode the sound track audio node to connect to
  90751. */
  90752. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  90753. /**
  90754. * Transform this sound into a directional source
  90755. * @param coneInnerAngle Size of the inner cone in degree
  90756. * @param coneOuterAngle Size of the outer cone in degree
  90757. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  90758. */
  90759. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  90760. /**
  90761. * Gets or sets the inner angle for the directional cone.
  90762. */
  90763. /**
  90764. * Gets or sets the inner angle for the directional cone.
  90765. */
  90766. directionalConeInnerAngle: number;
  90767. /**
  90768. * Gets or sets the outer angle for the directional cone.
  90769. */
  90770. /**
  90771. * Gets or sets the outer angle for the directional cone.
  90772. */
  90773. directionalConeOuterAngle: number;
  90774. /**
  90775. * Sets the position of the emitter if spatial sound is enabled
  90776. * @param newPosition Defines the new posisiton
  90777. */
  90778. setPosition(newPosition: Vector3): void;
  90779. /**
  90780. * Sets the local direction of the emitter if spatial sound is enabled
  90781. * @param newLocalDirection Defines the new local direction
  90782. */
  90783. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  90784. private _updateDirection;
  90785. /** @hidden */
  90786. updateDistanceFromListener(): void;
  90787. /**
  90788. * Sets a new custom attenuation function for the sound.
  90789. * @param callback Defines the function used for the attenuation
  90790. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90791. */
  90792. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  90793. /**
  90794. * Play the sound
  90795. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  90796. * @param offset (optional) Start the sound setting it at a specific time
  90797. */
  90798. play(time?: number, offset?: number): void;
  90799. private _onended;
  90800. /**
  90801. * Stop the sound
  90802. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  90803. */
  90804. stop(time?: number): void;
  90805. /**
  90806. * Put the sound in pause
  90807. */
  90808. pause(): void;
  90809. /**
  90810. * Sets a dedicated volume for this sounds
  90811. * @param newVolume Define the new volume of the sound
  90812. * @param time Define in how long the sound should be at this value
  90813. */
  90814. setVolume(newVolume: number, time?: number): void;
  90815. /**
  90816. * Set the sound play back rate
  90817. * @param newPlaybackRate Define the playback rate the sound should be played at
  90818. */
  90819. setPlaybackRate(newPlaybackRate: number): void;
  90820. /**
  90821. * Gets the volume of the sound.
  90822. * @returns the volume of the sound
  90823. */
  90824. getVolume(): number;
  90825. /**
  90826. * Attach the sound to a dedicated mesh
  90827. * @param transformNode The transform node to connect the sound with
  90828. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90829. */
  90830. attachToMesh(transformNode: TransformNode): void;
  90831. /**
  90832. * Detach the sound from the previously attached mesh
  90833. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90834. */
  90835. detachFromMesh(): void;
  90836. private _onRegisterAfterWorldMatrixUpdate;
  90837. /**
  90838. * Clone the current sound in the scene.
  90839. * @returns the new sound clone
  90840. */
  90841. clone(): Nullable<Sound>;
  90842. /**
  90843. * Gets the current underlying audio buffer containing the data
  90844. * @returns the audio buffer
  90845. */
  90846. getAudioBuffer(): Nullable<AudioBuffer>;
  90847. /**
  90848. * Serializes the Sound in a JSON representation
  90849. * @returns the JSON representation of the sound
  90850. */
  90851. serialize(): any;
  90852. /**
  90853. * Parse a JSON representation of a sound to innstantiate in a given scene
  90854. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  90855. * @param scene Define the scene the new parsed sound should be created in
  90856. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  90857. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  90858. * @returns the newly parsed sound
  90859. */
  90860. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  90861. }
  90862. }
  90863. declare module BABYLON {
  90864. /**
  90865. * This defines an action helpful to play a defined sound on a triggered action.
  90866. */
  90867. export class PlaySoundAction extends Action {
  90868. private _sound;
  90869. /**
  90870. * Instantiate the action
  90871. * @param triggerOptions defines the trigger options
  90872. * @param sound defines the sound to play
  90873. * @param condition defines the trigger related conditions
  90874. */
  90875. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90876. /** @hidden */
  90877. _prepare(): void;
  90878. /**
  90879. * Execute the action and play the sound.
  90880. */
  90881. execute(): void;
  90882. /**
  90883. * Serializes the actions and its related information.
  90884. * @param parent defines the object to serialize in
  90885. * @returns the serialized object
  90886. */
  90887. serialize(parent: any): any;
  90888. }
  90889. /**
  90890. * This defines an action helpful to stop a defined sound on a triggered action.
  90891. */
  90892. export class StopSoundAction extends Action {
  90893. private _sound;
  90894. /**
  90895. * Instantiate the action
  90896. * @param triggerOptions defines the trigger options
  90897. * @param sound defines the sound to stop
  90898. * @param condition defines the trigger related conditions
  90899. */
  90900. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90901. /** @hidden */
  90902. _prepare(): void;
  90903. /**
  90904. * Execute the action and stop the sound.
  90905. */
  90906. execute(): void;
  90907. /**
  90908. * Serializes the actions and its related information.
  90909. * @param parent defines the object to serialize in
  90910. * @returns the serialized object
  90911. */
  90912. serialize(parent: any): any;
  90913. }
  90914. }
  90915. declare module BABYLON {
  90916. /**
  90917. * This defines an action responsible to change the value of a property
  90918. * by interpolating between its current value and the newly set one once triggered.
  90919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90920. */
  90921. export class InterpolateValueAction extends Action {
  90922. /**
  90923. * Defines the path of the property where the value should be interpolated
  90924. */
  90925. propertyPath: string;
  90926. /**
  90927. * Defines the target value at the end of the interpolation.
  90928. */
  90929. value: any;
  90930. /**
  90931. * Defines the time it will take for the property to interpolate to the value.
  90932. */
  90933. duration: number;
  90934. /**
  90935. * Defines if the other scene animations should be stopped when the action has been triggered
  90936. */
  90937. stopOtherAnimations?: boolean;
  90938. /**
  90939. * Defines a callback raised once the interpolation animation has been done.
  90940. */
  90941. onInterpolationDone?: () => void;
  90942. /**
  90943. * Observable triggered once the interpolation animation has been done.
  90944. */
  90945. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  90946. private _target;
  90947. private _effectiveTarget;
  90948. private _property;
  90949. /**
  90950. * Instantiate the action
  90951. * @param triggerOptions defines the trigger options
  90952. * @param target defines the object containing the value to interpolate
  90953. * @param propertyPath defines the path to the property in the target object
  90954. * @param value defines the target value at the end of the interpolation
  90955. * @param duration deines the time it will take for the property to interpolate to the value.
  90956. * @param condition defines the trigger related conditions
  90957. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  90958. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  90959. */
  90960. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  90961. /** @hidden */
  90962. _prepare(): void;
  90963. /**
  90964. * Execute the action starts the value interpolation.
  90965. */
  90966. execute(): void;
  90967. /**
  90968. * Serializes the actions and its related information.
  90969. * @param parent defines the object to serialize in
  90970. * @returns the serialized object
  90971. */
  90972. serialize(parent: any): any;
  90973. }
  90974. }
  90975. declare module BABYLON {
  90976. /**
  90977. * Options allowed during the creation of a sound track.
  90978. */
  90979. export interface ISoundTrackOptions {
  90980. /**
  90981. * The volume the sound track should take during creation
  90982. */
  90983. volume?: number;
  90984. /**
  90985. * Define if the sound track is the main sound track of the scene
  90986. */
  90987. mainTrack?: boolean;
  90988. }
  90989. /**
  90990. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  90991. * It will be also used in a future release to apply effects on a specific track.
  90992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  90993. */
  90994. export class SoundTrack {
  90995. /**
  90996. * The unique identifier of the sound track in the scene.
  90997. */
  90998. id: number;
  90999. /**
  91000. * The list of sounds included in the sound track.
  91001. */
  91002. soundCollection: Array<Sound>;
  91003. private _outputAudioNode;
  91004. private _scene;
  91005. private _isMainTrack;
  91006. private _connectedAnalyser;
  91007. private _options;
  91008. private _isInitialized;
  91009. /**
  91010. * Creates a new sound track.
  91011. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  91012. * @param scene Define the scene the sound track belongs to
  91013. * @param options
  91014. */
  91015. constructor(scene: Scene, options?: ISoundTrackOptions);
  91016. private _initializeSoundTrackAudioGraph;
  91017. /**
  91018. * Release the sound track and its associated resources
  91019. */
  91020. dispose(): void;
  91021. /**
  91022. * Adds a sound to this sound track
  91023. * @param sound define the cound to add
  91024. * @ignoreNaming
  91025. */
  91026. AddSound(sound: Sound): void;
  91027. /**
  91028. * Removes a sound to this sound track
  91029. * @param sound define the cound to remove
  91030. * @ignoreNaming
  91031. */
  91032. RemoveSound(sound: Sound): void;
  91033. /**
  91034. * Set a global volume for the full sound track.
  91035. * @param newVolume Define the new volume of the sound track
  91036. */
  91037. setVolume(newVolume: number): void;
  91038. /**
  91039. * Switch the panning model to HRTF:
  91040. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  91041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91042. */
  91043. switchPanningModelToHRTF(): void;
  91044. /**
  91045. * Switch the panning model to Equal Power:
  91046. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  91047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91048. */
  91049. switchPanningModelToEqualPower(): void;
  91050. /**
  91051. * Connect the sound track to an audio analyser allowing some amazing
  91052. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  91053. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  91054. * @param analyser The analyser to connect to the engine
  91055. */
  91056. connectToAnalyser(analyser: Analyser): void;
  91057. }
  91058. }
  91059. declare module BABYLON {
  91060. interface AbstractScene {
  91061. /**
  91062. * The list of sounds used in the scene.
  91063. */
  91064. sounds: Nullable<Array<Sound>>;
  91065. }
  91066. interface Scene {
  91067. /**
  91068. * @hidden
  91069. * Backing field
  91070. */
  91071. _mainSoundTrack: SoundTrack;
  91072. /**
  91073. * The main sound track played by the scene.
  91074. * It cotains your primary collection of sounds.
  91075. */
  91076. mainSoundTrack: SoundTrack;
  91077. /**
  91078. * The list of sound tracks added to the scene
  91079. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91080. */
  91081. soundTracks: Nullable<Array<SoundTrack>>;
  91082. /**
  91083. * Gets a sound using a given name
  91084. * @param name defines the name to search for
  91085. * @return the found sound or null if not found at all.
  91086. */
  91087. getSoundByName(name: string): Nullable<Sound>;
  91088. /**
  91089. * Gets or sets if audio support is enabled
  91090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91091. */
  91092. audioEnabled: boolean;
  91093. /**
  91094. * Gets or sets if audio will be output to headphones
  91095. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91096. */
  91097. headphone: boolean;
  91098. }
  91099. /**
  91100. * Defines the sound scene component responsible to manage any sounds
  91101. * in a given scene.
  91102. */
  91103. export class AudioSceneComponent implements ISceneSerializableComponent {
  91104. /**
  91105. * The component name helpfull to identify the component in the list of scene components.
  91106. */
  91107. readonly name: string;
  91108. /**
  91109. * The scene the component belongs to.
  91110. */
  91111. scene: Scene;
  91112. private _audioEnabled;
  91113. /**
  91114. * Gets whether audio is enabled or not.
  91115. * Please use related enable/disable method to switch state.
  91116. */
  91117. readonly audioEnabled: boolean;
  91118. private _headphone;
  91119. /**
  91120. * Gets whether audio is outputing to headphone or not.
  91121. * Please use the according Switch methods to change output.
  91122. */
  91123. readonly headphone: boolean;
  91124. /**
  91125. * Creates a new instance of the component for the given scene
  91126. * @param scene Defines the scene to register the component in
  91127. */
  91128. constructor(scene: Scene);
  91129. /**
  91130. * Registers the component in a given scene
  91131. */
  91132. register(): void;
  91133. /**
  91134. * Rebuilds the elements related to this component in case of
  91135. * context lost for instance.
  91136. */
  91137. rebuild(): void;
  91138. /**
  91139. * Serializes the component data to the specified json object
  91140. * @param serializationObject The object to serialize to
  91141. */
  91142. serialize(serializationObject: any): void;
  91143. /**
  91144. * Adds all the element from the container to the scene
  91145. * @param container the container holding the elements
  91146. */
  91147. addFromContainer(container: AbstractScene): void;
  91148. /**
  91149. * Removes all the elements in the container from the scene
  91150. * @param container contains the elements to remove
  91151. */
  91152. removeFromContainer(container: AbstractScene): void;
  91153. /**
  91154. * Disposes the component and the associated ressources.
  91155. */
  91156. dispose(): void;
  91157. /**
  91158. * Disables audio in the associated scene.
  91159. */
  91160. disableAudio(): void;
  91161. /**
  91162. * Enables audio in the associated scene.
  91163. */
  91164. enableAudio(): void;
  91165. /**
  91166. * Switch audio to headphone output.
  91167. */
  91168. switchAudioModeForHeadphones(): void;
  91169. /**
  91170. * Switch audio to normal speakers.
  91171. */
  91172. switchAudioModeForNormalSpeakers(): void;
  91173. private _afterRender;
  91174. }
  91175. }
  91176. declare module BABYLON {
  91177. /**
  91178. * Wraps one or more Sound objects and selects one with random weight for playback.
  91179. */
  91180. export class WeightedSound {
  91181. /** When true a Sound will be selected and played when the current playing Sound completes. */
  91182. loop: boolean;
  91183. private _coneInnerAngle;
  91184. private _coneOuterAngle;
  91185. private _volume;
  91186. /** A Sound is currently playing. */
  91187. isPlaying: boolean;
  91188. /** A Sound is currently paused. */
  91189. isPaused: boolean;
  91190. private _sounds;
  91191. private _weights;
  91192. private _currentIndex?;
  91193. /**
  91194. * Creates a new WeightedSound from the list of sounds given.
  91195. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  91196. * @param sounds Array of Sounds that will be selected from.
  91197. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  91198. */
  91199. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  91200. /**
  91201. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  91202. */
  91203. /**
  91204. * The size of cone in degress for a directional sound in which there will be no attenuation.
  91205. */
  91206. directionalConeInnerAngle: number;
  91207. /**
  91208. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  91209. * Listener angles between innerAngle and outerAngle will falloff linearly.
  91210. */
  91211. /**
  91212. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  91213. * Listener angles between innerAngle and outerAngle will falloff linearly.
  91214. */
  91215. directionalConeOuterAngle: number;
  91216. /**
  91217. * Playback volume.
  91218. */
  91219. /**
  91220. * Playback volume.
  91221. */
  91222. volume: number;
  91223. private _onended;
  91224. /**
  91225. * Suspend playback
  91226. */
  91227. pause(): void;
  91228. /**
  91229. * Stop playback
  91230. */
  91231. stop(): void;
  91232. /**
  91233. * Start playback.
  91234. * @param startOffset Position the clip head at a specific time in seconds.
  91235. */
  91236. play(startOffset?: number): void;
  91237. }
  91238. }
  91239. declare module BABYLON {
  91240. /**
  91241. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  91242. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91243. */
  91244. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  91245. /**
  91246. * Gets the name of the behavior.
  91247. */
  91248. readonly name: string;
  91249. /**
  91250. * The easing function used by animations
  91251. */
  91252. static EasingFunction: BackEase;
  91253. /**
  91254. * The easing mode used by animations
  91255. */
  91256. static EasingMode: number;
  91257. /**
  91258. * The duration of the animation, in milliseconds
  91259. */
  91260. transitionDuration: number;
  91261. /**
  91262. * Length of the distance animated by the transition when lower radius is reached
  91263. */
  91264. lowerRadiusTransitionRange: number;
  91265. /**
  91266. * Length of the distance animated by the transition when upper radius is reached
  91267. */
  91268. upperRadiusTransitionRange: number;
  91269. private _autoTransitionRange;
  91270. /**
  91271. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91272. */
  91273. /**
  91274. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91275. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  91276. */
  91277. autoTransitionRange: boolean;
  91278. private _attachedCamera;
  91279. private _onAfterCheckInputsObserver;
  91280. private _onMeshTargetChangedObserver;
  91281. /**
  91282. * Initializes the behavior.
  91283. */
  91284. init(): void;
  91285. /**
  91286. * Attaches the behavior to its arc rotate camera.
  91287. * @param camera Defines the camera to attach the behavior to
  91288. */
  91289. attach(camera: ArcRotateCamera): void;
  91290. /**
  91291. * Detaches the behavior from its current arc rotate camera.
  91292. */
  91293. detach(): void;
  91294. private _radiusIsAnimating;
  91295. private _radiusBounceTransition;
  91296. private _animatables;
  91297. private _cachedWheelPrecision;
  91298. /**
  91299. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  91300. * @param radiusLimit The limit to check against.
  91301. * @return Bool to indicate if at limit.
  91302. */
  91303. private _isRadiusAtLimit;
  91304. /**
  91305. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  91306. * @param radiusDelta The delta by which to animate to. Can be negative.
  91307. */
  91308. private _applyBoundRadiusAnimation;
  91309. /**
  91310. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  91311. */
  91312. protected _clearAnimationLocks(): void;
  91313. /**
  91314. * Stops and removes all animations that have been applied to the camera
  91315. */
  91316. stopAllAnimations(): void;
  91317. }
  91318. }
  91319. declare module BABYLON {
  91320. /**
  91321. * 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.
  91322. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91323. */
  91324. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  91325. /**
  91326. * Gets the name of the behavior.
  91327. */
  91328. readonly name: string;
  91329. private _mode;
  91330. private _radiusScale;
  91331. private _positionScale;
  91332. private _defaultElevation;
  91333. private _elevationReturnTime;
  91334. private _elevationReturnWaitTime;
  91335. private _zoomStopsAnimation;
  91336. private _framingTime;
  91337. /**
  91338. * The easing function used by animations
  91339. */
  91340. static EasingFunction: ExponentialEase;
  91341. /**
  91342. * The easing mode used by animations
  91343. */
  91344. static EasingMode: number;
  91345. /**
  91346. * Sets the current mode used by the behavior
  91347. */
  91348. /**
  91349. * Gets current mode used by the behavior.
  91350. */
  91351. mode: number;
  91352. /**
  91353. * Sets the scale applied to the radius (1 by default)
  91354. */
  91355. /**
  91356. * Gets the scale applied to the radius
  91357. */
  91358. radiusScale: number;
  91359. /**
  91360. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91361. */
  91362. /**
  91363. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91364. */
  91365. positionScale: number;
  91366. /**
  91367. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91368. * behaviour is triggered, in radians.
  91369. */
  91370. /**
  91371. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91372. * behaviour is triggered, in radians.
  91373. */
  91374. defaultElevation: number;
  91375. /**
  91376. * Sets the time (in milliseconds) taken to return to the default beta position.
  91377. * Negative value indicates camera should not return to default.
  91378. */
  91379. /**
  91380. * Gets the time (in milliseconds) taken to return to the default beta position.
  91381. * Negative value indicates camera should not return to default.
  91382. */
  91383. elevationReturnTime: number;
  91384. /**
  91385. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91386. */
  91387. /**
  91388. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91389. */
  91390. elevationReturnWaitTime: number;
  91391. /**
  91392. * Sets the flag that indicates if user zooming should stop animation.
  91393. */
  91394. /**
  91395. * Gets the flag that indicates if user zooming should stop animation.
  91396. */
  91397. zoomStopsAnimation: boolean;
  91398. /**
  91399. * Sets the transition time when framing the mesh, in milliseconds
  91400. */
  91401. /**
  91402. * Gets the transition time when framing the mesh, in milliseconds
  91403. */
  91404. framingTime: number;
  91405. /**
  91406. * Define if the behavior should automatically change the configured
  91407. * camera limits and sensibilities.
  91408. */
  91409. autoCorrectCameraLimitsAndSensibility: boolean;
  91410. private _onPrePointerObservableObserver;
  91411. private _onAfterCheckInputsObserver;
  91412. private _onMeshTargetChangedObserver;
  91413. private _attachedCamera;
  91414. private _isPointerDown;
  91415. private _lastInteractionTime;
  91416. /**
  91417. * Initializes the behavior.
  91418. */
  91419. init(): void;
  91420. /**
  91421. * Attaches the behavior to its arc rotate camera.
  91422. * @param camera Defines the camera to attach the behavior to
  91423. */
  91424. attach(camera: ArcRotateCamera): void;
  91425. /**
  91426. * Detaches the behavior from its current arc rotate camera.
  91427. */
  91428. detach(): void;
  91429. private _animatables;
  91430. private _betaIsAnimating;
  91431. private _betaTransition;
  91432. private _radiusTransition;
  91433. private _vectorTransition;
  91434. /**
  91435. * Targets the given mesh and updates zoom level accordingly.
  91436. * @param mesh The mesh to target.
  91437. * @param radius Optional. If a cached radius position already exists, overrides default.
  91438. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91439. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91440. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91441. */
  91442. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91443. /**
  91444. * Targets the given mesh with its children and updates zoom level accordingly.
  91445. * @param mesh The mesh to target.
  91446. * @param radius Optional. If a cached radius position already exists, overrides default.
  91447. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91448. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91449. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91450. */
  91451. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91452. /**
  91453. * Targets the given meshes with their children and updates zoom level accordingly.
  91454. * @param meshes The mesh to target.
  91455. * @param radius Optional. If a cached radius position already exists, overrides default.
  91456. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91457. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91458. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91459. */
  91460. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91461. /**
  91462. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  91463. * @param minimumWorld Determines the smaller position of the bounding box extend
  91464. * @param maximumWorld Determines the bigger position of the bounding box extend
  91465. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91466. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91467. */
  91468. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91469. /**
  91470. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  91471. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  91472. * frustum width.
  91473. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  91474. * to fully enclose the mesh in the viewing frustum.
  91475. */
  91476. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  91477. /**
  91478. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  91479. * is automatically returned to its default position (expected to be above ground plane).
  91480. */
  91481. private _maintainCameraAboveGround;
  91482. /**
  91483. * Returns the frustum slope based on the canvas ratio and camera FOV
  91484. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  91485. */
  91486. private _getFrustumSlope;
  91487. /**
  91488. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  91489. */
  91490. private _clearAnimationLocks;
  91491. /**
  91492. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  91493. */
  91494. private _applyUserInteraction;
  91495. /**
  91496. * Stops and removes all animations that have been applied to the camera
  91497. */
  91498. stopAllAnimations(): void;
  91499. /**
  91500. * Gets a value indicating if the user is moving the camera
  91501. */
  91502. readonly isUserIsMoving: boolean;
  91503. /**
  91504. * The camera can move all the way towards the mesh.
  91505. */
  91506. static IgnoreBoundsSizeMode: number;
  91507. /**
  91508. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  91509. */
  91510. static FitFrustumSidesMode: number;
  91511. }
  91512. }
  91513. declare module BABYLON {
  91514. /**
  91515. * Base class for Camera Pointer Inputs.
  91516. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  91517. * for example usage.
  91518. */
  91519. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  91520. /**
  91521. * Defines the camera the input is attached to.
  91522. */
  91523. abstract camera: Camera;
  91524. /**
  91525. * Whether keyboard modifier keys are pressed at time of last mouse event.
  91526. */
  91527. protected _altKey: boolean;
  91528. protected _ctrlKey: boolean;
  91529. protected _metaKey: boolean;
  91530. protected _shiftKey: boolean;
  91531. /**
  91532. * Which mouse buttons were pressed at time of last mouse event.
  91533. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  91534. */
  91535. protected _buttonsPressed: number;
  91536. /**
  91537. * Defines the buttons associated with the input to handle camera move.
  91538. */
  91539. buttons: number[];
  91540. /**
  91541. * Attach the input controls to a specific dom element to get the input from.
  91542. * @param element Defines the element the controls should be listened from
  91543. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91544. */
  91545. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91546. /**
  91547. * Detach the current controls from the specified dom element.
  91548. * @param element Defines the element to stop listening the inputs from
  91549. */
  91550. detachControl(element: Nullable<HTMLElement>): void;
  91551. /**
  91552. * Gets the class name of the current input.
  91553. * @returns the class name
  91554. */
  91555. getClassName(): string;
  91556. /**
  91557. * Get the friendly name associated with the input class.
  91558. * @returns the input friendly name
  91559. */
  91560. getSimpleName(): string;
  91561. /**
  91562. * Called on pointer POINTERDOUBLETAP event.
  91563. * Override this method to provide functionality on POINTERDOUBLETAP event.
  91564. */
  91565. protected onDoubleTap(type: string): void;
  91566. /**
  91567. * Called on pointer POINTERMOVE event if only a single touch is active.
  91568. * Override this method to provide functionality.
  91569. */
  91570. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91571. /**
  91572. * Called on pointer POINTERMOVE event if multiple touches are active.
  91573. * Override this method to provide functionality.
  91574. */
  91575. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91576. /**
  91577. * Called on JS contextmenu event.
  91578. * Override this method to provide functionality.
  91579. */
  91580. protected onContextMenu(evt: PointerEvent): void;
  91581. /**
  91582. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91583. * press.
  91584. * Override this method to provide functionality.
  91585. */
  91586. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91587. /**
  91588. * Called each time a new POINTERUP event occurs. Ie, for each button
  91589. * release.
  91590. * Override this method to provide functionality.
  91591. */
  91592. protected onButtonUp(evt: PointerEvent): void;
  91593. /**
  91594. * Called when window becomes inactive.
  91595. * Override this method to provide functionality.
  91596. */
  91597. protected onLostFocus(): void;
  91598. private _pointerInput;
  91599. private _observer;
  91600. private _onLostFocus;
  91601. }
  91602. }
  91603. declare module BABYLON {
  91604. /**
  91605. * Manage the pointers inputs to control an arc rotate camera.
  91606. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91607. */
  91608. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  91609. /**
  91610. * Defines the camera the input is attached to.
  91611. */
  91612. camera: ArcRotateCamera;
  91613. /**
  91614. * Gets the class name of the current input.
  91615. * @returns the class name
  91616. */
  91617. getClassName(): string;
  91618. /**
  91619. * Defines the buttons associated with the input to handle camera move.
  91620. */
  91621. buttons: number[];
  91622. /**
  91623. * Defines the pointer angular sensibility along the X axis or how fast is
  91624. * the camera rotating.
  91625. */
  91626. angularSensibilityX: number;
  91627. /**
  91628. * Defines the pointer angular sensibility along the Y axis or how fast is
  91629. * the camera rotating.
  91630. */
  91631. angularSensibilityY: number;
  91632. /**
  91633. * Defines the pointer pinch precision or how fast is the camera zooming.
  91634. */
  91635. pinchPrecision: number;
  91636. /**
  91637. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  91638. * from 0.
  91639. * It defines the percentage of current camera.radius to use as delta when
  91640. * pinch zoom is used.
  91641. */
  91642. pinchDeltaPercentage: number;
  91643. /**
  91644. * Defines the pointer panning sensibility or how fast is the camera moving.
  91645. */
  91646. panningSensibility: number;
  91647. /**
  91648. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  91649. */
  91650. multiTouchPanning: boolean;
  91651. /**
  91652. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  91653. * zoom (pinch) through multitouch.
  91654. */
  91655. multiTouchPanAndZoom: boolean;
  91656. /**
  91657. * Revers pinch action direction.
  91658. */
  91659. pinchInwards: boolean;
  91660. private _isPanClick;
  91661. private _twoFingerActivityCount;
  91662. private _isPinching;
  91663. /**
  91664. * Called on pointer POINTERMOVE event if only a single touch is active.
  91665. */
  91666. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91667. /**
  91668. * Called on pointer POINTERDOUBLETAP event.
  91669. */
  91670. protected onDoubleTap(type: string): void;
  91671. /**
  91672. * Called on pointer POINTERMOVE event if multiple touches are active.
  91673. */
  91674. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91675. /**
  91676. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91677. * press.
  91678. */
  91679. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91680. /**
  91681. * Called each time a new POINTERUP event occurs. Ie, for each button
  91682. * release.
  91683. */
  91684. protected onButtonUp(evt: PointerEvent): void;
  91685. /**
  91686. * Called when window becomes inactive.
  91687. */
  91688. protected onLostFocus(): void;
  91689. }
  91690. }
  91691. declare module BABYLON {
  91692. /**
  91693. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  91694. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91695. */
  91696. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  91697. /**
  91698. * Defines the camera the input is attached to.
  91699. */
  91700. camera: ArcRotateCamera;
  91701. /**
  91702. * Defines the list of key codes associated with the up action (increase alpha)
  91703. */
  91704. keysUp: number[];
  91705. /**
  91706. * Defines the list of key codes associated with the down action (decrease alpha)
  91707. */
  91708. keysDown: number[];
  91709. /**
  91710. * Defines the list of key codes associated with the left action (increase beta)
  91711. */
  91712. keysLeft: number[];
  91713. /**
  91714. * Defines the list of key codes associated with the right action (decrease beta)
  91715. */
  91716. keysRight: number[];
  91717. /**
  91718. * Defines the list of key codes associated with the reset action.
  91719. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  91720. */
  91721. keysReset: number[];
  91722. /**
  91723. * Defines the panning sensibility of the inputs.
  91724. * (How fast is the camera paning)
  91725. */
  91726. panningSensibility: number;
  91727. /**
  91728. * Defines the zooming sensibility of the inputs.
  91729. * (How fast is the camera zooming)
  91730. */
  91731. zoomingSensibility: number;
  91732. /**
  91733. * Defines wether maintaining the alt key down switch the movement mode from
  91734. * orientation to zoom.
  91735. */
  91736. useAltToZoom: boolean;
  91737. /**
  91738. * Rotation speed of the camera
  91739. */
  91740. angularSpeed: number;
  91741. private _keys;
  91742. private _ctrlPressed;
  91743. private _altPressed;
  91744. private _onCanvasBlurObserver;
  91745. private _onKeyboardObserver;
  91746. private _engine;
  91747. private _scene;
  91748. /**
  91749. * Attach the input controls to a specific dom element to get the input from.
  91750. * @param element Defines the element the controls should be listened from
  91751. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91752. */
  91753. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91754. /**
  91755. * Detach the current controls from the specified dom element.
  91756. * @param element Defines the element to stop listening the inputs from
  91757. */
  91758. detachControl(element: Nullable<HTMLElement>): void;
  91759. /**
  91760. * Update the current camera state depending on the inputs that have been used this frame.
  91761. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91762. */
  91763. checkInputs(): void;
  91764. /**
  91765. * Gets the class name of the current intput.
  91766. * @returns the class name
  91767. */
  91768. getClassName(): string;
  91769. /**
  91770. * Get the friendly name associated with the input class.
  91771. * @returns the input friendly name
  91772. */
  91773. getSimpleName(): string;
  91774. }
  91775. }
  91776. declare module BABYLON {
  91777. /**
  91778. * Manage the mouse wheel inputs to control an arc rotate camera.
  91779. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91780. */
  91781. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  91782. /**
  91783. * Defines the camera the input is attached to.
  91784. */
  91785. camera: ArcRotateCamera;
  91786. /**
  91787. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  91788. */
  91789. wheelPrecision: number;
  91790. /**
  91791. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  91792. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  91793. */
  91794. wheelDeltaPercentage: number;
  91795. private _wheel;
  91796. private _observer;
  91797. /**
  91798. * Attach the input controls to a specific dom element to get the input from.
  91799. * @param element Defines the element the controls should be listened from
  91800. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91801. */
  91802. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91803. /**
  91804. * Detach the current controls from the specified dom element.
  91805. * @param element Defines the element to stop listening the inputs from
  91806. */
  91807. detachControl(element: Nullable<HTMLElement>): void;
  91808. /**
  91809. * Gets the class name of the current intput.
  91810. * @returns the class name
  91811. */
  91812. getClassName(): string;
  91813. /**
  91814. * Get the friendly name associated with the input class.
  91815. * @returns the input friendly name
  91816. */
  91817. getSimpleName(): string;
  91818. }
  91819. }
  91820. declare module BABYLON {
  91821. /**
  91822. * Default Inputs manager for the ArcRotateCamera.
  91823. * It groups all the default supported inputs for ease of use.
  91824. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91825. */
  91826. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  91827. /**
  91828. * Instantiates a new ArcRotateCameraInputsManager.
  91829. * @param camera Defines the camera the inputs belong to
  91830. */
  91831. constructor(camera: ArcRotateCamera);
  91832. /**
  91833. * Add mouse wheel input support to the input manager.
  91834. * @returns the current input manager
  91835. */
  91836. addMouseWheel(): ArcRotateCameraInputsManager;
  91837. /**
  91838. * Add pointers input support to the input manager.
  91839. * @returns the current input manager
  91840. */
  91841. addPointers(): ArcRotateCameraInputsManager;
  91842. /**
  91843. * Add keyboard input support to the input manager.
  91844. * @returns the current input manager
  91845. */
  91846. addKeyboard(): ArcRotateCameraInputsManager;
  91847. }
  91848. }
  91849. declare module BABYLON {
  91850. /**
  91851. * This represents an orbital type of camera.
  91852. *
  91853. * 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.
  91854. * 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.
  91855. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  91856. */
  91857. export class ArcRotateCamera extends TargetCamera {
  91858. /**
  91859. * Defines the rotation angle of the camera along the longitudinal axis.
  91860. */
  91861. alpha: number;
  91862. /**
  91863. * Defines the rotation angle of the camera along the latitudinal axis.
  91864. */
  91865. beta: number;
  91866. /**
  91867. * Defines the radius of the camera from it s target point.
  91868. */
  91869. radius: number;
  91870. protected _target: Vector3;
  91871. protected _targetHost: Nullable<AbstractMesh>;
  91872. /**
  91873. * Defines the target point of the camera.
  91874. * The camera looks towards it form the radius distance.
  91875. */
  91876. target: Vector3;
  91877. /**
  91878. * Define the current local position of the camera in the scene
  91879. */
  91880. position: Vector3;
  91881. /**
  91882. * Current inertia value on the longitudinal axis.
  91883. * The bigger this number the longer it will take for the camera to stop.
  91884. */
  91885. inertialAlphaOffset: number;
  91886. /**
  91887. * Current inertia value on the latitudinal axis.
  91888. * The bigger this number the longer it will take for the camera to stop.
  91889. */
  91890. inertialBetaOffset: number;
  91891. /**
  91892. * Current inertia value on the radius axis.
  91893. * The bigger this number the longer it will take for the camera to stop.
  91894. */
  91895. inertialRadiusOffset: number;
  91896. /**
  91897. * Minimum allowed angle on the longitudinal axis.
  91898. * This can help limiting how the Camera is able to move in the scene.
  91899. */
  91900. lowerAlphaLimit: Nullable<number>;
  91901. /**
  91902. * Maximum allowed angle on the longitudinal axis.
  91903. * This can help limiting how the Camera is able to move in the scene.
  91904. */
  91905. upperAlphaLimit: Nullable<number>;
  91906. /**
  91907. * Minimum allowed angle on the latitudinal axis.
  91908. * This can help limiting how the Camera is able to move in the scene.
  91909. */
  91910. lowerBetaLimit: number;
  91911. /**
  91912. * Maximum allowed angle on the latitudinal axis.
  91913. * This can help limiting how the Camera is able to move in the scene.
  91914. */
  91915. upperBetaLimit: number;
  91916. /**
  91917. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  91918. * This can help limiting how the Camera is able to move in the scene.
  91919. */
  91920. lowerRadiusLimit: Nullable<number>;
  91921. /**
  91922. * Maximum allowed distance of the camera to the target (The camera can not get further).
  91923. * This can help limiting how the Camera is able to move in the scene.
  91924. */
  91925. upperRadiusLimit: Nullable<number>;
  91926. /**
  91927. * Defines the current inertia value used during panning of the camera along the X axis.
  91928. */
  91929. inertialPanningX: number;
  91930. /**
  91931. * Defines the current inertia value used during panning of the camera along the Y axis.
  91932. */
  91933. inertialPanningY: number;
  91934. /**
  91935. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  91936. * Basically if your fingers moves away from more than this distance you will be considered
  91937. * in pinch mode.
  91938. */
  91939. pinchToPanMaxDistance: number;
  91940. /**
  91941. * Defines the maximum distance the camera can pan.
  91942. * This could help keeping the cammera always in your scene.
  91943. */
  91944. panningDistanceLimit: Nullable<number>;
  91945. /**
  91946. * Defines the target of the camera before paning.
  91947. */
  91948. panningOriginTarget: Vector3;
  91949. /**
  91950. * Defines the value of the inertia used during panning.
  91951. * 0 would mean stop inertia and one would mean no decelleration at all.
  91952. */
  91953. panningInertia: number;
  91954. /**
  91955. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  91956. */
  91957. angularSensibilityX: number;
  91958. /**
  91959. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  91960. */
  91961. angularSensibilityY: number;
  91962. /**
  91963. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  91964. */
  91965. pinchPrecision: number;
  91966. /**
  91967. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  91968. * It will be used instead of pinchDeltaPrecision if different from 0.
  91969. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  91970. */
  91971. pinchDeltaPercentage: number;
  91972. /**
  91973. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  91974. */
  91975. panningSensibility: number;
  91976. /**
  91977. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  91978. */
  91979. keysUp: number[];
  91980. /**
  91981. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  91982. */
  91983. keysDown: number[];
  91984. /**
  91985. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  91986. */
  91987. keysLeft: number[];
  91988. /**
  91989. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  91990. */
  91991. keysRight: number[];
  91992. /**
  91993. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  91994. */
  91995. wheelPrecision: number;
  91996. /**
  91997. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  91998. * It will be used instead of pinchDeltaPrecision if different from 0.
  91999. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  92000. */
  92001. wheelDeltaPercentage: number;
  92002. /**
  92003. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  92004. */
  92005. zoomOnFactor: number;
  92006. /**
  92007. * Defines a screen offset for the camera position.
  92008. */
  92009. targetScreenOffset: Vector2;
  92010. /**
  92011. * Allows the camera to be completely reversed.
  92012. * If false the camera can not arrive upside down.
  92013. */
  92014. allowUpsideDown: boolean;
  92015. /**
  92016. * Define if double tap/click is used to restore the previously saved state of the camera.
  92017. */
  92018. useInputToRestoreState: boolean;
  92019. /** @hidden */
  92020. _viewMatrix: Matrix;
  92021. /** @hidden */
  92022. _useCtrlForPanning: boolean;
  92023. /** @hidden */
  92024. _panningMouseButton: number;
  92025. /**
  92026. * Defines the input associated to the camera.
  92027. */
  92028. inputs: ArcRotateCameraInputsManager;
  92029. /** @hidden */
  92030. _reset: () => void;
  92031. /**
  92032. * Defines the allowed panning axis.
  92033. */
  92034. panningAxis: Vector3;
  92035. protected _localDirection: Vector3;
  92036. protected _transformedDirection: Vector3;
  92037. private _bouncingBehavior;
  92038. /**
  92039. * Gets the bouncing behavior of the camera if it has been enabled.
  92040. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92041. */
  92042. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  92043. /**
  92044. * Defines if the bouncing behavior of the camera is enabled on the camera.
  92045. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92046. */
  92047. useBouncingBehavior: boolean;
  92048. private _framingBehavior;
  92049. /**
  92050. * Gets the framing behavior of the camera if it has been enabled.
  92051. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92052. */
  92053. readonly framingBehavior: Nullable<FramingBehavior>;
  92054. /**
  92055. * Defines if the framing behavior of the camera is enabled on the camera.
  92056. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92057. */
  92058. useFramingBehavior: boolean;
  92059. private _autoRotationBehavior;
  92060. /**
  92061. * Gets the auto rotation behavior of the camera if it has been enabled.
  92062. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92063. */
  92064. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  92065. /**
  92066. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  92067. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92068. */
  92069. useAutoRotationBehavior: boolean;
  92070. /**
  92071. * Observable triggered when the mesh target has been changed on the camera.
  92072. */
  92073. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  92074. /**
  92075. * Event raised when the camera is colliding with a mesh.
  92076. */
  92077. onCollide: (collidedMesh: AbstractMesh) => void;
  92078. /**
  92079. * Defines whether the camera should check collision with the objects oh the scene.
  92080. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  92081. */
  92082. checkCollisions: boolean;
  92083. /**
  92084. * Defines the collision radius of the camera.
  92085. * This simulates a sphere around the camera.
  92086. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92087. */
  92088. collisionRadius: Vector3;
  92089. protected _collider: Collider;
  92090. protected _previousPosition: Vector3;
  92091. protected _collisionVelocity: Vector3;
  92092. protected _newPosition: Vector3;
  92093. protected _previousAlpha: number;
  92094. protected _previousBeta: number;
  92095. protected _previousRadius: number;
  92096. protected _collisionTriggered: boolean;
  92097. protected _targetBoundingCenter: Nullable<Vector3>;
  92098. private _computationVector;
  92099. private _tempAxisVector;
  92100. private _tempAxisRotationMatrix;
  92101. /**
  92102. * Instantiates a new ArcRotateCamera in a given scene
  92103. * @param name Defines the name of the camera
  92104. * @param alpha Defines the camera rotation along the logitudinal axis
  92105. * @param beta Defines the camera rotation along the latitudinal axis
  92106. * @param radius Defines the camera distance from its target
  92107. * @param target Defines the camera target
  92108. * @param scene Defines the scene the camera belongs to
  92109. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  92110. */
  92111. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92112. /** @hidden */
  92113. _initCache(): void;
  92114. /** @hidden */
  92115. _updateCache(ignoreParentClass?: boolean): void;
  92116. protected _getTargetPosition(): Vector3;
  92117. private _storedAlpha;
  92118. private _storedBeta;
  92119. private _storedRadius;
  92120. private _storedTarget;
  92121. /**
  92122. * Stores the current state of the camera (alpha, beta, radius and target)
  92123. * @returns the camera itself
  92124. */
  92125. storeState(): Camera;
  92126. /**
  92127. * @hidden
  92128. * Restored camera state. You must call storeState() first
  92129. */
  92130. _restoreStateValues(): boolean;
  92131. /** @hidden */
  92132. _isSynchronizedViewMatrix(): boolean;
  92133. /**
  92134. * Attached controls to the current camera.
  92135. * @param element Defines the element the controls should be listened from
  92136. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92137. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  92138. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  92139. */
  92140. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  92141. /**
  92142. * Detach the current controls from the camera.
  92143. * The camera will stop reacting to inputs.
  92144. * @param element Defines the element to stop listening the inputs from
  92145. */
  92146. detachControl(element: HTMLElement): void;
  92147. /** @hidden */
  92148. _checkInputs(): void;
  92149. protected _checkLimits(): void;
  92150. /**
  92151. * Rebuilds angles (alpha, beta) and radius from the give position and target
  92152. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  92153. */
  92154. rebuildAnglesAndRadius(updateView?: boolean): void;
  92155. /**
  92156. * Use a position to define the current camera related information like aplha, beta and radius
  92157. * @param position Defines the position to set the camera at
  92158. */
  92159. setPosition(position: Vector3): void;
  92160. /**
  92161. * Defines the target the camera should look at.
  92162. * This will automatically adapt alpha beta and radius to fit within the new target.
  92163. * @param target Defines the new target as a Vector or a mesh
  92164. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  92165. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  92166. */
  92167. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  92168. /** @hidden */
  92169. _getViewMatrix(): Matrix;
  92170. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  92171. /**
  92172. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  92173. * @param meshes Defines the mesh to zoom on
  92174. * @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)
  92175. */
  92176. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  92177. /**
  92178. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  92179. * The target will be changed but the radius
  92180. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  92181. * @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)
  92182. */
  92183. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  92184. min: Vector3;
  92185. max: Vector3;
  92186. distance: number;
  92187. }, doNotUpdateMaxZ?: boolean): void;
  92188. /**
  92189. * @override
  92190. * Override Camera.createRigCamera
  92191. */
  92192. createRigCamera(name: string, cameraIndex: number): Camera;
  92193. /**
  92194. * @hidden
  92195. * @override
  92196. * Override Camera._updateRigCameras
  92197. */
  92198. _updateRigCameras(): void;
  92199. /**
  92200. * Destroy the camera and release the current resources hold by it.
  92201. */
  92202. dispose(): void;
  92203. /**
  92204. * Gets the current object class name.
  92205. * @return the class name
  92206. */
  92207. getClassName(): string;
  92208. }
  92209. }
  92210. declare module BABYLON {
  92211. /**
  92212. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  92213. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92214. */
  92215. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  92216. /**
  92217. * Gets the name of the behavior.
  92218. */
  92219. readonly name: string;
  92220. private _zoomStopsAnimation;
  92221. private _idleRotationSpeed;
  92222. private _idleRotationWaitTime;
  92223. private _idleRotationSpinupTime;
  92224. /**
  92225. * Sets the flag that indicates if user zooming should stop animation.
  92226. */
  92227. /**
  92228. * Gets the flag that indicates if user zooming should stop animation.
  92229. */
  92230. zoomStopsAnimation: boolean;
  92231. /**
  92232. * Sets the default speed at which the camera rotates around the model.
  92233. */
  92234. /**
  92235. * Gets the default speed at which the camera rotates around the model.
  92236. */
  92237. idleRotationSpeed: number;
  92238. /**
  92239. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  92240. */
  92241. /**
  92242. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  92243. */
  92244. idleRotationWaitTime: number;
  92245. /**
  92246. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  92247. */
  92248. /**
  92249. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  92250. */
  92251. idleRotationSpinupTime: number;
  92252. /**
  92253. * Gets a value indicating if the camera is currently rotating because of this behavior
  92254. */
  92255. readonly rotationInProgress: boolean;
  92256. private _onPrePointerObservableObserver;
  92257. private _onAfterCheckInputsObserver;
  92258. private _attachedCamera;
  92259. private _isPointerDown;
  92260. private _lastFrameTime;
  92261. private _lastInteractionTime;
  92262. private _cameraRotationSpeed;
  92263. /**
  92264. * Initializes the behavior.
  92265. */
  92266. init(): void;
  92267. /**
  92268. * Attaches the behavior to its arc rotate camera.
  92269. * @param camera Defines the camera to attach the behavior to
  92270. */
  92271. attach(camera: ArcRotateCamera): void;
  92272. /**
  92273. * Detaches the behavior from its current arc rotate camera.
  92274. */
  92275. detach(): void;
  92276. /**
  92277. * Returns true if user is scrolling.
  92278. * @return true if user is scrolling.
  92279. */
  92280. private _userIsZooming;
  92281. private _lastFrameRadius;
  92282. private _shouldAnimationStopForInteraction;
  92283. /**
  92284. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  92285. */
  92286. private _applyUserInteraction;
  92287. private _userIsMoving;
  92288. }
  92289. }
  92290. declare module BABYLON {
  92291. /**
  92292. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  92293. */
  92294. export class AttachToBoxBehavior implements Behavior<Mesh> {
  92295. private ui;
  92296. /**
  92297. * The name of the behavior
  92298. */
  92299. name: string;
  92300. /**
  92301. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  92302. */
  92303. distanceAwayFromFace: number;
  92304. /**
  92305. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  92306. */
  92307. distanceAwayFromBottomOfFace: number;
  92308. private _faceVectors;
  92309. private _target;
  92310. private _scene;
  92311. private _onRenderObserver;
  92312. private _tmpMatrix;
  92313. private _tmpVector;
  92314. /**
  92315. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  92316. * @param ui The transform node that should be attched to the mesh
  92317. */
  92318. constructor(ui: TransformNode);
  92319. /**
  92320. * Initializes the behavior
  92321. */
  92322. init(): void;
  92323. private _closestFace;
  92324. private _zeroVector;
  92325. private _lookAtTmpMatrix;
  92326. private _lookAtToRef;
  92327. /**
  92328. * Attaches the AttachToBoxBehavior to the passed in mesh
  92329. * @param target The mesh that the specified node will be attached to
  92330. */
  92331. attach(target: Mesh): void;
  92332. /**
  92333. * Detaches the behavior from the mesh
  92334. */
  92335. detach(): void;
  92336. }
  92337. }
  92338. declare module BABYLON {
  92339. /**
  92340. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  92341. */
  92342. export class FadeInOutBehavior implements Behavior<Mesh> {
  92343. /**
  92344. * Time in milliseconds to delay before fading in (Default: 0)
  92345. */
  92346. delay: number;
  92347. /**
  92348. * Time in milliseconds for the mesh to fade in (Default: 300)
  92349. */
  92350. fadeInTime: number;
  92351. private _millisecondsPerFrame;
  92352. private _hovered;
  92353. private _hoverValue;
  92354. private _ownerNode;
  92355. /**
  92356. * Instatiates the FadeInOutBehavior
  92357. */
  92358. constructor();
  92359. /**
  92360. * The name of the behavior
  92361. */
  92362. readonly name: string;
  92363. /**
  92364. * Initializes the behavior
  92365. */
  92366. init(): void;
  92367. /**
  92368. * Attaches the fade behavior on the passed in mesh
  92369. * @param ownerNode The mesh that will be faded in/out once attached
  92370. */
  92371. attach(ownerNode: Mesh): void;
  92372. /**
  92373. * Detaches the behavior from the mesh
  92374. */
  92375. detach(): void;
  92376. /**
  92377. * Triggers the mesh to begin fading in or out
  92378. * @param value if the object should fade in or out (true to fade in)
  92379. */
  92380. fadeIn(value: boolean): void;
  92381. private _update;
  92382. private _setAllVisibility;
  92383. }
  92384. }
  92385. declare module BABYLON {
  92386. /**
  92387. * Class containing a set of static utilities functions for managing Pivots
  92388. * @hidden
  92389. */
  92390. export class PivotTools {
  92391. private static _PivotCached;
  92392. private static _OldPivotPoint;
  92393. private static _PivotTranslation;
  92394. private static _PivotTmpVector;
  92395. /** @hidden */
  92396. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  92397. /** @hidden */
  92398. static _RestorePivotPoint(mesh: AbstractMesh): void;
  92399. }
  92400. }
  92401. declare module BABYLON {
  92402. /**
  92403. * Class containing static functions to help procedurally build meshes
  92404. */
  92405. export class PlaneBuilder {
  92406. /**
  92407. * Creates a plane mesh
  92408. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  92409. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  92410. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  92411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92412. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92414. * @param name defines the name of the mesh
  92415. * @param options defines the options used to create the mesh
  92416. * @param scene defines the hosting scene
  92417. * @returns the plane mesh
  92418. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  92419. */
  92420. static CreatePlane(name: string, options: {
  92421. size?: number;
  92422. width?: number;
  92423. height?: number;
  92424. sideOrientation?: number;
  92425. frontUVs?: Vector4;
  92426. backUVs?: Vector4;
  92427. updatable?: boolean;
  92428. sourcePlane?: Plane;
  92429. }, scene: Scene): Mesh;
  92430. }
  92431. }
  92432. declare module BABYLON {
  92433. /**
  92434. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  92435. */
  92436. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  92437. private static _AnyMouseID;
  92438. private _attachedNode;
  92439. private _dragPlane;
  92440. private _scene;
  92441. private _pointerObserver;
  92442. private _beforeRenderObserver;
  92443. private static _planeScene;
  92444. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  92445. /**
  92446. * 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)
  92447. */
  92448. maxDragAngle: number;
  92449. /**
  92450. * @hidden
  92451. */
  92452. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  92453. /**
  92454. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92455. */
  92456. currentDraggingPointerID: number;
  92457. /**
  92458. * The last position where the pointer hit the drag plane in world space
  92459. */
  92460. lastDragPosition: Vector3;
  92461. /**
  92462. * If the behavior is currently in a dragging state
  92463. */
  92464. dragging: boolean;
  92465. /**
  92466. * 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)
  92467. */
  92468. dragDeltaRatio: number;
  92469. /**
  92470. * If the drag plane orientation should be updated during the dragging (Default: true)
  92471. */
  92472. updateDragPlane: boolean;
  92473. private _debugMode;
  92474. private _moving;
  92475. /**
  92476. * Fires each time the attached mesh is dragged with the pointer
  92477. * * delta between last drag position and current drag position in world space
  92478. * * dragDistance along the drag axis
  92479. * * dragPlaneNormal normal of the current drag plane used during the drag
  92480. * * dragPlanePoint in world space where the drag intersects the drag plane
  92481. */
  92482. onDragObservable: Observable<{
  92483. delta: Vector3;
  92484. dragPlanePoint: Vector3;
  92485. dragPlaneNormal: Vector3;
  92486. dragDistance: number;
  92487. pointerId: number;
  92488. }>;
  92489. /**
  92490. * Fires each time a drag begins (eg. mouse down on mesh)
  92491. */
  92492. onDragStartObservable: Observable<{
  92493. dragPlanePoint: Vector3;
  92494. pointerId: number;
  92495. }>;
  92496. /**
  92497. * Fires each time a drag ends (eg. mouse release after drag)
  92498. */
  92499. onDragEndObservable: Observable<{
  92500. dragPlanePoint: Vector3;
  92501. pointerId: number;
  92502. }>;
  92503. /**
  92504. * If the attached mesh should be moved when dragged
  92505. */
  92506. moveAttached: boolean;
  92507. /**
  92508. * If the drag behavior will react to drag events (Default: true)
  92509. */
  92510. enabled: boolean;
  92511. /**
  92512. * If camera controls should be detached during the drag
  92513. */
  92514. detachCameraControls: boolean;
  92515. /**
  92516. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  92517. */
  92518. useObjectOrienationForDragging: boolean;
  92519. private _options;
  92520. /**
  92521. * Creates a pointer drag behavior that can be attached to a mesh
  92522. * @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)
  92523. */
  92524. constructor(options?: {
  92525. dragAxis?: Vector3;
  92526. dragPlaneNormal?: Vector3;
  92527. });
  92528. /**
  92529. * Predicate to determine if it is valid to move the object to a new position when it is moved
  92530. */
  92531. validateDrag: (targetPosition: Vector3) => boolean;
  92532. /**
  92533. * The name of the behavior
  92534. */
  92535. readonly name: string;
  92536. /**
  92537. * Initializes the behavior
  92538. */
  92539. init(): void;
  92540. private _tmpVector;
  92541. private _alternatePickedPoint;
  92542. private _worldDragAxis;
  92543. private _targetPosition;
  92544. private _attachedElement;
  92545. /**
  92546. * Attaches the drag behavior the passed in mesh
  92547. * @param ownerNode The mesh that will be dragged around once attached
  92548. */
  92549. attach(ownerNode: AbstractMesh): void;
  92550. /**
  92551. * Force relase the drag action by code.
  92552. */
  92553. releaseDrag(): void;
  92554. private _startDragRay;
  92555. private _lastPointerRay;
  92556. /**
  92557. * Simulates the start of a pointer drag event on the behavior
  92558. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  92559. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  92560. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  92561. */
  92562. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  92563. private _startDrag;
  92564. private _dragDelta;
  92565. private _moveDrag;
  92566. private _pickWithRayOnDragPlane;
  92567. private _pointA;
  92568. private _pointB;
  92569. private _pointC;
  92570. private _lineA;
  92571. private _lineB;
  92572. private _localAxis;
  92573. private _lookAt;
  92574. private _updateDragPlanePosition;
  92575. /**
  92576. * Detaches the behavior from the mesh
  92577. */
  92578. detach(): void;
  92579. }
  92580. }
  92581. declare module BABYLON {
  92582. /**
  92583. * A behavior that when attached to a mesh will allow the mesh to be scaled
  92584. */
  92585. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  92586. private _dragBehaviorA;
  92587. private _dragBehaviorB;
  92588. private _startDistance;
  92589. private _initialScale;
  92590. private _targetScale;
  92591. private _ownerNode;
  92592. private _sceneRenderObserver;
  92593. /**
  92594. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  92595. */
  92596. constructor();
  92597. /**
  92598. * The name of the behavior
  92599. */
  92600. readonly name: string;
  92601. /**
  92602. * Initializes the behavior
  92603. */
  92604. init(): void;
  92605. private _getCurrentDistance;
  92606. /**
  92607. * Attaches the scale behavior the passed in mesh
  92608. * @param ownerNode The mesh that will be scaled around once attached
  92609. */
  92610. attach(ownerNode: Mesh): void;
  92611. /**
  92612. * Detaches the behavior from the mesh
  92613. */
  92614. detach(): void;
  92615. }
  92616. }
  92617. declare module BABYLON {
  92618. /**
  92619. * 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
  92620. */
  92621. export class SixDofDragBehavior implements Behavior<Mesh> {
  92622. private static _virtualScene;
  92623. private _ownerNode;
  92624. private _sceneRenderObserver;
  92625. private _scene;
  92626. private _targetPosition;
  92627. private _virtualOriginMesh;
  92628. private _virtualDragMesh;
  92629. private _pointerObserver;
  92630. private _moving;
  92631. private _startingOrientation;
  92632. /**
  92633. * 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)
  92634. */
  92635. private zDragFactor;
  92636. /**
  92637. * If the object should rotate to face the drag origin
  92638. */
  92639. rotateDraggedObject: boolean;
  92640. /**
  92641. * If the behavior is currently in a dragging state
  92642. */
  92643. dragging: boolean;
  92644. /**
  92645. * 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)
  92646. */
  92647. dragDeltaRatio: number;
  92648. /**
  92649. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92650. */
  92651. currentDraggingPointerID: number;
  92652. /**
  92653. * If camera controls should be detached during the drag
  92654. */
  92655. detachCameraControls: boolean;
  92656. /**
  92657. * Fires each time a drag starts
  92658. */
  92659. onDragStartObservable: Observable<{}>;
  92660. /**
  92661. * Fires each time a drag ends (eg. mouse release after drag)
  92662. */
  92663. onDragEndObservable: Observable<{}>;
  92664. /**
  92665. * 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
  92666. */
  92667. constructor();
  92668. /**
  92669. * The name of the behavior
  92670. */
  92671. readonly name: string;
  92672. /**
  92673. * Initializes the behavior
  92674. */
  92675. init(): void;
  92676. /**
  92677. * Attaches the scale behavior the passed in mesh
  92678. * @param ownerNode The mesh that will be scaled around once attached
  92679. */
  92680. attach(ownerNode: Mesh): void;
  92681. /**
  92682. * Detaches the behavior from the mesh
  92683. */
  92684. detach(): void;
  92685. }
  92686. }
  92687. declare module BABYLON {
  92688. /**
  92689. * Class used to apply inverse kinematics to bones
  92690. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  92691. */
  92692. export class BoneIKController {
  92693. private static _tmpVecs;
  92694. private static _tmpQuat;
  92695. private static _tmpMats;
  92696. /**
  92697. * Gets or sets the target mesh
  92698. */
  92699. targetMesh: AbstractMesh;
  92700. /** Gets or sets the mesh used as pole */
  92701. poleTargetMesh: AbstractMesh;
  92702. /**
  92703. * Gets or sets the bone used as pole
  92704. */
  92705. poleTargetBone: Nullable<Bone>;
  92706. /**
  92707. * Gets or sets the target position
  92708. */
  92709. targetPosition: Vector3;
  92710. /**
  92711. * Gets or sets the pole target position
  92712. */
  92713. poleTargetPosition: Vector3;
  92714. /**
  92715. * Gets or sets the pole target local offset
  92716. */
  92717. poleTargetLocalOffset: Vector3;
  92718. /**
  92719. * Gets or sets the pole angle
  92720. */
  92721. poleAngle: number;
  92722. /**
  92723. * Gets or sets the mesh associated with the controller
  92724. */
  92725. mesh: AbstractMesh;
  92726. /**
  92727. * 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)
  92728. */
  92729. slerpAmount: number;
  92730. private _bone1Quat;
  92731. private _bone1Mat;
  92732. private _bone2Ang;
  92733. private _bone1;
  92734. private _bone2;
  92735. private _bone1Length;
  92736. private _bone2Length;
  92737. private _maxAngle;
  92738. private _maxReach;
  92739. private _rightHandedSystem;
  92740. private _bendAxis;
  92741. private _slerping;
  92742. private _adjustRoll;
  92743. /**
  92744. * Gets or sets maximum allowed angle
  92745. */
  92746. maxAngle: number;
  92747. /**
  92748. * Creates a new BoneIKController
  92749. * @param mesh defines the mesh to control
  92750. * @param bone defines the bone to control
  92751. * @param options defines options to set up the controller
  92752. */
  92753. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  92754. targetMesh?: AbstractMesh;
  92755. poleTargetMesh?: AbstractMesh;
  92756. poleTargetBone?: Bone;
  92757. poleTargetLocalOffset?: Vector3;
  92758. poleAngle?: number;
  92759. bendAxis?: Vector3;
  92760. maxAngle?: number;
  92761. slerpAmount?: number;
  92762. });
  92763. private _setMaxAngle;
  92764. /**
  92765. * Force the controller to update the bones
  92766. */
  92767. update(): void;
  92768. }
  92769. }
  92770. declare module BABYLON {
  92771. /**
  92772. * Class used to make a bone look toward a point in space
  92773. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  92774. */
  92775. export class BoneLookController {
  92776. private static _tmpVecs;
  92777. private static _tmpQuat;
  92778. private static _tmpMats;
  92779. /**
  92780. * The target Vector3 that the bone will look at
  92781. */
  92782. target: Vector3;
  92783. /**
  92784. * The mesh that the bone is attached to
  92785. */
  92786. mesh: AbstractMesh;
  92787. /**
  92788. * The bone that will be looking to the target
  92789. */
  92790. bone: Bone;
  92791. /**
  92792. * The up axis of the coordinate system that is used when the bone is rotated
  92793. */
  92794. upAxis: Vector3;
  92795. /**
  92796. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  92797. */
  92798. upAxisSpace: Space;
  92799. /**
  92800. * Used to make an adjustment to the yaw of the bone
  92801. */
  92802. adjustYaw: number;
  92803. /**
  92804. * Used to make an adjustment to the pitch of the bone
  92805. */
  92806. adjustPitch: number;
  92807. /**
  92808. * Used to make an adjustment to the roll of the bone
  92809. */
  92810. adjustRoll: number;
  92811. /**
  92812. * 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)
  92813. */
  92814. slerpAmount: number;
  92815. private _minYaw;
  92816. private _maxYaw;
  92817. private _minPitch;
  92818. private _maxPitch;
  92819. private _minYawSin;
  92820. private _minYawCos;
  92821. private _maxYawSin;
  92822. private _maxYawCos;
  92823. private _midYawConstraint;
  92824. private _minPitchTan;
  92825. private _maxPitchTan;
  92826. private _boneQuat;
  92827. private _slerping;
  92828. private _transformYawPitch;
  92829. private _transformYawPitchInv;
  92830. private _firstFrameSkipped;
  92831. private _yawRange;
  92832. private _fowardAxis;
  92833. /**
  92834. * Gets or sets the minimum yaw angle that the bone can look to
  92835. */
  92836. minYaw: number;
  92837. /**
  92838. * Gets or sets the maximum yaw angle that the bone can look to
  92839. */
  92840. maxYaw: number;
  92841. /**
  92842. * Gets or sets the minimum pitch angle that the bone can look to
  92843. */
  92844. minPitch: number;
  92845. /**
  92846. * Gets or sets the maximum pitch angle that the bone can look to
  92847. */
  92848. maxPitch: number;
  92849. /**
  92850. * Create a BoneLookController
  92851. * @param mesh the mesh that the bone belongs to
  92852. * @param bone the bone that will be looking to the target
  92853. * @param target the target Vector3 to look at
  92854. * @param options optional settings:
  92855. * * maxYaw: the maximum angle the bone will yaw to
  92856. * * minYaw: the minimum angle the bone will yaw to
  92857. * * maxPitch: the maximum angle the bone will pitch to
  92858. * * minPitch: the minimum angle the bone will yaw to
  92859. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  92860. * * upAxis: the up axis of the coordinate system
  92861. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  92862. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  92863. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  92864. * * adjustYaw: used to make an adjustment to the yaw of the bone
  92865. * * adjustPitch: used to make an adjustment to the pitch of the bone
  92866. * * adjustRoll: used to make an adjustment to the roll of the bone
  92867. **/
  92868. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  92869. maxYaw?: number;
  92870. minYaw?: number;
  92871. maxPitch?: number;
  92872. minPitch?: number;
  92873. slerpAmount?: number;
  92874. upAxis?: Vector3;
  92875. upAxisSpace?: Space;
  92876. yawAxis?: Vector3;
  92877. pitchAxis?: Vector3;
  92878. adjustYaw?: number;
  92879. adjustPitch?: number;
  92880. adjustRoll?: number;
  92881. });
  92882. /**
  92883. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  92884. */
  92885. update(): void;
  92886. private _getAngleDiff;
  92887. private _getAngleBetween;
  92888. private _isAngleBetween;
  92889. }
  92890. }
  92891. declare module BABYLON {
  92892. /**
  92893. * Manage the gamepad inputs to control an arc rotate camera.
  92894. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92895. */
  92896. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  92897. /**
  92898. * Defines the camera the input is attached to.
  92899. */
  92900. camera: ArcRotateCamera;
  92901. /**
  92902. * Defines the gamepad the input is gathering event from.
  92903. */
  92904. gamepad: Nullable<Gamepad>;
  92905. /**
  92906. * Defines the gamepad rotation sensiblity.
  92907. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92908. */
  92909. gamepadRotationSensibility: number;
  92910. /**
  92911. * Defines the gamepad move sensiblity.
  92912. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92913. */
  92914. gamepadMoveSensibility: number;
  92915. private _onGamepadConnectedObserver;
  92916. private _onGamepadDisconnectedObserver;
  92917. /**
  92918. * Attach the input controls to a specific dom element to get the input from.
  92919. * @param element Defines the element the controls should be listened from
  92920. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92921. */
  92922. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92923. /**
  92924. * Detach the current controls from the specified dom element.
  92925. * @param element Defines the element to stop listening the inputs from
  92926. */
  92927. detachControl(element: Nullable<HTMLElement>): void;
  92928. /**
  92929. * Update the current camera state depending on the inputs that have been used this frame.
  92930. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92931. */
  92932. checkInputs(): void;
  92933. /**
  92934. * Gets the class name of the current intput.
  92935. * @returns the class name
  92936. */
  92937. getClassName(): string;
  92938. /**
  92939. * Get the friendly name associated with the input class.
  92940. * @returns the input friendly name
  92941. */
  92942. getSimpleName(): string;
  92943. }
  92944. }
  92945. declare module BABYLON {
  92946. interface ArcRotateCameraInputsManager {
  92947. /**
  92948. * Add orientation input support to the input manager.
  92949. * @returns the current input manager
  92950. */
  92951. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  92952. }
  92953. /**
  92954. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  92955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92956. */
  92957. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  92958. /**
  92959. * Defines the camera the input is attached to.
  92960. */
  92961. camera: ArcRotateCamera;
  92962. /**
  92963. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  92964. */
  92965. alphaCorrection: number;
  92966. /**
  92967. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  92968. */
  92969. gammaCorrection: number;
  92970. private _alpha;
  92971. private _gamma;
  92972. private _dirty;
  92973. private _deviceOrientationHandler;
  92974. /**
  92975. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  92976. */
  92977. constructor();
  92978. /**
  92979. * Attach the input controls to a specific dom element to get the input from.
  92980. * @param element Defines the element the controls should be listened from
  92981. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92982. */
  92983. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92984. /** @hidden */
  92985. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  92986. /**
  92987. * Update the current camera state depending on the inputs that have been used this frame.
  92988. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92989. */
  92990. checkInputs(): void;
  92991. /**
  92992. * Detach the current controls from the specified dom element.
  92993. * @param element Defines the element to stop listening the inputs from
  92994. */
  92995. detachControl(element: Nullable<HTMLElement>): void;
  92996. /**
  92997. * Gets the class name of the current intput.
  92998. * @returns the class name
  92999. */
  93000. getClassName(): string;
  93001. /**
  93002. * Get the friendly name associated with the input class.
  93003. * @returns the input friendly name
  93004. */
  93005. getSimpleName(): string;
  93006. }
  93007. }
  93008. declare module BABYLON {
  93009. /**
  93010. * Listen to mouse events to control the camera.
  93011. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93012. */
  93013. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  93014. /**
  93015. * Defines the camera the input is attached to.
  93016. */
  93017. camera: FlyCamera;
  93018. /**
  93019. * Defines if touch is enabled. (Default is true.)
  93020. */
  93021. touchEnabled: boolean;
  93022. /**
  93023. * Defines the buttons associated with the input to handle camera rotation.
  93024. */
  93025. buttons: number[];
  93026. /**
  93027. * Assign buttons for Yaw control.
  93028. */
  93029. buttonsYaw: number[];
  93030. /**
  93031. * Assign buttons for Pitch control.
  93032. */
  93033. buttonsPitch: number[];
  93034. /**
  93035. * Assign buttons for Roll control.
  93036. */
  93037. buttonsRoll: number[];
  93038. /**
  93039. * Detect if any button is being pressed while mouse is moved.
  93040. * -1 = Mouse locked.
  93041. * 0 = Left button.
  93042. * 1 = Middle Button.
  93043. * 2 = Right Button.
  93044. */
  93045. activeButton: number;
  93046. /**
  93047. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  93048. * Higher values reduce its sensitivity.
  93049. */
  93050. angularSensibility: number;
  93051. private _mousemoveCallback;
  93052. private _observer;
  93053. private _rollObserver;
  93054. private previousPosition;
  93055. private noPreventDefault;
  93056. private element;
  93057. /**
  93058. * Listen to mouse events to control the camera.
  93059. * @param touchEnabled Define if touch is enabled. (Default is true.)
  93060. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93061. */
  93062. constructor(touchEnabled?: boolean);
  93063. /**
  93064. * Attach the mouse control to the HTML DOM element.
  93065. * @param element Defines the element that listens to the input events.
  93066. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  93067. */
  93068. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93069. /**
  93070. * Detach the current controls from the specified dom element.
  93071. * @param element Defines the element to stop listening the inputs from
  93072. */
  93073. detachControl(element: Nullable<HTMLElement>): void;
  93074. /**
  93075. * Gets the class name of the current input.
  93076. * @returns the class name.
  93077. */
  93078. getClassName(): string;
  93079. /**
  93080. * Get the friendly name associated with the input class.
  93081. * @returns the input's friendly name.
  93082. */
  93083. getSimpleName(): string;
  93084. private _pointerInput;
  93085. private _onMouseMove;
  93086. /**
  93087. * Rotate camera by mouse offset.
  93088. */
  93089. private rotateCamera;
  93090. }
  93091. }
  93092. declare module BABYLON {
  93093. /**
  93094. * Default Inputs manager for the FlyCamera.
  93095. * It groups all the default supported inputs for ease of use.
  93096. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93097. */
  93098. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  93099. /**
  93100. * Instantiates a new FlyCameraInputsManager.
  93101. * @param camera Defines the camera the inputs belong to.
  93102. */
  93103. constructor(camera: FlyCamera);
  93104. /**
  93105. * Add keyboard input support to the input manager.
  93106. * @returns the new FlyCameraKeyboardMoveInput().
  93107. */
  93108. addKeyboard(): FlyCameraInputsManager;
  93109. /**
  93110. * Add mouse input support to the input manager.
  93111. * @param touchEnabled Enable touch screen support.
  93112. * @returns the new FlyCameraMouseInput().
  93113. */
  93114. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  93115. }
  93116. }
  93117. declare module BABYLON {
  93118. /**
  93119. * This is a flying camera, designed for 3D movement and rotation in all directions,
  93120. * such as in a 3D Space Shooter or a Flight Simulator.
  93121. */
  93122. export class FlyCamera extends TargetCamera {
  93123. /**
  93124. * Define the collision ellipsoid of the camera.
  93125. * This is helpful for simulating a camera body, like a player's body.
  93126. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  93127. */
  93128. ellipsoid: Vector3;
  93129. /**
  93130. * Define an offset for the position of the ellipsoid around the camera.
  93131. * This can be helpful if the camera is attached away from the player's body center,
  93132. * such as at its head.
  93133. */
  93134. ellipsoidOffset: Vector3;
  93135. /**
  93136. * Enable or disable collisions of the camera with the rest of the scene objects.
  93137. */
  93138. checkCollisions: boolean;
  93139. /**
  93140. * Enable or disable gravity on the camera.
  93141. */
  93142. applyGravity: boolean;
  93143. /**
  93144. * Define the current direction the camera is moving to.
  93145. */
  93146. cameraDirection: Vector3;
  93147. /**
  93148. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  93149. * This overrides and empties cameraRotation.
  93150. */
  93151. rotationQuaternion: Quaternion;
  93152. /**
  93153. * Track Roll to maintain the wanted Rolling when looking around.
  93154. */
  93155. _trackRoll: number;
  93156. /**
  93157. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  93158. */
  93159. rollCorrect: number;
  93160. /**
  93161. * Mimic a banked turn, Rolling the camera when Yawing.
  93162. * It's recommended to use rollCorrect = 10 for faster banking correction.
  93163. */
  93164. bankedTurn: boolean;
  93165. /**
  93166. * Limit in radians for how much Roll banking will add. (Default: 90°)
  93167. */
  93168. bankedTurnLimit: number;
  93169. /**
  93170. * Value of 0 disables the banked Roll.
  93171. * Value of 1 is equal to the Yaw angle in radians.
  93172. */
  93173. bankedTurnMultiplier: number;
  93174. /**
  93175. * The inputs manager loads all the input sources, such as keyboard and mouse.
  93176. */
  93177. inputs: FlyCameraInputsManager;
  93178. /**
  93179. * Gets the input sensibility for mouse input.
  93180. * Higher values reduce sensitivity.
  93181. */
  93182. /**
  93183. * Sets the input sensibility for a mouse input.
  93184. * Higher values reduce sensitivity.
  93185. */
  93186. angularSensibility: number;
  93187. /**
  93188. * Get the keys for camera movement forward.
  93189. */
  93190. /**
  93191. * Set the keys for camera movement forward.
  93192. */
  93193. keysForward: number[];
  93194. /**
  93195. * Get the keys for camera movement backward.
  93196. */
  93197. keysBackward: number[];
  93198. /**
  93199. * Get the keys for camera movement up.
  93200. */
  93201. /**
  93202. * Set the keys for camera movement up.
  93203. */
  93204. keysUp: number[];
  93205. /**
  93206. * Get the keys for camera movement down.
  93207. */
  93208. /**
  93209. * Set the keys for camera movement down.
  93210. */
  93211. keysDown: number[];
  93212. /**
  93213. * Get the keys for camera movement left.
  93214. */
  93215. /**
  93216. * Set the keys for camera movement left.
  93217. */
  93218. keysLeft: number[];
  93219. /**
  93220. * Set the keys for camera movement right.
  93221. */
  93222. /**
  93223. * Set the keys for camera movement right.
  93224. */
  93225. keysRight: number[];
  93226. /**
  93227. * Event raised when the camera collides with a mesh in the scene.
  93228. */
  93229. onCollide: (collidedMesh: AbstractMesh) => void;
  93230. private _collider;
  93231. private _needMoveForGravity;
  93232. private _oldPosition;
  93233. private _diffPosition;
  93234. private _newPosition;
  93235. /** @hidden */
  93236. _localDirection: Vector3;
  93237. /** @hidden */
  93238. _transformedDirection: Vector3;
  93239. /**
  93240. * Instantiates a FlyCamera.
  93241. * This is a flying camera, designed for 3D movement and rotation in all directions,
  93242. * such as in a 3D Space Shooter or a Flight Simulator.
  93243. * @param name Define the name of the camera in the scene.
  93244. * @param position Define the starting position of the camera in the scene.
  93245. * @param scene Define the scene the camera belongs to.
  93246. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  93247. */
  93248. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93249. /**
  93250. * Attach a control to the HTML DOM element.
  93251. * @param element Defines the element that listens to the input events.
  93252. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  93253. */
  93254. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93255. /**
  93256. * Detach a control from the HTML DOM element.
  93257. * The camera will stop reacting to that input.
  93258. * @param element Defines the element that listens to the input events.
  93259. */
  93260. detachControl(element: HTMLElement): void;
  93261. private _collisionMask;
  93262. /**
  93263. * Get the mask that the camera ignores in collision events.
  93264. */
  93265. /**
  93266. * Set the mask that the camera ignores in collision events.
  93267. */
  93268. collisionMask: number;
  93269. /** @hidden */
  93270. _collideWithWorld(displacement: Vector3): void;
  93271. /** @hidden */
  93272. private _onCollisionPositionChange;
  93273. /** @hidden */
  93274. _checkInputs(): void;
  93275. /** @hidden */
  93276. _decideIfNeedsToMove(): boolean;
  93277. /** @hidden */
  93278. _updatePosition(): void;
  93279. /**
  93280. * Restore the Roll to its target value at the rate specified.
  93281. * @param rate - Higher means slower restoring.
  93282. * @hidden
  93283. */
  93284. restoreRoll(rate: number): void;
  93285. /**
  93286. * Destroy the camera and release the current resources held by it.
  93287. */
  93288. dispose(): void;
  93289. /**
  93290. * Get the current object class name.
  93291. * @returns the class name.
  93292. */
  93293. getClassName(): string;
  93294. }
  93295. }
  93296. declare module BABYLON {
  93297. /**
  93298. * Listen to keyboard events to control the camera.
  93299. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93300. */
  93301. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  93302. /**
  93303. * Defines the camera the input is attached to.
  93304. */
  93305. camera: FlyCamera;
  93306. /**
  93307. * The list of keyboard keys used to control the forward move of the camera.
  93308. */
  93309. keysForward: number[];
  93310. /**
  93311. * The list of keyboard keys used to control the backward move of the camera.
  93312. */
  93313. keysBackward: number[];
  93314. /**
  93315. * The list of keyboard keys used to control the forward move of the camera.
  93316. */
  93317. keysUp: number[];
  93318. /**
  93319. * The list of keyboard keys used to control the backward move of the camera.
  93320. */
  93321. keysDown: number[];
  93322. /**
  93323. * The list of keyboard keys used to control the right strafe move of the camera.
  93324. */
  93325. keysRight: number[];
  93326. /**
  93327. * The list of keyboard keys used to control the left strafe move of the camera.
  93328. */
  93329. keysLeft: number[];
  93330. private _keys;
  93331. private _onCanvasBlurObserver;
  93332. private _onKeyboardObserver;
  93333. private _engine;
  93334. private _scene;
  93335. /**
  93336. * Attach the input controls to a specific dom element to get the input from.
  93337. * @param element Defines the element the controls should be listened from
  93338. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93339. */
  93340. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93341. /**
  93342. * Detach the current controls from the specified dom element.
  93343. * @param element Defines the element to stop listening the inputs from
  93344. */
  93345. detachControl(element: Nullable<HTMLElement>): void;
  93346. /**
  93347. * Gets the class name of the current intput.
  93348. * @returns the class name
  93349. */
  93350. getClassName(): string;
  93351. /** @hidden */
  93352. _onLostFocus(e: FocusEvent): void;
  93353. /**
  93354. * Get the friendly name associated with the input class.
  93355. * @returns the input friendly name
  93356. */
  93357. getSimpleName(): string;
  93358. /**
  93359. * Update the current camera state depending on the inputs that have been used this frame.
  93360. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93361. */
  93362. checkInputs(): void;
  93363. }
  93364. }
  93365. declare module BABYLON {
  93366. /**
  93367. * Manage the mouse wheel inputs to control a follow camera.
  93368. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93369. */
  93370. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  93371. /**
  93372. * Defines the camera the input is attached to.
  93373. */
  93374. camera: FollowCamera;
  93375. /**
  93376. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  93377. */
  93378. axisControlRadius: boolean;
  93379. /**
  93380. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  93381. */
  93382. axisControlHeight: boolean;
  93383. /**
  93384. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  93385. */
  93386. axisControlRotation: boolean;
  93387. /**
  93388. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  93389. * relation to mouseWheel events.
  93390. */
  93391. wheelPrecision: number;
  93392. /**
  93393. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  93394. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  93395. */
  93396. wheelDeltaPercentage: number;
  93397. private _wheel;
  93398. private _observer;
  93399. /**
  93400. * Attach the input controls to a specific dom element to get the input from.
  93401. * @param element Defines the element the controls should be listened from
  93402. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93403. */
  93404. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93405. /**
  93406. * Detach the current controls from the specified dom element.
  93407. * @param element Defines the element to stop listening the inputs from
  93408. */
  93409. detachControl(element: Nullable<HTMLElement>): void;
  93410. /**
  93411. * Gets the class name of the current intput.
  93412. * @returns the class name
  93413. */
  93414. getClassName(): string;
  93415. /**
  93416. * Get the friendly name associated with the input class.
  93417. * @returns the input friendly name
  93418. */
  93419. getSimpleName(): string;
  93420. }
  93421. }
  93422. declare module BABYLON {
  93423. /**
  93424. * Manage the pointers inputs to control an follow camera.
  93425. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93426. */
  93427. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  93428. /**
  93429. * Defines the camera the input is attached to.
  93430. */
  93431. camera: FollowCamera;
  93432. /**
  93433. * Gets the class name of the current input.
  93434. * @returns the class name
  93435. */
  93436. getClassName(): string;
  93437. /**
  93438. * Defines the pointer angular sensibility along the X axis or how fast is
  93439. * the camera rotating.
  93440. * A negative number will reverse the axis direction.
  93441. */
  93442. angularSensibilityX: number;
  93443. /**
  93444. * Defines the pointer angular sensibility along the Y axis or how fast is
  93445. * the camera rotating.
  93446. * A negative number will reverse the axis direction.
  93447. */
  93448. angularSensibilityY: number;
  93449. /**
  93450. * Defines the pointer pinch precision or how fast is the camera zooming.
  93451. * A negative number will reverse the axis direction.
  93452. */
  93453. pinchPrecision: number;
  93454. /**
  93455. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  93456. * from 0.
  93457. * It defines the percentage of current camera.radius to use as delta when
  93458. * pinch zoom is used.
  93459. */
  93460. pinchDeltaPercentage: number;
  93461. /**
  93462. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  93463. */
  93464. axisXControlRadius: boolean;
  93465. /**
  93466. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  93467. */
  93468. axisXControlHeight: boolean;
  93469. /**
  93470. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  93471. */
  93472. axisXControlRotation: boolean;
  93473. /**
  93474. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  93475. */
  93476. axisYControlRadius: boolean;
  93477. /**
  93478. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  93479. */
  93480. axisYControlHeight: boolean;
  93481. /**
  93482. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  93483. */
  93484. axisYControlRotation: boolean;
  93485. /**
  93486. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  93487. */
  93488. axisPinchControlRadius: boolean;
  93489. /**
  93490. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  93491. */
  93492. axisPinchControlHeight: boolean;
  93493. /**
  93494. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  93495. */
  93496. axisPinchControlRotation: boolean;
  93497. /**
  93498. * Log error messages if basic misconfiguration has occurred.
  93499. */
  93500. warningEnable: boolean;
  93501. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93502. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93503. private _warningCounter;
  93504. private _warning;
  93505. }
  93506. }
  93507. declare module BABYLON {
  93508. /**
  93509. * Default Inputs manager for the FollowCamera.
  93510. * It groups all the default supported inputs for ease of use.
  93511. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93512. */
  93513. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  93514. /**
  93515. * Instantiates a new FollowCameraInputsManager.
  93516. * @param camera Defines the camera the inputs belong to
  93517. */
  93518. constructor(camera: FollowCamera);
  93519. /**
  93520. * Add keyboard input support to the input manager.
  93521. * @returns the current input manager
  93522. */
  93523. addKeyboard(): FollowCameraInputsManager;
  93524. /**
  93525. * Add mouse wheel input support to the input manager.
  93526. * @returns the current input manager
  93527. */
  93528. addMouseWheel(): FollowCameraInputsManager;
  93529. /**
  93530. * Add pointers input support to the input manager.
  93531. * @returns the current input manager
  93532. */
  93533. addPointers(): FollowCameraInputsManager;
  93534. /**
  93535. * Add orientation input support to the input manager.
  93536. * @returns the current input manager
  93537. */
  93538. addVRDeviceOrientation(): FollowCameraInputsManager;
  93539. }
  93540. }
  93541. declare module BABYLON {
  93542. /**
  93543. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  93544. * an arc rotate version arcFollowCamera are available.
  93545. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93546. */
  93547. export class FollowCamera extends TargetCamera {
  93548. /**
  93549. * Distance the follow camera should follow an object at
  93550. */
  93551. radius: number;
  93552. /**
  93553. * Minimum allowed distance of the camera to the axis of rotation
  93554. * (The camera can not get closer).
  93555. * This can help limiting how the Camera is able to move in the scene.
  93556. */
  93557. lowerRadiusLimit: Nullable<number>;
  93558. /**
  93559. * Maximum allowed distance of the camera to the axis of rotation
  93560. * (The camera can not get further).
  93561. * This can help limiting how the Camera is able to move in the scene.
  93562. */
  93563. upperRadiusLimit: Nullable<number>;
  93564. /**
  93565. * Define a rotation offset between the camera and the object it follows
  93566. */
  93567. rotationOffset: number;
  93568. /**
  93569. * Minimum allowed angle to camera position relative to target object.
  93570. * This can help limiting how the Camera is able to move in the scene.
  93571. */
  93572. lowerRotationOffsetLimit: Nullable<number>;
  93573. /**
  93574. * Maximum allowed angle to camera position relative to target object.
  93575. * This can help limiting how the Camera is able to move in the scene.
  93576. */
  93577. upperRotationOffsetLimit: Nullable<number>;
  93578. /**
  93579. * Define a height offset between the camera and the object it follows.
  93580. * It can help following an object from the top (like a car chaing a plane)
  93581. */
  93582. heightOffset: number;
  93583. /**
  93584. * Minimum allowed height of camera position relative to target object.
  93585. * This can help limiting how the Camera is able to move in the scene.
  93586. */
  93587. lowerHeightOffsetLimit: Nullable<number>;
  93588. /**
  93589. * Maximum allowed height of camera position relative to target object.
  93590. * This can help limiting how the Camera is able to move in the scene.
  93591. */
  93592. upperHeightOffsetLimit: Nullable<number>;
  93593. /**
  93594. * Define how fast the camera can accelerate to follow it s target.
  93595. */
  93596. cameraAcceleration: number;
  93597. /**
  93598. * Define the speed limit of the camera following an object.
  93599. */
  93600. maxCameraSpeed: number;
  93601. /**
  93602. * Define the target of the camera.
  93603. */
  93604. lockedTarget: Nullable<AbstractMesh>;
  93605. /**
  93606. * Defines the input associated with the camera.
  93607. */
  93608. inputs: FollowCameraInputsManager;
  93609. /**
  93610. * Instantiates the follow camera.
  93611. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93612. * @param name Define the name of the camera in the scene
  93613. * @param position Define the position of the camera
  93614. * @param scene Define the scene the camera belong to
  93615. * @param lockedTarget Define the target of the camera
  93616. */
  93617. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  93618. private _follow;
  93619. /**
  93620. * Attached controls to the current camera.
  93621. * @param element Defines the element the controls should be listened from
  93622. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93623. */
  93624. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93625. /**
  93626. * Detach the current controls from the camera.
  93627. * The camera will stop reacting to inputs.
  93628. * @param element Defines the element to stop listening the inputs from
  93629. */
  93630. detachControl(element: HTMLElement): void;
  93631. /** @hidden */
  93632. _checkInputs(): void;
  93633. private _checkLimits;
  93634. /**
  93635. * Gets the camera class name.
  93636. * @returns the class name
  93637. */
  93638. getClassName(): string;
  93639. }
  93640. /**
  93641. * Arc Rotate version of the follow camera.
  93642. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  93643. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93644. */
  93645. export class ArcFollowCamera extends TargetCamera {
  93646. /** The longitudinal angle of the camera */
  93647. alpha: number;
  93648. /** The latitudinal angle of the camera */
  93649. beta: number;
  93650. /** The radius of the camera from its target */
  93651. radius: number;
  93652. /** Define the camera target (the messh it should follow) */
  93653. target: Nullable<AbstractMesh>;
  93654. private _cartesianCoordinates;
  93655. /**
  93656. * Instantiates a new ArcFollowCamera
  93657. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93658. * @param name Define the name of the camera
  93659. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  93660. * @param beta Define the rotation angle of the camera around the elevation axis
  93661. * @param radius Define the radius of the camera from its target point
  93662. * @param target Define the target of the camera
  93663. * @param scene Define the scene the camera belongs to
  93664. */
  93665. constructor(name: string,
  93666. /** The longitudinal angle of the camera */
  93667. alpha: number,
  93668. /** The latitudinal angle of the camera */
  93669. beta: number,
  93670. /** The radius of the camera from its target */
  93671. radius: number,
  93672. /** Define the camera target (the messh it should follow) */
  93673. target: Nullable<AbstractMesh>, scene: Scene);
  93674. private _follow;
  93675. /** @hidden */
  93676. _checkInputs(): void;
  93677. /**
  93678. * Returns the class name of the object.
  93679. * It is mostly used internally for serialization purposes.
  93680. */
  93681. getClassName(): string;
  93682. }
  93683. }
  93684. declare module BABYLON {
  93685. /**
  93686. * Manage the keyboard inputs to control the movement of a follow camera.
  93687. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93688. */
  93689. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  93690. /**
  93691. * Defines the camera the input is attached to.
  93692. */
  93693. camera: FollowCamera;
  93694. /**
  93695. * Defines the list of key codes associated with the up action (increase heightOffset)
  93696. */
  93697. keysHeightOffsetIncr: number[];
  93698. /**
  93699. * Defines the list of key codes associated with the down action (decrease heightOffset)
  93700. */
  93701. keysHeightOffsetDecr: number[];
  93702. /**
  93703. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  93704. */
  93705. keysHeightOffsetModifierAlt: boolean;
  93706. /**
  93707. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  93708. */
  93709. keysHeightOffsetModifierCtrl: boolean;
  93710. /**
  93711. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  93712. */
  93713. keysHeightOffsetModifierShift: boolean;
  93714. /**
  93715. * Defines the list of key codes associated with the left action (increase rotationOffset)
  93716. */
  93717. keysRotationOffsetIncr: number[];
  93718. /**
  93719. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  93720. */
  93721. keysRotationOffsetDecr: number[];
  93722. /**
  93723. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  93724. */
  93725. keysRotationOffsetModifierAlt: boolean;
  93726. /**
  93727. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  93728. */
  93729. keysRotationOffsetModifierCtrl: boolean;
  93730. /**
  93731. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  93732. */
  93733. keysRotationOffsetModifierShift: boolean;
  93734. /**
  93735. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  93736. */
  93737. keysRadiusIncr: number[];
  93738. /**
  93739. * Defines the list of key codes associated with the zoom-out action (increase radius)
  93740. */
  93741. keysRadiusDecr: number[];
  93742. /**
  93743. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  93744. */
  93745. keysRadiusModifierAlt: boolean;
  93746. /**
  93747. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  93748. */
  93749. keysRadiusModifierCtrl: boolean;
  93750. /**
  93751. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  93752. */
  93753. keysRadiusModifierShift: boolean;
  93754. /**
  93755. * Defines the rate of change of heightOffset.
  93756. */
  93757. heightSensibility: number;
  93758. /**
  93759. * Defines the rate of change of rotationOffset.
  93760. */
  93761. rotationSensibility: number;
  93762. /**
  93763. * Defines the rate of change of radius.
  93764. */
  93765. radiusSensibility: number;
  93766. private _keys;
  93767. private _ctrlPressed;
  93768. private _altPressed;
  93769. private _shiftPressed;
  93770. private _onCanvasBlurObserver;
  93771. private _onKeyboardObserver;
  93772. private _engine;
  93773. private _scene;
  93774. /**
  93775. * Attach the input controls to a specific dom element to get the input from.
  93776. * @param element Defines the element the controls should be listened from
  93777. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93778. */
  93779. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93780. /**
  93781. * Detach the current controls from the specified dom element.
  93782. * @param element Defines the element to stop listening the inputs from
  93783. */
  93784. detachControl(element: Nullable<HTMLElement>): void;
  93785. /**
  93786. * Update the current camera state depending on the inputs that have been used this frame.
  93787. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93788. */
  93789. checkInputs(): void;
  93790. /**
  93791. * Gets the class name of the current input.
  93792. * @returns the class name
  93793. */
  93794. getClassName(): string;
  93795. /**
  93796. * Get the friendly name associated with the input class.
  93797. * @returns the input friendly name
  93798. */
  93799. getSimpleName(): string;
  93800. /**
  93801. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93802. * allow modification of the heightOffset value.
  93803. */
  93804. private _modifierHeightOffset;
  93805. /**
  93806. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93807. * allow modification of the rotationOffset value.
  93808. */
  93809. private _modifierRotationOffset;
  93810. /**
  93811. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93812. * allow modification of the radius value.
  93813. */
  93814. private _modifierRadius;
  93815. }
  93816. }
  93817. declare module BABYLON {
  93818. interface FreeCameraInputsManager {
  93819. /**
  93820. * Add orientation input support to the input manager.
  93821. * @returns the current input manager
  93822. */
  93823. addDeviceOrientation(): FreeCameraInputsManager;
  93824. }
  93825. /**
  93826. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  93827. * Screen rotation is taken into account.
  93828. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93829. */
  93830. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  93831. private _camera;
  93832. private _screenOrientationAngle;
  93833. private _constantTranform;
  93834. private _screenQuaternion;
  93835. private _alpha;
  93836. private _beta;
  93837. private _gamma;
  93838. /**
  93839. * Instantiates a new input
  93840. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93841. */
  93842. constructor();
  93843. /**
  93844. * Define the camera controlled by the input.
  93845. */
  93846. camera: FreeCamera;
  93847. /**
  93848. * Attach the input controls to a specific dom element to get the input from.
  93849. * @param element Defines the element the controls should be listened from
  93850. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93851. */
  93852. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93853. private _orientationChanged;
  93854. private _deviceOrientation;
  93855. /**
  93856. * Detach the current controls from the specified dom element.
  93857. * @param element Defines the element to stop listening the inputs from
  93858. */
  93859. detachControl(element: Nullable<HTMLElement>): void;
  93860. /**
  93861. * Update the current camera state depending on the inputs that have been used this frame.
  93862. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93863. */
  93864. checkInputs(): void;
  93865. /**
  93866. * Gets the class name of the current intput.
  93867. * @returns the class name
  93868. */
  93869. getClassName(): string;
  93870. /**
  93871. * Get the friendly name associated with the input class.
  93872. * @returns the input friendly name
  93873. */
  93874. getSimpleName(): string;
  93875. }
  93876. }
  93877. declare module BABYLON {
  93878. /**
  93879. * Manage the gamepad inputs to control a free camera.
  93880. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93881. */
  93882. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  93883. /**
  93884. * Define the camera the input is attached to.
  93885. */
  93886. camera: FreeCamera;
  93887. /**
  93888. * Define the Gamepad controlling the input
  93889. */
  93890. gamepad: Nullable<Gamepad>;
  93891. /**
  93892. * Defines the gamepad rotation sensiblity.
  93893. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93894. */
  93895. gamepadAngularSensibility: number;
  93896. /**
  93897. * Defines the gamepad move sensiblity.
  93898. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93899. */
  93900. gamepadMoveSensibility: number;
  93901. private _onGamepadConnectedObserver;
  93902. private _onGamepadDisconnectedObserver;
  93903. private _cameraTransform;
  93904. private _deltaTransform;
  93905. private _vector3;
  93906. private _vector2;
  93907. /**
  93908. * Attach the input controls to a specific dom element to get the input from.
  93909. * @param element Defines the element the controls should be listened from
  93910. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93911. */
  93912. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93913. /**
  93914. * Detach the current controls from the specified dom element.
  93915. * @param element Defines the element to stop listening the inputs from
  93916. */
  93917. detachControl(element: Nullable<HTMLElement>): void;
  93918. /**
  93919. * Update the current camera state depending on the inputs that have been used this frame.
  93920. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93921. */
  93922. checkInputs(): void;
  93923. /**
  93924. * Gets the class name of the current intput.
  93925. * @returns the class name
  93926. */
  93927. getClassName(): string;
  93928. /**
  93929. * Get the friendly name associated with the input class.
  93930. * @returns the input friendly name
  93931. */
  93932. getSimpleName(): string;
  93933. }
  93934. }
  93935. declare module BABYLON {
  93936. /**
  93937. * Defines the potential axis of a Joystick
  93938. */
  93939. export enum JoystickAxis {
  93940. /** X axis */
  93941. X = 0,
  93942. /** Y axis */
  93943. Y = 1,
  93944. /** Z axis */
  93945. Z = 2
  93946. }
  93947. /**
  93948. * Class used to define virtual joystick (used in touch mode)
  93949. */
  93950. export class VirtualJoystick {
  93951. /**
  93952. * Gets or sets a boolean indicating that left and right values must be inverted
  93953. */
  93954. reverseLeftRight: boolean;
  93955. /**
  93956. * Gets or sets a boolean indicating that up and down values must be inverted
  93957. */
  93958. reverseUpDown: boolean;
  93959. /**
  93960. * Gets the offset value for the position (ie. the change of the position value)
  93961. */
  93962. deltaPosition: Vector3;
  93963. /**
  93964. * Gets a boolean indicating if the virtual joystick was pressed
  93965. */
  93966. pressed: boolean;
  93967. /**
  93968. * Canvas the virtual joystick will render onto, default z-index of this is 5
  93969. */
  93970. static Canvas: Nullable<HTMLCanvasElement>;
  93971. private static _globalJoystickIndex;
  93972. private static vjCanvasContext;
  93973. private static vjCanvasWidth;
  93974. private static vjCanvasHeight;
  93975. private static halfWidth;
  93976. private _action;
  93977. private _axisTargetedByLeftAndRight;
  93978. private _axisTargetedByUpAndDown;
  93979. private _joystickSensibility;
  93980. private _inversedSensibility;
  93981. private _joystickPointerID;
  93982. private _joystickColor;
  93983. private _joystickPointerPos;
  93984. private _joystickPreviousPointerPos;
  93985. private _joystickPointerStartPos;
  93986. private _deltaJoystickVector;
  93987. private _leftJoystick;
  93988. private _touches;
  93989. private _onPointerDownHandlerRef;
  93990. private _onPointerMoveHandlerRef;
  93991. private _onPointerUpHandlerRef;
  93992. private _onResize;
  93993. /**
  93994. * Creates a new virtual joystick
  93995. * @param leftJoystick defines that the joystick is for left hand (false by default)
  93996. */
  93997. constructor(leftJoystick?: boolean);
  93998. /**
  93999. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  94000. * @param newJoystickSensibility defines the new sensibility
  94001. */
  94002. setJoystickSensibility(newJoystickSensibility: number): void;
  94003. private _onPointerDown;
  94004. private _onPointerMove;
  94005. private _onPointerUp;
  94006. /**
  94007. * Change the color of the virtual joystick
  94008. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  94009. */
  94010. setJoystickColor(newColor: string): void;
  94011. /**
  94012. * Defines a callback to call when the joystick is touched
  94013. * @param action defines the callback
  94014. */
  94015. setActionOnTouch(action: () => any): void;
  94016. /**
  94017. * Defines which axis you'd like to control for left & right
  94018. * @param axis defines the axis to use
  94019. */
  94020. setAxisForLeftRight(axis: JoystickAxis): void;
  94021. /**
  94022. * Defines which axis you'd like to control for up & down
  94023. * @param axis defines the axis to use
  94024. */
  94025. setAxisForUpDown(axis: JoystickAxis): void;
  94026. private _drawVirtualJoystick;
  94027. /**
  94028. * Release internal HTML canvas
  94029. */
  94030. releaseCanvas(): void;
  94031. }
  94032. }
  94033. declare module BABYLON {
  94034. interface FreeCameraInputsManager {
  94035. /**
  94036. * Add virtual joystick input support to the input manager.
  94037. * @returns the current input manager
  94038. */
  94039. addVirtualJoystick(): FreeCameraInputsManager;
  94040. }
  94041. /**
  94042. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  94043. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94044. */
  94045. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  94046. /**
  94047. * Defines the camera the input is attached to.
  94048. */
  94049. camera: FreeCamera;
  94050. private _leftjoystick;
  94051. private _rightjoystick;
  94052. /**
  94053. * Gets the left stick of the virtual joystick.
  94054. * @returns The virtual Joystick
  94055. */
  94056. getLeftJoystick(): VirtualJoystick;
  94057. /**
  94058. * Gets the right stick of the virtual joystick.
  94059. * @returns The virtual Joystick
  94060. */
  94061. getRightJoystick(): VirtualJoystick;
  94062. /**
  94063. * Update the current camera state depending on the inputs that have been used this frame.
  94064. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94065. */
  94066. checkInputs(): void;
  94067. /**
  94068. * Attach the input controls to a specific dom element to get the input from.
  94069. * @param element Defines the element the controls should be listened from
  94070. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94071. */
  94072. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94073. /**
  94074. * Detach the current controls from the specified dom element.
  94075. * @param element Defines the element to stop listening the inputs from
  94076. */
  94077. detachControl(element: Nullable<HTMLElement>): void;
  94078. /**
  94079. * Gets the class name of the current intput.
  94080. * @returns the class name
  94081. */
  94082. getClassName(): string;
  94083. /**
  94084. * Get the friendly name associated with the input class.
  94085. * @returns the input friendly name
  94086. */
  94087. getSimpleName(): string;
  94088. }
  94089. }
  94090. declare module BABYLON {
  94091. /**
  94092. * This represents a FPS type of camera controlled by touch.
  94093. * This is like a universal camera minus the Gamepad controls.
  94094. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94095. */
  94096. export class TouchCamera extends FreeCamera {
  94097. /**
  94098. * Defines the touch sensibility for rotation.
  94099. * The higher the faster.
  94100. */
  94101. touchAngularSensibility: number;
  94102. /**
  94103. * Defines the touch sensibility for move.
  94104. * The higher the faster.
  94105. */
  94106. touchMoveSensibility: number;
  94107. /**
  94108. * Instantiates a new touch camera.
  94109. * This represents a FPS type of camera controlled by touch.
  94110. * This is like a universal camera minus the Gamepad controls.
  94111. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94112. * @param name Define the name of the camera in the scene
  94113. * @param position Define the start position of the camera in the scene
  94114. * @param scene Define the scene the camera belongs to
  94115. */
  94116. constructor(name: string, position: Vector3, scene: Scene);
  94117. /**
  94118. * Gets the current object class name.
  94119. * @return the class name
  94120. */
  94121. getClassName(): string;
  94122. /** @hidden */
  94123. _setupInputs(): void;
  94124. }
  94125. }
  94126. declare module BABYLON {
  94127. /**
  94128. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  94129. * being tilted forward or back and left or right.
  94130. */
  94131. export class DeviceOrientationCamera extends FreeCamera {
  94132. private _initialQuaternion;
  94133. private _quaternionCache;
  94134. /**
  94135. * Creates a new device orientation camera
  94136. * @param name The name of the camera
  94137. * @param position The start position camera
  94138. * @param scene The scene the camera belongs to
  94139. */
  94140. constructor(name: string, position: Vector3, scene: Scene);
  94141. /**
  94142. * Gets the current instance class name ("DeviceOrientationCamera").
  94143. * This helps avoiding instanceof at run time.
  94144. * @returns the class name
  94145. */
  94146. getClassName(): string;
  94147. /**
  94148. * @hidden
  94149. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  94150. */
  94151. _checkInputs(): void;
  94152. /**
  94153. * Reset the camera to its default orientation on the specified axis only.
  94154. * @param axis The axis to reset
  94155. */
  94156. resetToCurrentRotation(axis?: Axis): void;
  94157. }
  94158. }
  94159. declare module BABYLON {
  94160. /**
  94161. * 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,
  94162. * which still works and will still be found in many Playgrounds.
  94163. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94164. */
  94165. export class UniversalCamera extends TouchCamera {
  94166. /**
  94167. * Defines the gamepad rotation sensiblity.
  94168. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  94169. */
  94170. gamepadAngularSensibility: number;
  94171. /**
  94172. * Defines the gamepad move sensiblity.
  94173. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  94174. */
  94175. gamepadMoveSensibility: number;
  94176. /**
  94177. * 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,
  94178. * which still works and will still be found in many Playgrounds.
  94179. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94180. * @param name Define the name of the camera in the scene
  94181. * @param position Define the start position of the camera in the scene
  94182. * @param scene Define the scene the camera belongs to
  94183. */
  94184. constructor(name: string, position: Vector3, scene: Scene);
  94185. /**
  94186. * Gets the current object class name.
  94187. * @return the class name
  94188. */
  94189. getClassName(): string;
  94190. }
  94191. }
  94192. declare module BABYLON {
  94193. /**
  94194. * This represents a FPS type of camera. This is only here for back compat purpose.
  94195. * Please use the UniversalCamera instead as both are identical.
  94196. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94197. */
  94198. export class GamepadCamera extends UniversalCamera {
  94199. /**
  94200. * Instantiates a new Gamepad Camera
  94201. * This represents a FPS type of camera. This is only here for back compat purpose.
  94202. * Please use the UniversalCamera instead as both are identical.
  94203. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94204. * @param name Define the name of the camera in the scene
  94205. * @param position Define the start position of the camera in the scene
  94206. * @param scene Define the scene the camera belongs to
  94207. */
  94208. constructor(name: string, position: Vector3, scene: Scene);
  94209. /**
  94210. * Gets the current object class name.
  94211. * @return the class name
  94212. */
  94213. getClassName(): string;
  94214. }
  94215. }
  94216. declare module BABYLON {
  94217. /** @hidden */
  94218. export var passPixelShader: {
  94219. name: string;
  94220. shader: string;
  94221. };
  94222. }
  94223. declare module BABYLON {
  94224. /** @hidden */
  94225. export var passCubePixelShader: {
  94226. name: string;
  94227. shader: string;
  94228. };
  94229. }
  94230. declare module BABYLON {
  94231. /**
  94232. * PassPostProcess which produces an output the same as it's input
  94233. */
  94234. export class PassPostProcess extends PostProcess {
  94235. /**
  94236. * Creates the PassPostProcess
  94237. * @param name The name of the effect.
  94238. * @param options The required width/height ratio to downsize to before computing the render pass.
  94239. * @param camera The camera to apply the render pass to.
  94240. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94241. * @param engine The engine which the post process will be applied. (default: current engine)
  94242. * @param reusable If the post process can be reused on the same frame. (default: false)
  94243. * @param textureType The type of texture to be used when performing the post processing.
  94244. * @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)
  94245. */
  94246. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94247. }
  94248. /**
  94249. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  94250. */
  94251. export class PassCubePostProcess extends PostProcess {
  94252. private _face;
  94253. /**
  94254. * Gets or sets the cube face to display.
  94255. * * 0 is +X
  94256. * * 1 is -X
  94257. * * 2 is +Y
  94258. * * 3 is -Y
  94259. * * 4 is +Z
  94260. * * 5 is -Z
  94261. */
  94262. face: number;
  94263. /**
  94264. * Creates the PassCubePostProcess
  94265. * @param name The name of the effect.
  94266. * @param options The required width/height ratio to downsize to before computing the render pass.
  94267. * @param camera The camera to apply the render pass to.
  94268. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94269. * @param engine The engine which the post process will be applied. (default: current engine)
  94270. * @param reusable If the post process can be reused on the same frame. (default: false)
  94271. * @param textureType The type of texture to be used when performing the post processing.
  94272. * @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)
  94273. */
  94274. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94275. }
  94276. }
  94277. declare module BABYLON {
  94278. /** @hidden */
  94279. export var anaglyphPixelShader: {
  94280. name: string;
  94281. shader: string;
  94282. };
  94283. }
  94284. declare module BABYLON {
  94285. /**
  94286. * Postprocess used to generate anaglyphic rendering
  94287. */
  94288. export class AnaglyphPostProcess extends PostProcess {
  94289. private _passedProcess;
  94290. /**
  94291. * Creates a new AnaglyphPostProcess
  94292. * @param name defines postprocess name
  94293. * @param options defines creation options or target ratio scale
  94294. * @param rigCameras defines cameras using this postprocess
  94295. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  94296. * @param engine defines hosting engine
  94297. * @param reusable defines if the postprocess will be reused multiple times per frame
  94298. */
  94299. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  94300. }
  94301. }
  94302. declare module BABYLON {
  94303. /**
  94304. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  94305. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94306. */
  94307. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  94308. /**
  94309. * Creates a new AnaglyphArcRotateCamera
  94310. * @param name defines camera name
  94311. * @param alpha defines alpha angle (in radians)
  94312. * @param beta defines beta angle (in radians)
  94313. * @param radius defines radius
  94314. * @param target defines camera target
  94315. * @param interaxialDistance defines distance between each color axis
  94316. * @param scene defines the hosting scene
  94317. */
  94318. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  94319. /**
  94320. * Gets camera class name
  94321. * @returns AnaglyphArcRotateCamera
  94322. */
  94323. getClassName(): string;
  94324. }
  94325. }
  94326. declare module BABYLON {
  94327. /**
  94328. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  94329. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94330. */
  94331. export class AnaglyphFreeCamera extends FreeCamera {
  94332. /**
  94333. * Creates a new AnaglyphFreeCamera
  94334. * @param name defines camera name
  94335. * @param position defines initial position
  94336. * @param interaxialDistance defines distance between each color axis
  94337. * @param scene defines the hosting scene
  94338. */
  94339. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94340. /**
  94341. * Gets camera class name
  94342. * @returns AnaglyphFreeCamera
  94343. */
  94344. getClassName(): string;
  94345. }
  94346. }
  94347. declare module BABYLON {
  94348. /**
  94349. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  94350. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94351. */
  94352. export class AnaglyphGamepadCamera extends GamepadCamera {
  94353. /**
  94354. * Creates a new AnaglyphGamepadCamera
  94355. * @param name defines camera name
  94356. * @param position defines initial position
  94357. * @param interaxialDistance defines distance between each color axis
  94358. * @param scene defines the hosting scene
  94359. */
  94360. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94361. /**
  94362. * Gets camera class name
  94363. * @returns AnaglyphGamepadCamera
  94364. */
  94365. getClassName(): string;
  94366. }
  94367. }
  94368. declare module BABYLON {
  94369. /**
  94370. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  94371. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94372. */
  94373. export class AnaglyphUniversalCamera extends UniversalCamera {
  94374. /**
  94375. * Creates a new AnaglyphUniversalCamera
  94376. * @param name defines camera name
  94377. * @param position defines initial position
  94378. * @param interaxialDistance defines distance between each color axis
  94379. * @param scene defines the hosting scene
  94380. */
  94381. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94382. /**
  94383. * Gets camera class name
  94384. * @returns AnaglyphUniversalCamera
  94385. */
  94386. getClassName(): string;
  94387. }
  94388. }
  94389. declare module BABYLON {
  94390. /** @hidden */
  94391. export var stereoscopicInterlacePixelShader: {
  94392. name: string;
  94393. shader: string;
  94394. };
  94395. }
  94396. declare module BABYLON {
  94397. /**
  94398. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  94399. */
  94400. export class StereoscopicInterlacePostProcess extends PostProcess {
  94401. private _stepSize;
  94402. private _passedProcess;
  94403. /**
  94404. * Initializes a StereoscopicInterlacePostProcess
  94405. * @param name The name of the effect.
  94406. * @param rigCameras The rig cameras to be appled to the post process
  94407. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  94408. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94409. * @param engine The engine which the post process will be applied. (default: current engine)
  94410. * @param reusable If the post process can be reused on the same frame. (default: false)
  94411. */
  94412. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  94413. }
  94414. }
  94415. declare module BABYLON {
  94416. /**
  94417. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  94418. * @see http://doc.babylonjs.com/features/cameras
  94419. */
  94420. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  94421. /**
  94422. * Creates a new StereoscopicArcRotateCamera
  94423. * @param name defines camera name
  94424. * @param alpha defines alpha angle (in radians)
  94425. * @param beta defines beta angle (in radians)
  94426. * @param radius defines radius
  94427. * @param target defines camera target
  94428. * @param interaxialDistance defines distance between each color axis
  94429. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94430. * @param scene defines the hosting scene
  94431. */
  94432. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94433. /**
  94434. * Gets camera class name
  94435. * @returns StereoscopicArcRotateCamera
  94436. */
  94437. getClassName(): string;
  94438. }
  94439. }
  94440. declare module BABYLON {
  94441. /**
  94442. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  94443. * @see http://doc.babylonjs.com/features/cameras
  94444. */
  94445. export class StereoscopicFreeCamera extends FreeCamera {
  94446. /**
  94447. * Creates a new StereoscopicFreeCamera
  94448. * @param name defines camera name
  94449. * @param position defines initial position
  94450. * @param interaxialDistance defines distance between each color axis
  94451. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94452. * @param scene defines the hosting scene
  94453. */
  94454. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94455. /**
  94456. * Gets camera class name
  94457. * @returns StereoscopicFreeCamera
  94458. */
  94459. getClassName(): string;
  94460. }
  94461. }
  94462. declare module BABYLON {
  94463. /**
  94464. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  94465. * @see http://doc.babylonjs.com/features/cameras
  94466. */
  94467. export class StereoscopicGamepadCamera extends GamepadCamera {
  94468. /**
  94469. * Creates a new StereoscopicGamepadCamera
  94470. * @param name defines camera name
  94471. * @param position defines initial position
  94472. * @param interaxialDistance defines distance between each color axis
  94473. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94474. * @param scene defines the hosting scene
  94475. */
  94476. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94477. /**
  94478. * Gets camera class name
  94479. * @returns StereoscopicGamepadCamera
  94480. */
  94481. getClassName(): string;
  94482. }
  94483. }
  94484. declare module BABYLON {
  94485. /**
  94486. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  94487. * @see http://doc.babylonjs.com/features/cameras
  94488. */
  94489. export class StereoscopicUniversalCamera extends UniversalCamera {
  94490. /**
  94491. * Creates a new StereoscopicUniversalCamera
  94492. * @param name defines camera name
  94493. * @param position defines initial position
  94494. * @param interaxialDistance defines distance between each color axis
  94495. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94496. * @param scene defines the hosting scene
  94497. */
  94498. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94499. /**
  94500. * Gets camera class name
  94501. * @returns StereoscopicUniversalCamera
  94502. */
  94503. getClassName(): string;
  94504. }
  94505. }
  94506. declare module BABYLON {
  94507. /**
  94508. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94509. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94510. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94511. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94512. */
  94513. export class VirtualJoysticksCamera extends FreeCamera {
  94514. /**
  94515. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  94516. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94517. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94518. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94519. * @param name Define the name of the camera in the scene
  94520. * @param position Define the start position of the camera in the scene
  94521. * @param scene Define the scene the camera belongs to
  94522. */
  94523. constructor(name: string, position: Vector3, scene: Scene);
  94524. /**
  94525. * Gets the current object class name.
  94526. * @return the class name
  94527. */
  94528. getClassName(): string;
  94529. }
  94530. }
  94531. declare module BABYLON {
  94532. /**
  94533. * This represents all the required metrics to create a VR camera.
  94534. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  94535. */
  94536. export class VRCameraMetrics {
  94537. /**
  94538. * Define the horizontal resolution off the screen.
  94539. */
  94540. hResolution: number;
  94541. /**
  94542. * Define the vertical resolution off the screen.
  94543. */
  94544. vResolution: number;
  94545. /**
  94546. * Define the horizontal screen size.
  94547. */
  94548. hScreenSize: number;
  94549. /**
  94550. * Define the vertical screen size.
  94551. */
  94552. vScreenSize: number;
  94553. /**
  94554. * Define the vertical screen center position.
  94555. */
  94556. vScreenCenter: number;
  94557. /**
  94558. * Define the distance of the eyes to the screen.
  94559. */
  94560. eyeToScreenDistance: number;
  94561. /**
  94562. * Define the distance between both lenses
  94563. */
  94564. lensSeparationDistance: number;
  94565. /**
  94566. * Define the distance between both viewer's eyes.
  94567. */
  94568. interpupillaryDistance: number;
  94569. /**
  94570. * Define the distortion factor of the VR postprocess.
  94571. * Please, touch with care.
  94572. */
  94573. distortionK: number[];
  94574. /**
  94575. * Define the chromatic aberration correction factors for the VR post process.
  94576. */
  94577. chromaAbCorrection: number[];
  94578. /**
  94579. * Define the scale factor of the post process.
  94580. * The smaller the better but the slower.
  94581. */
  94582. postProcessScaleFactor: number;
  94583. /**
  94584. * Define an offset for the lens center.
  94585. */
  94586. lensCenterOffset: number;
  94587. /**
  94588. * Define if the current vr camera should compensate the distortion of the lense or not.
  94589. */
  94590. compensateDistortion: boolean;
  94591. /**
  94592. * Gets the rendering aspect ratio based on the provided resolutions.
  94593. */
  94594. readonly aspectRatio: number;
  94595. /**
  94596. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  94597. */
  94598. readonly aspectRatioFov: number;
  94599. /**
  94600. * @hidden
  94601. */
  94602. readonly leftHMatrix: Matrix;
  94603. /**
  94604. * @hidden
  94605. */
  94606. readonly rightHMatrix: Matrix;
  94607. /**
  94608. * @hidden
  94609. */
  94610. readonly leftPreViewMatrix: Matrix;
  94611. /**
  94612. * @hidden
  94613. */
  94614. readonly rightPreViewMatrix: Matrix;
  94615. /**
  94616. * Get the default VRMetrics based on the most generic setup.
  94617. * @returns the default vr metrics
  94618. */
  94619. static GetDefault(): VRCameraMetrics;
  94620. }
  94621. }
  94622. declare module BABYLON {
  94623. /** @hidden */
  94624. export var vrDistortionCorrectionPixelShader: {
  94625. name: string;
  94626. shader: string;
  94627. };
  94628. }
  94629. declare module BABYLON {
  94630. /**
  94631. * VRDistortionCorrectionPostProcess used for mobile VR
  94632. */
  94633. export class VRDistortionCorrectionPostProcess extends PostProcess {
  94634. private _isRightEye;
  94635. private _distortionFactors;
  94636. private _postProcessScaleFactor;
  94637. private _lensCenterOffset;
  94638. private _scaleIn;
  94639. private _scaleFactor;
  94640. private _lensCenter;
  94641. /**
  94642. * Initializes the VRDistortionCorrectionPostProcess
  94643. * @param name The name of the effect.
  94644. * @param camera The camera to apply the render pass to.
  94645. * @param isRightEye If this is for the right eye distortion
  94646. * @param vrMetrics All the required metrics for the VR camera
  94647. */
  94648. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  94649. }
  94650. }
  94651. declare module BABYLON {
  94652. /**
  94653. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  94654. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94655. */
  94656. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  94657. /**
  94658. * Creates a new VRDeviceOrientationArcRotateCamera
  94659. * @param name defines camera name
  94660. * @param alpha defines the camera rotation along the logitudinal axis
  94661. * @param beta defines the camera rotation along the latitudinal axis
  94662. * @param radius defines the camera distance from its target
  94663. * @param target defines the camera target
  94664. * @param scene defines the scene the camera belongs to
  94665. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94666. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94667. */
  94668. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94669. /**
  94670. * Gets camera class name
  94671. * @returns VRDeviceOrientationArcRotateCamera
  94672. */
  94673. getClassName(): string;
  94674. }
  94675. }
  94676. declare module BABYLON {
  94677. /**
  94678. * Camera used to simulate VR rendering (based on FreeCamera)
  94679. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94680. */
  94681. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  94682. /**
  94683. * Creates a new VRDeviceOrientationFreeCamera
  94684. * @param name defines camera name
  94685. * @param position defines the start position of the camera
  94686. * @param scene defines the scene the camera belongs to
  94687. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94688. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94689. */
  94690. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94691. /**
  94692. * Gets camera class name
  94693. * @returns VRDeviceOrientationFreeCamera
  94694. */
  94695. getClassName(): string;
  94696. }
  94697. }
  94698. declare module BABYLON {
  94699. /**
  94700. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  94701. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94702. */
  94703. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  94704. /**
  94705. * Creates a new VRDeviceOrientationGamepadCamera
  94706. * @param name defines camera name
  94707. * @param position defines the start position of the camera
  94708. * @param scene defines the scene the camera belongs to
  94709. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94710. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94711. */
  94712. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94713. /**
  94714. * Gets camera class name
  94715. * @returns VRDeviceOrientationGamepadCamera
  94716. */
  94717. getClassName(): string;
  94718. }
  94719. }
  94720. declare module BABYLON {
  94721. /**
  94722. * Defines supported buttons for XBox360 compatible gamepads
  94723. */
  94724. export enum Xbox360Button {
  94725. /** A */
  94726. A = 0,
  94727. /** B */
  94728. B = 1,
  94729. /** X */
  94730. X = 2,
  94731. /** Y */
  94732. Y = 3,
  94733. /** Start */
  94734. Start = 4,
  94735. /** Back */
  94736. Back = 5,
  94737. /** Left button */
  94738. LB = 6,
  94739. /** Right button */
  94740. RB = 7,
  94741. /** Left stick */
  94742. LeftStick = 8,
  94743. /** Right stick */
  94744. RightStick = 9
  94745. }
  94746. /** Defines values for XBox360 DPad */
  94747. export enum Xbox360Dpad {
  94748. /** Up */
  94749. Up = 0,
  94750. /** Down */
  94751. Down = 1,
  94752. /** Left */
  94753. Left = 2,
  94754. /** Right */
  94755. Right = 3
  94756. }
  94757. /**
  94758. * Defines a XBox360 gamepad
  94759. */
  94760. export class Xbox360Pad extends Gamepad {
  94761. private _leftTrigger;
  94762. private _rightTrigger;
  94763. private _onlefttriggerchanged;
  94764. private _onrighttriggerchanged;
  94765. private _onbuttondown;
  94766. private _onbuttonup;
  94767. private _ondpaddown;
  94768. private _ondpadup;
  94769. /** Observable raised when a button is pressed */
  94770. onButtonDownObservable: Observable<Xbox360Button>;
  94771. /** Observable raised when a button is released */
  94772. onButtonUpObservable: Observable<Xbox360Button>;
  94773. /** Observable raised when a pad is pressed */
  94774. onPadDownObservable: Observable<Xbox360Dpad>;
  94775. /** Observable raised when a pad is released */
  94776. onPadUpObservable: Observable<Xbox360Dpad>;
  94777. private _buttonA;
  94778. private _buttonB;
  94779. private _buttonX;
  94780. private _buttonY;
  94781. private _buttonBack;
  94782. private _buttonStart;
  94783. private _buttonLB;
  94784. private _buttonRB;
  94785. private _buttonLeftStick;
  94786. private _buttonRightStick;
  94787. private _dPadUp;
  94788. private _dPadDown;
  94789. private _dPadLeft;
  94790. private _dPadRight;
  94791. private _isXboxOnePad;
  94792. /**
  94793. * Creates a new XBox360 gamepad object
  94794. * @param id defines the id of this gamepad
  94795. * @param index defines its index
  94796. * @param gamepad defines the internal HTML gamepad object
  94797. * @param xboxOne defines if it is a XBox One gamepad
  94798. */
  94799. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  94800. /**
  94801. * Defines the callback to call when left trigger is pressed
  94802. * @param callback defines the callback to use
  94803. */
  94804. onlefttriggerchanged(callback: (value: number) => void): void;
  94805. /**
  94806. * Defines the callback to call when right trigger is pressed
  94807. * @param callback defines the callback to use
  94808. */
  94809. onrighttriggerchanged(callback: (value: number) => void): void;
  94810. /**
  94811. * Gets the left trigger value
  94812. */
  94813. /**
  94814. * Sets the left trigger value
  94815. */
  94816. leftTrigger: number;
  94817. /**
  94818. * Gets the right trigger value
  94819. */
  94820. /**
  94821. * Sets the right trigger value
  94822. */
  94823. rightTrigger: number;
  94824. /**
  94825. * Defines the callback to call when a button is pressed
  94826. * @param callback defines the callback to use
  94827. */
  94828. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  94829. /**
  94830. * Defines the callback to call when a button is released
  94831. * @param callback defines the callback to use
  94832. */
  94833. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  94834. /**
  94835. * Defines the callback to call when a pad is pressed
  94836. * @param callback defines the callback to use
  94837. */
  94838. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  94839. /**
  94840. * Defines the callback to call when a pad is released
  94841. * @param callback defines the callback to use
  94842. */
  94843. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  94844. private _setButtonValue;
  94845. private _setDPadValue;
  94846. /**
  94847. * Gets the value of the `A` button
  94848. */
  94849. /**
  94850. * Sets the value of the `A` button
  94851. */
  94852. buttonA: number;
  94853. /**
  94854. * Gets the value of the `B` button
  94855. */
  94856. /**
  94857. * Sets the value of the `B` button
  94858. */
  94859. buttonB: number;
  94860. /**
  94861. * Gets the value of the `X` button
  94862. */
  94863. /**
  94864. * Sets the value of the `X` button
  94865. */
  94866. buttonX: number;
  94867. /**
  94868. * Gets the value of the `Y` button
  94869. */
  94870. /**
  94871. * Sets the value of the `Y` button
  94872. */
  94873. buttonY: number;
  94874. /**
  94875. * Gets the value of the `Start` button
  94876. */
  94877. /**
  94878. * Sets the value of the `Start` button
  94879. */
  94880. buttonStart: number;
  94881. /**
  94882. * Gets the value of the `Back` button
  94883. */
  94884. /**
  94885. * Sets the value of the `Back` button
  94886. */
  94887. buttonBack: number;
  94888. /**
  94889. * Gets the value of the `Left` button
  94890. */
  94891. /**
  94892. * Sets the value of the `Left` button
  94893. */
  94894. buttonLB: number;
  94895. /**
  94896. * Gets the value of the `Right` button
  94897. */
  94898. /**
  94899. * Sets the value of the `Right` button
  94900. */
  94901. buttonRB: number;
  94902. /**
  94903. * Gets the value of the Left joystick
  94904. */
  94905. /**
  94906. * Sets the value of the Left joystick
  94907. */
  94908. buttonLeftStick: number;
  94909. /**
  94910. * Gets the value of the Right joystick
  94911. */
  94912. /**
  94913. * Sets the value of the Right joystick
  94914. */
  94915. buttonRightStick: number;
  94916. /**
  94917. * Gets the value of D-pad up
  94918. */
  94919. /**
  94920. * Sets the value of D-pad up
  94921. */
  94922. dPadUp: number;
  94923. /**
  94924. * Gets the value of D-pad down
  94925. */
  94926. /**
  94927. * Sets the value of D-pad down
  94928. */
  94929. dPadDown: number;
  94930. /**
  94931. * Gets the value of D-pad left
  94932. */
  94933. /**
  94934. * Sets the value of D-pad left
  94935. */
  94936. dPadLeft: number;
  94937. /**
  94938. * Gets the value of D-pad right
  94939. */
  94940. /**
  94941. * Sets the value of D-pad right
  94942. */
  94943. dPadRight: number;
  94944. /**
  94945. * Force the gamepad to synchronize with device values
  94946. */
  94947. update(): void;
  94948. /**
  94949. * Disposes the gamepad
  94950. */
  94951. dispose(): void;
  94952. }
  94953. }
  94954. declare module BABYLON {
  94955. /**
  94956. * Base class of materials working in push mode in babylon JS
  94957. * @hidden
  94958. */
  94959. export class PushMaterial extends Material {
  94960. protected _activeEffect: Effect;
  94961. protected _normalMatrix: Matrix;
  94962. /**
  94963. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  94964. * This means that the material can keep using a previous shader while a new one is being compiled.
  94965. * This is mostly used when shader parallel compilation is supported (true by default)
  94966. */
  94967. allowShaderHotSwapping: boolean;
  94968. constructor(name: string, scene: Scene);
  94969. getEffect(): Effect;
  94970. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94971. /**
  94972. * Binds the given world matrix to the active effect
  94973. *
  94974. * @param world the matrix to bind
  94975. */
  94976. bindOnlyWorldMatrix(world: Matrix): void;
  94977. /**
  94978. * Binds the given normal matrix to the active effect
  94979. *
  94980. * @param normalMatrix the matrix to bind
  94981. */
  94982. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  94983. bind(world: Matrix, mesh?: Mesh): void;
  94984. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  94985. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  94986. }
  94987. }
  94988. declare module BABYLON {
  94989. /**
  94990. * This groups all the flags used to control the materials channel.
  94991. */
  94992. export class MaterialFlags {
  94993. private static _DiffuseTextureEnabled;
  94994. /**
  94995. * Are diffuse textures enabled in the application.
  94996. */
  94997. static DiffuseTextureEnabled: boolean;
  94998. private static _AmbientTextureEnabled;
  94999. /**
  95000. * Are ambient textures enabled in the application.
  95001. */
  95002. static AmbientTextureEnabled: boolean;
  95003. private static _OpacityTextureEnabled;
  95004. /**
  95005. * Are opacity textures enabled in the application.
  95006. */
  95007. static OpacityTextureEnabled: boolean;
  95008. private static _ReflectionTextureEnabled;
  95009. /**
  95010. * Are reflection textures enabled in the application.
  95011. */
  95012. static ReflectionTextureEnabled: boolean;
  95013. private static _EmissiveTextureEnabled;
  95014. /**
  95015. * Are emissive textures enabled in the application.
  95016. */
  95017. static EmissiveTextureEnabled: boolean;
  95018. private static _SpecularTextureEnabled;
  95019. /**
  95020. * Are specular textures enabled in the application.
  95021. */
  95022. static SpecularTextureEnabled: boolean;
  95023. private static _BumpTextureEnabled;
  95024. /**
  95025. * Are bump textures enabled in the application.
  95026. */
  95027. static BumpTextureEnabled: boolean;
  95028. private static _LightmapTextureEnabled;
  95029. /**
  95030. * Are lightmap textures enabled in the application.
  95031. */
  95032. static LightmapTextureEnabled: boolean;
  95033. private static _RefractionTextureEnabled;
  95034. /**
  95035. * Are refraction textures enabled in the application.
  95036. */
  95037. static RefractionTextureEnabled: boolean;
  95038. private static _ColorGradingTextureEnabled;
  95039. /**
  95040. * Are color grading textures enabled in the application.
  95041. */
  95042. static ColorGradingTextureEnabled: boolean;
  95043. private static _FresnelEnabled;
  95044. /**
  95045. * Are fresnels enabled in the application.
  95046. */
  95047. static FresnelEnabled: boolean;
  95048. private static _ClearCoatTextureEnabled;
  95049. /**
  95050. * Are clear coat textures enabled in the application.
  95051. */
  95052. static ClearCoatTextureEnabled: boolean;
  95053. private static _ClearCoatBumpTextureEnabled;
  95054. /**
  95055. * Are clear coat bump textures enabled in the application.
  95056. */
  95057. static ClearCoatBumpTextureEnabled: boolean;
  95058. private static _ClearCoatTintTextureEnabled;
  95059. /**
  95060. * Are clear coat tint textures enabled in the application.
  95061. */
  95062. static ClearCoatTintTextureEnabled: boolean;
  95063. private static _SheenTextureEnabled;
  95064. /**
  95065. * Are sheen textures enabled in the application.
  95066. */
  95067. static SheenTextureEnabled: boolean;
  95068. private static _AnisotropicTextureEnabled;
  95069. /**
  95070. * Are anisotropic textures enabled in the application.
  95071. */
  95072. static AnisotropicTextureEnabled: boolean;
  95073. }
  95074. }
  95075. declare module BABYLON {
  95076. /** @hidden */
  95077. export var defaultFragmentDeclaration: {
  95078. name: string;
  95079. shader: string;
  95080. };
  95081. }
  95082. declare module BABYLON {
  95083. /** @hidden */
  95084. export var defaultUboDeclaration: {
  95085. name: string;
  95086. shader: string;
  95087. };
  95088. }
  95089. declare module BABYLON {
  95090. /** @hidden */
  95091. export var lightFragmentDeclaration: {
  95092. name: string;
  95093. shader: string;
  95094. };
  95095. }
  95096. declare module BABYLON {
  95097. /** @hidden */
  95098. export var lightUboDeclaration: {
  95099. name: string;
  95100. shader: string;
  95101. };
  95102. }
  95103. declare module BABYLON {
  95104. /** @hidden */
  95105. export var lightsFragmentFunctions: {
  95106. name: string;
  95107. shader: string;
  95108. };
  95109. }
  95110. declare module BABYLON {
  95111. /** @hidden */
  95112. export var shadowsFragmentFunctions: {
  95113. name: string;
  95114. shader: string;
  95115. };
  95116. }
  95117. declare module BABYLON {
  95118. /** @hidden */
  95119. export var fresnelFunction: {
  95120. name: string;
  95121. shader: string;
  95122. };
  95123. }
  95124. declare module BABYLON {
  95125. /** @hidden */
  95126. export var reflectionFunction: {
  95127. name: string;
  95128. shader: string;
  95129. };
  95130. }
  95131. declare module BABYLON {
  95132. /** @hidden */
  95133. export var bumpFragmentFunctions: {
  95134. name: string;
  95135. shader: string;
  95136. };
  95137. }
  95138. declare module BABYLON {
  95139. /** @hidden */
  95140. export var logDepthDeclaration: {
  95141. name: string;
  95142. shader: string;
  95143. };
  95144. }
  95145. declare module BABYLON {
  95146. /** @hidden */
  95147. export var bumpFragment: {
  95148. name: string;
  95149. shader: string;
  95150. };
  95151. }
  95152. declare module BABYLON {
  95153. /** @hidden */
  95154. export var depthPrePass: {
  95155. name: string;
  95156. shader: string;
  95157. };
  95158. }
  95159. declare module BABYLON {
  95160. /** @hidden */
  95161. export var lightFragment: {
  95162. name: string;
  95163. shader: string;
  95164. };
  95165. }
  95166. declare module BABYLON {
  95167. /** @hidden */
  95168. export var logDepthFragment: {
  95169. name: string;
  95170. shader: string;
  95171. };
  95172. }
  95173. declare module BABYLON {
  95174. /** @hidden */
  95175. export var defaultPixelShader: {
  95176. name: string;
  95177. shader: string;
  95178. };
  95179. }
  95180. declare module BABYLON {
  95181. /** @hidden */
  95182. export var defaultVertexDeclaration: {
  95183. name: string;
  95184. shader: string;
  95185. };
  95186. }
  95187. declare module BABYLON {
  95188. /** @hidden */
  95189. export var bumpVertexDeclaration: {
  95190. name: string;
  95191. shader: string;
  95192. };
  95193. }
  95194. declare module BABYLON {
  95195. /** @hidden */
  95196. export var bumpVertex: {
  95197. name: string;
  95198. shader: string;
  95199. };
  95200. }
  95201. declare module BABYLON {
  95202. /** @hidden */
  95203. export var fogVertex: {
  95204. name: string;
  95205. shader: string;
  95206. };
  95207. }
  95208. declare module BABYLON {
  95209. /** @hidden */
  95210. export var shadowsVertex: {
  95211. name: string;
  95212. shader: string;
  95213. };
  95214. }
  95215. declare module BABYLON {
  95216. /** @hidden */
  95217. export var pointCloudVertex: {
  95218. name: string;
  95219. shader: string;
  95220. };
  95221. }
  95222. declare module BABYLON {
  95223. /** @hidden */
  95224. export var logDepthVertex: {
  95225. name: string;
  95226. shader: string;
  95227. };
  95228. }
  95229. declare module BABYLON {
  95230. /** @hidden */
  95231. export var defaultVertexShader: {
  95232. name: string;
  95233. shader: string;
  95234. };
  95235. }
  95236. declare module BABYLON {
  95237. /** @hidden */
  95238. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  95239. MAINUV1: boolean;
  95240. MAINUV2: boolean;
  95241. DIFFUSE: boolean;
  95242. DIFFUSEDIRECTUV: number;
  95243. AMBIENT: boolean;
  95244. AMBIENTDIRECTUV: number;
  95245. OPACITY: boolean;
  95246. OPACITYDIRECTUV: number;
  95247. OPACITYRGB: boolean;
  95248. REFLECTION: boolean;
  95249. EMISSIVE: boolean;
  95250. EMISSIVEDIRECTUV: number;
  95251. SPECULAR: boolean;
  95252. SPECULARDIRECTUV: number;
  95253. BUMP: boolean;
  95254. BUMPDIRECTUV: number;
  95255. PARALLAX: boolean;
  95256. PARALLAXOCCLUSION: boolean;
  95257. SPECULAROVERALPHA: boolean;
  95258. CLIPPLANE: boolean;
  95259. CLIPPLANE2: boolean;
  95260. CLIPPLANE3: boolean;
  95261. CLIPPLANE4: boolean;
  95262. ALPHATEST: boolean;
  95263. DEPTHPREPASS: boolean;
  95264. ALPHAFROMDIFFUSE: boolean;
  95265. POINTSIZE: boolean;
  95266. FOG: boolean;
  95267. SPECULARTERM: boolean;
  95268. DIFFUSEFRESNEL: boolean;
  95269. OPACITYFRESNEL: boolean;
  95270. REFLECTIONFRESNEL: boolean;
  95271. REFRACTIONFRESNEL: boolean;
  95272. EMISSIVEFRESNEL: boolean;
  95273. FRESNEL: boolean;
  95274. NORMAL: boolean;
  95275. UV1: boolean;
  95276. UV2: boolean;
  95277. VERTEXCOLOR: boolean;
  95278. VERTEXALPHA: boolean;
  95279. NUM_BONE_INFLUENCERS: number;
  95280. BonesPerMesh: number;
  95281. BONETEXTURE: boolean;
  95282. INSTANCES: boolean;
  95283. GLOSSINESS: boolean;
  95284. ROUGHNESS: boolean;
  95285. EMISSIVEASILLUMINATION: boolean;
  95286. LINKEMISSIVEWITHDIFFUSE: boolean;
  95287. REFLECTIONFRESNELFROMSPECULAR: boolean;
  95288. LIGHTMAP: boolean;
  95289. LIGHTMAPDIRECTUV: number;
  95290. OBJECTSPACE_NORMALMAP: boolean;
  95291. USELIGHTMAPASSHADOWMAP: boolean;
  95292. REFLECTIONMAP_3D: boolean;
  95293. REFLECTIONMAP_SPHERICAL: boolean;
  95294. REFLECTIONMAP_PLANAR: boolean;
  95295. REFLECTIONMAP_CUBIC: boolean;
  95296. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  95297. REFLECTIONMAP_PROJECTION: boolean;
  95298. REFLECTIONMAP_SKYBOX: boolean;
  95299. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  95300. REFLECTIONMAP_EXPLICIT: boolean;
  95301. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  95302. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  95303. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  95304. INVERTCUBICMAP: boolean;
  95305. LOGARITHMICDEPTH: boolean;
  95306. REFRACTION: boolean;
  95307. REFRACTIONMAP_3D: boolean;
  95308. REFLECTIONOVERALPHA: boolean;
  95309. TWOSIDEDLIGHTING: boolean;
  95310. SHADOWFLOAT: boolean;
  95311. MORPHTARGETS: boolean;
  95312. MORPHTARGETS_NORMAL: boolean;
  95313. MORPHTARGETS_TANGENT: boolean;
  95314. NUM_MORPH_INFLUENCERS: number;
  95315. NONUNIFORMSCALING: boolean;
  95316. PREMULTIPLYALPHA: boolean;
  95317. IMAGEPROCESSING: boolean;
  95318. VIGNETTE: boolean;
  95319. VIGNETTEBLENDMODEMULTIPLY: boolean;
  95320. VIGNETTEBLENDMODEOPAQUE: boolean;
  95321. TONEMAPPING: boolean;
  95322. TONEMAPPING_ACES: boolean;
  95323. CONTRAST: boolean;
  95324. COLORCURVES: boolean;
  95325. COLORGRADING: boolean;
  95326. COLORGRADING3D: boolean;
  95327. SAMPLER3DGREENDEPTH: boolean;
  95328. SAMPLER3DBGRMAP: boolean;
  95329. IMAGEPROCESSINGPOSTPROCESS: boolean;
  95330. /**
  95331. * If the reflection texture on this material is in linear color space
  95332. * @hidden
  95333. */
  95334. IS_REFLECTION_LINEAR: boolean;
  95335. /**
  95336. * If the refraction texture on this material is in linear color space
  95337. * @hidden
  95338. */
  95339. IS_REFRACTION_LINEAR: boolean;
  95340. EXPOSURE: boolean;
  95341. constructor();
  95342. setReflectionMode(modeToEnable: string): void;
  95343. }
  95344. /**
  95345. * This is the default material used in Babylon. It is the best trade off between quality
  95346. * and performances.
  95347. * @see http://doc.babylonjs.com/babylon101/materials
  95348. */
  95349. export class StandardMaterial extends PushMaterial {
  95350. private _diffuseTexture;
  95351. /**
  95352. * The basic texture of the material as viewed under a light.
  95353. */
  95354. diffuseTexture: Nullable<BaseTexture>;
  95355. private _ambientTexture;
  95356. /**
  95357. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  95358. */
  95359. ambientTexture: Nullable<BaseTexture>;
  95360. private _opacityTexture;
  95361. /**
  95362. * Define the transparency of the material from a texture.
  95363. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  95364. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  95365. */
  95366. opacityTexture: Nullable<BaseTexture>;
  95367. private _reflectionTexture;
  95368. /**
  95369. * Define the texture used to display the reflection.
  95370. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95371. */
  95372. reflectionTexture: Nullable<BaseTexture>;
  95373. private _emissiveTexture;
  95374. /**
  95375. * Define texture of the material as if self lit.
  95376. * This will be mixed in the final result even in the absence of light.
  95377. */
  95378. emissiveTexture: Nullable<BaseTexture>;
  95379. private _specularTexture;
  95380. /**
  95381. * Define how the color and intensity of the highlight given by the light in the material.
  95382. */
  95383. specularTexture: Nullable<BaseTexture>;
  95384. private _bumpTexture;
  95385. /**
  95386. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  95387. * 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.
  95388. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  95389. */
  95390. bumpTexture: Nullable<BaseTexture>;
  95391. private _lightmapTexture;
  95392. /**
  95393. * Complex lighting can be computationally expensive to compute at runtime.
  95394. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  95395. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  95396. */
  95397. lightmapTexture: Nullable<BaseTexture>;
  95398. private _refractionTexture;
  95399. /**
  95400. * Define the texture used to display the refraction.
  95401. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95402. */
  95403. refractionTexture: Nullable<BaseTexture>;
  95404. /**
  95405. * The color of the material lit by the environmental background lighting.
  95406. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  95407. */
  95408. ambientColor: Color3;
  95409. /**
  95410. * The basic color of the material as viewed under a light.
  95411. */
  95412. diffuseColor: Color3;
  95413. /**
  95414. * Define how the color and intensity of the highlight given by the light in the material.
  95415. */
  95416. specularColor: Color3;
  95417. /**
  95418. * Define the color of the material as if self lit.
  95419. * This will be mixed in the final result even in the absence of light.
  95420. */
  95421. emissiveColor: Color3;
  95422. /**
  95423. * Defines how sharp are the highlights in the material.
  95424. * The bigger the value the sharper giving a more glossy feeling to the result.
  95425. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  95426. */
  95427. specularPower: number;
  95428. private _useAlphaFromDiffuseTexture;
  95429. /**
  95430. * Does the transparency come from the diffuse texture alpha channel.
  95431. */
  95432. useAlphaFromDiffuseTexture: boolean;
  95433. private _useEmissiveAsIllumination;
  95434. /**
  95435. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  95436. */
  95437. useEmissiveAsIllumination: boolean;
  95438. private _linkEmissiveWithDiffuse;
  95439. /**
  95440. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  95441. * the emissive level when the final color is close to one.
  95442. */
  95443. linkEmissiveWithDiffuse: boolean;
  95444. private _useSpecularOverAlpha;
  95445. /**
  95446. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  95447. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  95448. */
  95449. useSpecularOverAlpha: boolean;
  95450. private _useReflectionOverAlpha;
  95451. /**
  95452. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  95453. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  95454. */
  95455. useReflectionOverAlpha: boolean;
  95456. private _disableLighting;
  95457. /**
  95458. * Does lights from the scene impacts this material.
  95459. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  95460. */
  95461. disableLighting: boolean;
  95462. private _useObjectSpaceNormalMap;
  95463. /**
  95464. * Allows using an object space normal map (instead of tangent space).
  95465. */
  95466. useObjectSpaceNormalMap: boolean;
  95467. private _useParallax;
  95468. /**
  95469. * Is parallax enabled or not.
  95470. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95471. */
  95472. useParallax: boolean;
  95473. private _useParallaxOcclusion;
  95474. /**
  95475. * Is parallax occlusion enabled or not.
  95476. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  95477. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95478. */
  95479. useParallaxOcclusion: boolean;
  95480. /**
  95481. * 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.
  95482. */
  95483. parallaxScaleBias: number;
  95484. private _roughness;
  95485. /**
  95486. * Helps to define how blurry the reflections should appears in the material.
  95487. */
  95488. roughness: number;
  95489. /**
  95490. * In case of refraction, define the value of the indice of refraction.
  95491. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95492. */
  95493. indexOfRefraction: number;
  95494. /**
  95495. * Invert the refraction texture alongside the y axis.
  95496. * It can be useful with procedural textures or probe for instance.
  95497. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95498. */
  95499. invertRefractionY: boolean;
  95500. /**
  95501. * Defines the alpha limits in alpha test mode.
  95502. */
  95503. alphaCutOff: number;
  95504. private _useLightmapAsShadowmap;
  95505. /**
  95506. * In case of light mapping, define whether the map contains light or shadow informations.
  95507. */
  95508. useLightmapAsShadowmap: boolean;
  95509. private _diffuseFresnelParameters;
  95510. /**
  95511. * Define the diffuse fresnel parameters of the material.
  95512. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95513. */
  95514. diffuseFresnelParameters: FresnelParameters;
  95515. private _opacityFresnelParameters;
  95516. /**
  95517. * Define the opacity fresnel parameters of the material.
  95518. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95519. */
  95520. opacityFresnelParameters: FresnelParameters;
  95521. private _reflectionFresnelParameters;
  95522. /**
  95523. * Define the reflection fresnel parameters of the material.
  95524. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95525. */
  95526. reflectionFresnelParameters: FresnelParameters;
  95527. private _refractionFresnelParameters;
  95528. /**
  95529. * Define the refraction fresnel parameters of the material.
  95530. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95531. */
  95532. refractionFresnelParameters: FresnelParameters;
  95533. private _emissiveFresnelParameters;
  95534. /**
  95535. * Define the emissive fresnel parameters of the material.
  95536. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95537. */
  95538. emissiveFresnelParameters: FresnelParameters;
  95539. private _useReflectionFresnelFromSpecular;
  95540. /**
  95541. * If true automatically deducts the fresnels values from the material specularity.
  95542. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95543. */
  95544. useReflectionFresnelFromSpecular: boolean;
  95545. private _useGlossinessFromSpecularMapAlpha;
  95546. /**
  95547. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  95548. */
  95549. useGlossinessFromSpecularMapAlpha: boolean;
  95550. private _maxSimultaneousLights;
  95551. /**
  95552. * Defines the maximum number of lights that can be used in the material
  95553. */
  95554. maxSimultaneousLights: number;
  95555. private _invertNormalMapX;
  95556. /**
  95557. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  95558. */
  95559. invertNormalMapX: boolean;
  95560. private _invertNormalMapY;
  95561. /**
  95562. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  95563. */
  95564. invertNormalMapY: boolean;
  95565. private _twoSidedLighting;
  95566. /**
  95567. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  95568. */
  95569. twoSidedLighting: boolean;
  95570. /**
  95571. * Default configuration related to image processing available in the standard Material.
  95572. */
  95573. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95574. /**
  95575. * Gets the image processing configuration used either in this material.
  95576. */
  95577. /**
  95578. * Sets the Default image processing configuration used either in the this material.
  95579. *
  95580. * If sets to null, the scene one is in use.
  95581. */
  95582. imageProcessingConfiguration: ImageProcessingConfiguration;
  95583. /**
  95584. * Keep track of the image processing observer to allow dispose and replace.
  95585. */
  95586. private _imageProcessingObserver;
  95587. /**
  95588. * Attaches a new image processing configuration to the Standard Material.
  95589. * @param configuration
  95590. */
  95591. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  95592. /**
  95593. * Gets wether the color curves effect is enabled.
  95594. */
  95595. /**
  95596. * Sets wether the color curves effect is enabled.
  95597. */
  95598. cameraColorCurvesEnabled: boolean;
  95599. /**
  95600. * Gets wether the color grading effect is enabled.
  95601. */
  95602. /**
  95603. * Gets wether the color grading effect is enabled.
  95604. */
  95605. cameraColorGradingEnabled: boolean;
  95606. /**
  95607. * Gets wether tonemapping is enabled or not.
  95608. */
  95609. /**
  95610. * Sets wether tonemapping is enabled or not
  95611. */
  95612. cameraToneMappingEnabled: boolean;
  95613. /**
  95614. * The camera exposure used on this material.
  95615. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95616. * This corresponds to a photographic exposure.
  95617. */
  95618. /**
  95619. * The camera exposure used on this material.
  95620. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95621. * This corresponds to a photographic exposure.
  95622. */
  95623. cameraExposure: number;
  95624. /**
  95625. * Gets The camera contrast used on this material.
  95626. */
  95627. /**
  95628. * Sets The camera contrast used on this material.
  95629. */
  95630. cameraContrast: number;
  95631. /**
  95632. * Gets the Color Grading 2D Lookup Texture.
  95633. */
  95634. /**
  95635. * Sets the Color Grading 2D Lookup Texture.
  95636. */
  95637. cameraColorGradingTexture: Nullable<BaseTexture>;
  95638. /**
  95639. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95640. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95641. * 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;
  95642. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95643. */
  95644. /**
  95645. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95646. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95647. * 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;
  95648. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95649. */
  95650. cameraColorCurves: Nullable<ColorCurves>;
  95651. /**
  95652. * Custom callback helping to override the default shader used in the material.
  95653. */
  95654. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  95655. protected _renderTargets: SmartArray<RenderTargetTexture>;
  95656. protected _worldViewProjectionMatrix: Matrix;
  95657. protected _globalAmbientColor: Color3;
  95658. protected _useLogarithmicDepth: boolean;
  95659. /**
  95660. * Instantiates a new standard material.
  95661. * This is the default material used in Babylon. It is the best trade off between quality
  95662. * and performances.
  95663. * @see http://doc.babylonjs.com/babylon101/materials
  95664. * @param name Define the name of the material in the scene
  95665. * @param scene Define the scene the material belong to
  95666. */
  95667. constructor(name: string, scene: Scene);
  95668. /**
  95669. * Gets a boolean indicating that current material needs to register RTT
  95670. */
  95671. readonly hasRenderTargetTextures: boolean;
  95672. /**
  95673. * Gets the current class name of the material e.g. "StandardMaterial"
  95674. * Mainly use in serialization.
  95675. * @returns the class name
  95676. */
  95677. getClassName(): string;
  95678. /**
  95679. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  95680. * You can try switching to logarithmic depth.
  95681. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  95682. */
  95683. useLogarithmicDepth: boolean;
  95684. /**
  95685. * Specifies if the material will require alpha blending
  95686. * @returns a boolean specifying if alpha blending is needed
  95687. */
  95688. needAlphaBlending(): boolean;
  95689. /**
  95690. * Specifies if this material should be rendered in alpha test mode
  95691. * @returns a boolean specifying if an alpha test is needed.
  95692. */
  95693. needAlphaTesting(): boolean;
  95694. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  95695. /**
  95696. * Get the texture used for alpha test purpose.
  95697. * @returns the diffuse texture in case of the standard material.
  95698. */
  95699. getAlphaTestTexture(): Nullable<BaseTexture>;
  95700. /**
  95701. * Get if the submesh is ready to be used and all its information available.
  95702. * Child classes can use it to update shaders
  95703. * @param mesh defines the mesh to check
  95704. * @param subMesh defines which submesh to check
  95705. * @param useInstances specifies that instances should be used
  95706. * @returns a boolean indicating that the submesh is ready or not
  95707. */
  95708. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95709. /**
  95710. * Builds the material UBO layouts.
  95711. * Used internally during the effect preparation.
  95712. */
  95713. buildUniformLayout(): void;
  95714. /**
  95715. * Unbinds the material from the mesh
  95716. */
  95717. unbind(): void;
  95718. /**
  95719. * Binds the submesh to this material by preparing the effect and shader to draw
  95720. * @param world defines the world transformation matrix
  95721. * @param mesh defines the mesh containing the submesh
  95722. * @param subMesh defines the submesh to bind the material to
  95723. */
  95724. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95725. /**
  95726. * Get the list of animatables in the material.
  95727. * @returns the list of animatables object used in the material
  95728. */
  95729. getAnimatables(): IAnimatable[];
  95730. /**
  95731. * Gets the active textures from the material
  95732. * @returns an array of textures
  95733. */
  95734. getActiveTextures(): BaseTexture[];
  95735. /**
  95736. * Specifies if the material uses a texture
  95737. * @param texture defines the texture to check against the material
  95738. * @returns a boolean specifying if the material uses the texture
  95739. */
  95740. hasTexture(texture: BaseTexture): boolean;
  95741. /**
  95742. * Disposes the material
  95743. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95744. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95745. */
  95746. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  95747. /**
  95748. * Makes a duplicate of the material, and gives it a new name
  95749. * @param name defines the new name for the duplicated material
  95750. * @returns the cloned material
  95751. */
  95752. clone(name: string): StandardMaterial;
  95753. /**
  95754. * Serializes this material in a JSON representation
  95755. * @returns the serialized material object
  95756. */
  95757. serialize(): any;
  95758. /**
  95759. * Creates a standard material from parsed material data
  95760. * @param source defines the JSON representation of the material
  95761. * @param scene defines the hosting scene
  95762. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95763. * @returns a new standard material
  95764. */
  95765. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  95766. /**
  95767. * Are diffuse textures enabled in the application.
  95768. */
  95769. static DiffuseTextureEnabled: boolean;
  95770. /**
  95771. * Are ambient textures enabled in the application.
  95772. */
  95773. static AmbientTextureEnabled: boolean;
  95774. /**
  95775. * Are opacity textures enabled in the application.
  95776. */
  95777. static OpacityTextureEnabled: boolean;
  95778. /**
  95779. * Are reflection textures enabled in the application.
  95780. */
  95781. static ReflectionTextureEnabled: boolean;
  95782. /**
  95783. * Are emissive textures enabled in the application.
  95784. */
  95785. static EmissiveTextureEnabled: boolean;
  95786. /**
  95787. * Are specular textures enabled in the application.
  95788. */
  95789. static SpecularTextureEnabled: boolean;
  95790. /**
  95791. * Are bump textures enabled in the application.
  95792. */
  95793. static BumpTextureEnabled: boolean;
  95794. /**
  95795. * Are lightmap textures enabled in the application.
  95796. */
  95797. static LightmapTextureEnabled: boolean;
  95798. /**
  95799. * Are refraction textures enabled in the application.
  95800. */
  95801. static RefractionTextureEnabled: boolean;
  95802. /**
  95803. * Are color grading textures enabled in the application.
  95804. */
  95805. static ColorGradingTextureEnabled: boolean;
  95806. /**
  95807. * Are fresnels enabled in the application.
  95808. */
  95809. static FresnelEnabled: boolean;
  95810. }
  95811. }
  95812. declare module BABYLON {
  95813. /**
  95814. * A class extending Texture allowing drawing on a texture
  95815. * @see http://doc.babylonjs.com/how_to/dynamictexture
  95816. */
  95817. export class DynamicTexture extends Texture {
  95818. private _generateMipMaps;
  95819. private _canvas;
  95820. private _context;
  95821. private _engine;
  95822. /**
  95823. * Creates a DynamicTexture
  95824. * @param name defines the name of the texture
  95825. * @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
  95826. * @param scene defines the scene where you want the texture
  95827. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  95828. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  95829. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  95830. */
  95831. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  95832. /**
  95833. * Get the current class name of the texture useful for serialization or dynamic coding.
  95834. * @returns "DynamicTexture"
  95835. */
  95836. getClassName(): string;
  95837. /**
  95838. * Gets the current state of canRescale
  95839. */
  95840. readonly canRescale: boolean;
  95841. private _recreate;
  95842. /**
  95843. * Scales the texture
  95844. * @param ratio the scale factor to apply to both width and height
  95845. */
  95846. scale(ratio: number): void;
  95847. /**
  95848. * Resizes the texture
  95849. * @param width the new width
  95850. * @param height the new height
  95851. */
  95852. scaleTo(width: number, height: number): void;
  95853. /**
  95854. * Gets the context of the canvas used by the texture
  95855. * @returns the canvas context of the dynamic texture
  95856. */
  95857. getContext(): CanvasRenderingContext2D;
  95858. /**
  95859. * Clears the texture
  95860. */
  95861. clear(): void;
  95862. /**
  95863. * Updates the texture
  95864. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  95865. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  95866. */
  95867. update(invertY?: boolean, premulAlpha?: boolean): void;
  95868. /**
  95869. * Draws text onto the texture
  95870. * @param text defines the text to be drawn
  95871. * @param x defines the placement of the text from the left
  95872. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  95873. * @param font defines the font to be used with font-style, font-size, font-name
  95874. * @param color defines the color used for the text
  95875. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  95876. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  95877. * @param update defines whether texture is immediately update (default is true)
  95878. */
  95879. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  95880. /**
  95881. * Clones the texture
  95882. * @returns the clone of the texture.
  95883. */
  95884. clone(): DynamicTexture;
  95885. /**
  95886. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  95887. * @returns a serialized dynamic texture object
  95888. */
  95889. serialize(): any;
  95890. /** @hidden */
  95891. _rebuild(): void;
  95892. }
  95893. }
  95894. declare module BABYLON {
  95895. /** @hidden */
  95896. export var imageProcessingPixelShader: {
  95897. name: string;
  95898. shader: string;
  95899. };
  95900. }
  95901. declare module BABYLON {
  95902. /**
  95903. * ImageProcessingPostProcess
  95904. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  95905. */
  95906. export class ImageProcessingPostProcess extends PostProcess {
  95907. /**
  95908. * Default configuration related to image processing available in the PBR Material.
  95909. */
  95910. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95911. /**
  95912. * Gets the image processing configuration used either in this material.
  95913. */
  95914. /**
  95915. * Sets the Default image processing configuration used either in the this material.
  95916. *
  95917. * If sets to null, the scene one is in use.
  95918. */
  95919. imageProcessingConfiguration: ImageProcessingConfiguration;
  95920. /**
  95921. * Keep track of the image processing observer to allow dispose and replace.
  95922. */
  95923. private _imageProcessingObserver;
  95924. /**
  95925. * Attaches a new image processing configuration to the PBR Material.
  95926. * @param configuration
  95927. */
  95928. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  95929. /**
  95930. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  95931. */
  95932. /**
  95933. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  95934. */
  95935. colorCurves: Nullable<ColorCurves>;
  95936. /**
  95937. * Gets wether the color curves effect is enabled.
  95938. */
  95939. /**
  95940. * Sets wether the color curves effect is enabled.
  95941. */
  95942. colorCurvesEnabled: boolean;
  95943. /**
  95944. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  95945. */
  95946. /**
  95947. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  95948. */
  95949. colorGradingTexture: Nullable<BaseTexture>;
  95950. /**
  95951. * Gets wether the color grading effect is enabled.
  95952. */
  95953. /**
  95954. * Gets wether the color grading effect is enabled.
  95955. */
  95956. colorGradingEnabled: boolean;
  95957. /**
  95958. * Gets exposure used in the effect.
  95959. */
  95960. /**
  95961. * Sets exposure used in the effect.
  95962. */
  95963. exposure: number;
  95964. /**
  95965. * Gets wether tonemapping is enabled or not.
  95966. */
  95967. /**
  95968. * Sets wether tonemapping is enabled or not
  95969. */
  95970. toneMappingEnabled: boolean;
  95971. /**
  95972. * Gets the type of tone mapping effect.
  95973. */
  95974. /**
  95975. * Sets the type of tone mapping effect.
  95976. */
  95977. toneMappingType: number;
  95978. /**
  95979. * Gets contrast used in the effect.
  95980. */
  95981. /**
  95982. * Sets contrast used in the effect.
  95983. */
  95984. contrast: number;
  95985. /**
  95986. * Gets Vignette stretch size.
  95987. */
  95988. /**
  95989. * Sets Vignette stretch size.
  95990. */
  95991. vignetteStretch: number;
  95992. /**
  95993. * Gets Vignette centre X Offset.
  95994. */
  95995. /**
  95996. * Sets Vignette centre X Offset.
  95997. */
  95998. vignetteCentreX: number;
  95999. /**
  96000. * Gets Vignette centre Y Offset.
  96001. */
  96002. /**
  96003. * Sets Vignette centre Y Offset.
  96004. */
  96005. vignetteCentreY: number;
  96006. /**
  96007. * Gets Vignette weight or intensity of the vignette effect.
  96008. */
  96009. /**
  96010. * Sets Vignette weight or intensity of the vignette effect.
  96011. */
  96012. vignetteWeight: number;
  96013. /**
  96014. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  96015. * if vignetteEnabled is set to true.
  96016. */
  96017. /**
  96018. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  96019. * if vignetteEnabled is set to true.
  96020. */
  96021. vignetteColor: Color4;
  96022. /**
  96023. * Gets Camera field of view used by the Vignette effect.
  96024. */
  96025. /**
  96026. * Sets Camera field of view used by the Vignette effect.
  96027. */
  96028. vignetteCameraFov: number;
  96029. /**
  96030. * Gets the vignette blend mode allowing different kind of effect.
  96031. */
  96032. /**
  96033. * Sets the vignette blend mode allowing different kind of effect.
  96034. */
  96035. vignetteBlendMode: number;
  96036. /**
  96037. * Gets wether the vignette effect is enabled.
  96038. */
  96039. /**
  96040. * Sets wether the vignette effect is enabled.
  96041. */
  96042. vignetteEnabled: boolean;
  96043. private _fromLinearSpace;
  96044. /**
  96045. * Gets wether the input of the processing is in Gamma or Linear Space.
  96046. */
  96047. /**
  96048. * Sets wether the input of the processing is in Gamma or Linear Space.
  96049. */
  96050. fromLinearSpace: boolean;
  96051. /**
  96052. * Defines cache preventing GC.
  96053. */
  96054. private _defines;
  96055. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  96056. /**
  96057. * "ImageProcessingPostProcess"
  96058. * @returns "ImageProcessingPostProcess"
  96059. */
  96060. getClassName(): string;
  96061. protected _updateParameters(): void;
  96062. dispose(camera?: Camera): void;
  96063. }
  96064. }
  96065. declare module BABYLON {
  96066. /**
  96067. * Class containing static functions to help procedurally build meshes
  96068. */
  96069. export class GroundBuilder {
  96070. /**
  96071. * Creates a ground mesh
  96072. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  96073. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  96074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96075. * @param name defines the name of the mesh
  96076. * @param options defines the options used to create the mesh
  96077. * @param scene defines the hosting scene
  96078. * @returns the ground mesh
  96079. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  96080. */
  96081. static CreateGround(name: string, options: {
  96082. width?: number;
  96083. height?: number;
  96084. subdivisions?: number;
  96085. subdivisionsX?: number;
  96086. subdivisionsY?: number;
  96087. updatable?: boolean;
  96088. }, scene: any): Mesh;
  96089. /**
  96090. * Creates a tiled ground mesh
  96091. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  96092. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  96093. * * 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
  96094. * * 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
  96095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96096. * @param name defines the name of the mesh
  96097. * @param options defines the options used to create the mesh
  96098. * @param scene defines the hosting scene
  96099. * @returns the tiled ground mesh
  96100. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  96101. */
  96102. static CreateTiledGround(name: string, options: {
  96103. xmin: number;
  96104. zmin: number;
  96105. xmax: number;
  96106. zmax: number;
  96107. subdivisions?: {
  96108. w: number;
  96109. h: number;
  96110. };
  96111. precision?: {
  96112. w: number;
  96113. h: number;
  96114. };
  96115. updatable?: boolean;
  96116. }, scene: Scene): Mesh;
  96117. /**
  96118. * Creates a ground mesh from a height map
  96119. * * The parameter `url` sets the URL of the height map image resource.
  96120. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  96121. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  96122. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  96123. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  96124. * * 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.
  96125. * * 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).
  96126. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  96127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96128. * @param name defines the name of the mesh
  96129. * @param url defines the url to the height map
  96130. * @param options defines the options used to create the mesh
  96131. * @param scene defines the hosting scene
  96132. * @returns the ground mesh
  96133. * @see https://doc.babylonjs.com/babylon101/height_map
  96134. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  96135. */
  96136. static CreateGroundFromHeightMap(name: string, url: string, options: {
  96137. width?: number;
  96138. height?: number;
  96139. subdivisions?: number;
  96140. minHeight?: number;
  96141. maxHeight?: number;
  96142. colorFilter?: Color3;
  96143. alphaFilter?: number;
  96144. updatable?: boolean;
  96145. onReady?: (mesh: GroundMesh) => void;
  96146. }, scene: Scene): GroundMesh;
  96147. }
  96148. }
  96149. declare module BABYLON {
  96150. /**
  96151. * Class containing static functions to help procedurally build meshes
  96152. */
  96153. export class TorusBuilder {
  96154. /**
  96155. * Creates a torus mesh
  96156. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  96157. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  96158. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  96159. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96160. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96162. * @param name defines the name of the mesh
  96163. * @param options defines the options used to create the mesh
  96164. * @param scene defines the hosting scene
  96165. * @returns the torus mesh
  96166. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  96167. */
  96168. static CreateTorus(name: string, options: {
  96169. diameter?: number;
  96170. thickness?: number;
  96171. tessellation?: number;
  96172. updatable?: boolean;
  96173. sideOrientation?: number;
  96174. frontUVs?: Vector4;
  96175. backUVs?: Vector4;
  96176. }, scene: any): Mesh;
  96177. }
  96178. }
  96179. declare module BABYLON {
  96180. /**
  96181. * Class containing static functions to help procedurally build meshes
  96182. */
  96183. export class CylinderBuilder {
  96184. /**
  96185. * Creates a cylinder or a cone mesh
  96186. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  96187. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  96188. * * 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.
  96189. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  96190. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  96191. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  96192. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  96193. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  96194. * * 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).
  96195. * * 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
  96196. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  96197. * * 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
  96198. * * 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.
  96199. * * If `enclose` is false, a ring surface is one element.
  96200. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  96201. * * 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
  96202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96203. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96205. * @param name defines the name of the mesh
  96206. * @param options defines the options used to create the mesh
  96207. * @param scene defines the hosting scene
  96208. * @returns the cylinder mesh
  96209. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  96210. */
  96211. static CreateCylinder(name: string, options: {
  96212. height?: number;
  96213. diameterTop?: number;
  96214. diameterBottom?: number;
  96215. diameter?: number;
  96216. tessellation?: number;
  96217. subdivisions?: number;
  96218. arc?: number;
  96219. faceColors?: Color4[];
  96220. faceUV?: Vector4[];
  96221. updatable?: boolean;
  96222. hasRings?: boolean;
  96223. enclose?: boolean;
  96224. sideOrientation?: number;
  96225. frontUVs?: Vector4;
  96226. backUVs?: Vector4;
  96227. }, scene: any): Mesh;
  96228. }
  96229. }
  96230. declare module BABYLON {
  96231. /**
  96232. * Manager for handling gamepads
  96233. */
  96234. export class GamepadManager {
  96235. private _scene?;
  96236. private _babylonGamepads;
  96237. private _oneGamepadConnected;
  96238. /** @hidden */
  96239. _isMonitoring: boolean;
  96240. private _gamepadEventSupported;
  96241. private _gamepadSupport;
  96242. /**
  96243. * observable to be triggered when the gamepad controller has been connected
  96244. */
  96245. onGamepadConnectedObservable: Observable<Gamepad>;
  96246. /**
  96247. * observable to be triggered when the gamepad controller has been disconnected
  96248. */
  96249. onGamepadDisconnectedObservable: Observable<Gamepad>;
  96250. private _onGamepadConnectedEvent;
  96251. private _onGamepadDisconnectedEvent;
  96252. /**
  96253. * Initializes the gamepad manager
  96254. * @param _scene BabylonJS scene
  96255. */
  96256. constructor(_scene?: Scene | undefined);
  96257. /**
  96258. * The gamepads in the game pad manager
  96259. */
  96260. readonly gamepads: Gamepad[];
  96261. /**
  96262. * Get the gamepad controllers based on type
  96263. * @param type The type of gamepad controller
  96264. * @returns Nullable gamepad
  96265. */
  96266. getGamepadByType(type?: number): Nullable<Gamepad>;
  96267. /**
  96268. * Disposes the gamepad manager
  96269. */
  96270. dispose(): void;
  96271. private _addNewGamepad;
  96272. private _startMonitoringGamepads;
  96273. private _stopMonitoringGamepads;
  96274. /** @hidden */
  96275. _checkGamepadsStatus(): void;
  96276. private _updateGamepadObjects;
  96277. }
  96278. }
  96279. declare module BABYLON {
  96280. interface Scene {
  96281. /** @hidden */
  96282. _gamepadManager: Nullable<GamepadManager>;
  96283. /**
  96284. * Gets the gamepad manager associated with the scene
  96285. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  96286. */
  96287. gamepadManager: GamepadManager;
  96288. }
  96289. /**
  96290. * Interface representing a free camera inputs manager
  96291. */
  96292. interface FreeCameraInputsManager {
  96293. /**
  96294. * Adds gamepad input support to the FreeCameraInputsManager.
  96295. * @returns the FreeCameraInputsManager
  96296. */
  96297. addGamepad(): FreeCameraInputsManager;
  96298. }
  96299. /**
  96300. * Interface representing an arc rotate camera inputs manager
  96301. */
  96302. interface ArcRotateCameraInputsManager {
  96303. /**
  96304. * Adds gamepad input support to the ArcRotateCamera InputManager.
  96305. * @returns the camera inputs manager
  96306. */
  96307. addGamepad(): ArcRotateCameraInputsManager;
  96308. }
  96309. /**
  96310. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  96311. */
  96312. export class GamepadSystemSceneComponent implements ISceneComponent {
  96313. /**
  96314. * The component name helpfull to identify the component in the list of scene components.
  96315. */
  96316. readonly name: string;
  96317. /**
  96318. * The scene the component belongs to.
  96319. */
  96320. scene: Scene;
  96321. /**
  96322. * Creates a new instance of the component for the given scene
  96323. * @param scene Defines the scene to register the component in
  96324. */
  96325. constructor(scene: Scene);
  96326. /**
  96327. * Registers the component in a given scene
  96328. */
  96329. register(): void;
  96330. /**
  96331. * Rebuilds the elements related to this component in case of
  96332. * context lost for instance.
  96333. */
  96334. rebuild(): void;
  96335. /**
  96336. * Disposes the component and the associated ressources
  96337. */
  96338. dispose(): void;
  96339. private _beforeCameraUpdate;
  96340. }
  96341. }
  96342. declare module BABYLON {
  96343. /**
  96344. * Options to modify the vr teleportation behavior.
  96345. */
  96346. export interface VRTeleportationOptions {
  96347. /**
  96348. * The name of the mesh which should be used as the teleportation floor. (default: null)
  96349. */
  96350. floorMeshName?: string;
  96351. /**
  96352. * A list of meshes to be used as the teleportation floor. (default: empty)
  96353. */
  96354. floorMeshes?: Mesh[];
  96355. }
  96356. /**
  96357. * Options to modify the vr experience helper's behavior.
  96358. */
  96359. export interface VRExperienceHelperOptions extends WebVROptions {
  96360. /**
  96361. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  96362. */
  96363. createDeviceOrientationCamera?: boolean;
  96364. /**
  96365. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  96366. */
  96367. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  96368. /**
  96369. * Uses the main button on the controller to toggle the laser casted. (default: true)
  96370. */
  96371. laserToggle?: boolean;
  96372. /**
  96373. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  96374. */
  96375. floorMeshes?: Mesh[];
  96376. /**
  96377. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  96378. */
  96379. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  96380. }
  96381. /**
  96382. * Event containing information after VR has been entered
  96383. */
  96384. export class OnAfterEnteringVRObservableEvent {
  96385. /**
  96386. * If entering vr was successful
  96387. */
  96388. success: boolean;
  96389. }
  96390. /**
  96391. * Helps to quickly add VR support to an existing scene.
  96392. * See http://doc.babylonjs.com/how_to/webvr_helper
  96393. */
  96394. export class VRExperienceHelper {
  96395. /** Options to modify the vr experience helper's behavior. */
  96396. webVROptions: VRExperienceHelperOptions;
  96397. private _scene;
  96398. private _position;
  96399. private _btnVR;
  96400. private _btnVRDisplayed;
  96401. private _webVRsupported;
  96402. private _webVRready;
  96403. private _webVRrequesting;
  96404. private _webVRpresenting;
  96405. private _hasEnteredVR;
  96406. private _fullscreenVRpresenting;
  96407. private _canvas;
  96408. private _webVRCamera;
  96409. private _vrDeviceOrientationCamera;
  96410. private _deviceOrientationCamera;
  96411. private _existingCamera;
  96412. private _onKeyDown;
  96413. private _onVrDisplayPresentChange;
  96414. private _onVRDisplayChanged;
  96415. private _onVRRequestPresentStart;
  96416. private _onVRRequestPresentComplete;
  96417. /**
  96418. * Observable raised right before entering VR.
  96419. */
  96420. onEnteringVRObservable: Observable<VRExperienceHelper>;
  96421. /**
  96422. * Observable raised when entering VR has completed.
  96423. */
  96424. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  96425. /**
  96426. * Observable raised when exiting VR.
  96427. */
  96428. onExitingVRObservable: Observable<VRExperienceHelper>;
  96429. /**
  96430. * Observable raised when controller mesh is loaded.
  96431. */
  96432. onControllerMeshLoadedObservable: Observable<WebVRController>;
  96433. /** Return this.onEnteringVRObservable
  96434. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  96435. */
  96436. readonly onEnteringVR: Observable<VRExperienceHelper>;
  96437. /** Return this.onExitingVRObservable
  96438. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  96439. */
  96440. readonly onExitingVR: Observable<VRExperienceHelper>;
  96441. /** Return this.onControllerMeshLoadedObservable
  96442. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  96443. */
  96444. readonly onControllerMeshLoaded: Observable<WebVRController>;
  96445. private _rayLength;
  96446. private _useCustomVRButton;
  96447. private _teleportationRequested;
  96448. private _teleportActive;
  96449. private _floorMeshName;
  96450. private _floorMeshesCollection;
  96451. private _rotationAllowed;
  96452. private _teleportBackwardsVector;
  96453. private _teleportationTarget;
  96454. private _isDefaultTeleportationTarget;
  96455. private _postProcessMove;
  96456. private _teleportationFillColor;
  96457. private _teleportationBorderColor;
  96458. private _rotationAngle;
  96459. private _haloCenter;
  96460. private _cameraGazer;
  96461. private _padSensibilityUp;
  96462. private _padSensibilityDown;
  96463. private _leftController;
  96464. private _rightController;
  96465. /**
  96466. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  96467. */
  96468. onNewMeshSelected: Observable<AbstractMesh>;
  96469. /**
  96470. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  96471. */
  96472. onNewMeshPicked: Observable<PickingInfo>;
  96473. private _circleEase;
  96474. /**
  96475. * Observable raised before camera teleportation
  96476. */
  96477. onBeforeCameraTeleport: Observable<Vector3>;
  96478. /**
  96479. * Observable raised after camera teleportation
  96480. */
  96481. onAfterCameraTeleport: Observable<Vector3>;
  96482. /**
  96483. * Observable raised when current selected mesh gets unselected
  96484. */
  96485. onSelectedMeshUnselected: Observable<AbstractMesh>;
  96486. private _raySelectionPredicate;
  96487. /**
  96488. * To be optionaly changed by user to define custom ray selection
  96489. */
  96490. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  96491. /**
  96492. * To be optionaly changed by user to define custom selection logic (after ray selection)
  96493. */
  96494. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  96495. /**
  96496. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  96497. */
  96498. teleportationEnabled: boolean;
  96499. private _defaultHeight;
  96500. private _teleportationInitialized;
  96501. private _interactionsEnabled;
  96502. private _interactionsRequested;
  96503. private _displayGaze;
  96504. private _displayLaserPointer;
  96505. /**
  96506. * The mesh used to display where the user is going to teleport.
  96507. */
  96508. /**
  96509. * Sets the mesh to be used to display where the user is going to teleport.
  96510. */
  96511. teleportationTarget: Mesh;
  96512. /**
  96513. * 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
  96514. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  96515. * See http://doc.babylonjs.com/resources/baking_transformations
  96516. */
  96517. gazeTrackerMesh: Mesh;
  96518. /**
  96519. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  96520. */
  96521. updateGazeTrackerScale: boolean;
  96522. /**
  96523. * If the gaze trackers color should be updated when selecting meshes
  96524. */
  96525. updateGazeTrackerColor: boolean;
  96526. /**
  96527. * The gaze tracking mesh corresponding to the left controller
  96528. */
  96529. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  96530. /**
  96531. * The gaze tracking mesh corresponding to the right controller
  96532. */
  96533. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  96534. /**
  96535. * If the ray of the gaze should be displayed.
  96536. */
  96537. /**
  96538. * Sets if the ray of the gaze should be displayed.
  96539. */
  96540. displayGaze: boolean;
  96541. /**
  96542. * If the ray of the LaserPointer should be displayed.
  96543. */
  96544. /**
  96545. * Sets if the ray of the LaserPointer should be displayed.
  96546. */
  96547. displayLaserPointer: boolean;
  96548. /**
  96549. * The deviceOrientationCamera used as the camera when not in VR.
  96550. */
  96551. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  96552. /**
  96553. * Based on the current WebVR support, returns the current VR camera used.
  96554. */
  96555. readonly currentVRCamera: Nullable<Camera>;
  96556. /**
  96557. * The webVRCamera which is used when in VR.
  96558. */
  96559. readonly webVRCamera: WebVRFreeCamera;
  96560. /**
  96561. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  96562. */
  96563. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  96564. private readonly _teleportationRequestInitiated;
  96565. /**
  96566. * Defines wether or not Pointer lock should be requested when switching to
  96567. * full screen.
  96568. */
  96569. requestPointerLockOnFullScreen: boolean;
  96570. /**
  96571. * Instantiates a VRExperienceHelper.
  96572. * Helps to quickly add VR support to an existing scene.
  96573. * @param scene The scene the VRExperienceHelper belongs to.
  96574. * @param webVROptions Options to modify the vr experience helper's behavior.
  96575. */
  96576. constructor(scene: Scene,
  96577. /** Options to modify the vr experience helper's behavior. */
  96578. webVROptions?: VRExperienceHelperOptions);
  96579. private _onDefaultMeshLoaded;
  96580. private _onResize;
  96581. private _onFullscreenChange;
  96582. /**
  96583. * Gets a value indicating if we are currently in VR mode.
  96584. */
  96585. readonly isInVRMode: boolean;
  96586. private onVrDisplayPresentChange;
  96587. private onVRDisplayChanged;
  96588. private moveButtonToBottomRight;
  96589. private displayVRButton;
  96590. private updateButtonVisibility;
  96591. private _cachedAngularSensibility;
  96592. /**
  96593. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  96594. * Otherwise, will use the fullscreen API.
  96595. */
  96596. enterVR(): void;
  96597. /**
  96598. * Attempt to exit VR, or fullscreen.
  96599. */
  96600. exitVR(): void;
  96601. /**
  96602. * The position of the vr experience helper.
  96603. */
  96604. /**
  96605. * Sets the position of the vr experience helper.
  96606. */
  96607. position: Vector3;
  96608. /**
  96609. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  96610. */
  96611. enableInteractions(): void;
  96612. private readonly _noControllerIsActive;
  96613. private beforeRender;
  96614. private _isTeleportationFloor;
  96615. /**
  96616. * Adds a floor mesh to be used for teleportation.
  96617. * @param floorMesh the mesh to be used for teleportation.
  96618. */
  96619. addFloorMesh(floorMesh: Mesh): void;
  96620. /**
  96621. * Removes a floor mesh from being used for teleportation.
  96622. * @param floorMesh the mesh to be removed.
  96623. */
  96624. removeFloorMesh(floorMesh: Mesh): void;
  96625. /**
  96626. * Enables interactions and teleportation using the VR controllers and gaze.
  96627. * @param vrTeleportationOptions options to modify teleportation behavior.
  96628. */
  96629. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  96630. private _onNewGamepadConnected;
  96631. private _tryEnableInteractionOnController;
  96632. private _onNewGamepadDisconnected;
  96633. private _enableInteractionOnController;
  96634. private _checkTeleportWithRay;
  96635. private _checkRotate;
  96636. private _checkTeleportBackwards;
  96637. private _enableTeleportationOnController;
  96638. private _createTeleportationCircles;
  96639. private _displayTeleportationTarget;
  96640. private _hideTeleportationTarget;
  96641. private _rotateCamera;
  96642. private _moveTeleportationSelectorTo;
  96643. private _workingVector;
  96644. private _workingQuaternion;
  96645. private _workingMatrix;
  96646. /**
  96647. * Teleports the users feet to the desired location
  96648. * @param location The location where the user's feet should be placed
  96649. */
  96650. teleportCamera(location: Vector3): void;
  96651. private _convertNormalToDirectionOfRay;
  96652. private _castRayAndSelectObject;
  96653. private _notifySelectedMeshUnselected;
  96654. /**
  96655. * Sets the color of the laser ray from the vr controllers.
  96656. * @param color new color for the ray.
  96657. */
  96658. changeLaserColor(color: Color3): void;
  96659. /**
  96660. * Sets the color of the ray from the vr headsets gaze.
  96661. * @param color new color for the ray.
  96662. */
  96663. changeGazeColor(color: Color3): void;
  96664. /**
  96665. * Exits VR and disposes of the vr experience helper
  96666. */
  96667. dispose(): void;
  96668. /**
  96669. * Gets the name of the VRExperienceHelper class
  96670. * @returns "VRExperienceHelper"
  96671. */
  96672. getClassName(): string;
  96673. }
  96674. }
  96675. declare module BABYLON {
  96676. /**
  96677. * Manages an XRSession
  96678. * @see https://doc.babylonjs.com/how_to/webxr
  96679. */
  96680. export class WebXRSessionManager implements IDisposable {
  96681. private scene;
  96682. /**
  96683. * Fires every time a new xrFrame arrives which can be used to update the camera
  96684. */
  96685. onXRFrameObservable: Observable<any>;
  96686. /**
  96687. * Fires when the xr session is ended either by the device or manually done
  96688. */
  96689. onXRSessionEnded: Observable<any>;
  96690. /** @hidden */
  96691. _xrSession: XRSession;
  96692. /** @hidden */
  96693. _frameOfReference: XRFrameOfReference;
  96694. /** @hidden */
  96695. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  96696. /** @hidden */
  96697. _currentXRFrame: Nullable<XRFrame>;
  96698. private _xrNavigator;
  96699. private _xrDevice;
  96700. private _tmpMatrix;
  96701. /**
  96702. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  96703. * @param scene The scene which the session should be created for
  96704. */
  96705. constructor(scene: Scene);
  96706. /**
  96707. * Initializes the manager
  96708. * After initialization enterXR can be called to start an XR session
  96709. * @returns Promise which resolves after it is initialized
  96710. */
  96711. initializeAsync(): Promise<void>;
  96712. /**
  96713. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  96714. * @param sessionCreationOptions xr options to create the session with
  96715. * @param frameOfReferenceType option to configure how the xr pose is expressed
  96716. * @returns Promise which resolves after it enters XR
  96717. */
  96718. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  96719. /**
  96720. * Stops the xrSession and restores the renderloop
  96721. * @returns Promise which resolves after it exits XR
  96722. */
  96723. exitXRAsync(): Promise<void>;
  96724. /**
  96725. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  96726. * @param ray ray to cast into the environment
  96727. * @returns Promise which resolves with a collision point in the environment if it exists
  96728. */
  96729. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  96730. /**
  96731. * Checks if a session would be supported for the creation options specified
  96732. * @param options creation options to check if they are supported
  96733. * @returns true if supported
  96734. */
  96735. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  96736. /**
  96737. * @hidden
  96738. * Converts the render layer of xrSession to a render target
  96739. * @param session session to create render target for
  96740. * @param scene scene the new render target should be created for
  96741. */
  96742. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  96743. /**
  96744. * Disposes of the session manager
  96745. */
  96746. dispose(): void;
  96747. }
  96748. }
  96749. declare module BABYLON {
  96750. /**
  96751. * WebXR Camera which holds the views for the xrSession
  96752. * @see https://doc.babylonjs.com/how_to/webxr
  96753. */
  96754. export class WebXRCamera extends FreeCamera {
  96755. private static _TmpMatrix;
  96756. /**
  96757. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  96758. * @param name the name of the camera
  96759. * @param scene the scene to add the camera to
  96760. */
  96761. constructor(name: string, scene: Scene);
  96762. private _updateNumberOfRigCameras;
  96763. /** @hidden */
  96764. _updateForDualEyeDebugging(pupilDistance?: number): void;
  96765. /**
  96766. * Updates the cameras position from the current pose information of the XR session
  96767. * @param xrSessionManager the session containing pose information
  96768. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  96769. */
  96770. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  96771. }
  96772. }
  96773. declare module BABYLON {
  96774. /**
  96775. * States of the webXR experience
  96776. */
  96777. export enum WebXRState {
  96778. /**
  96779. * Transitioning to being in XR mode
  96780. */
  96781. ENTERING_XR = 0,
  96782. /**
  96783. * Transitioning to non XR mode
  96784. */
  96785. EXITING_XR = 1,
  96786. /**
  96787. * In XR mode and presenting
  96788. */
  96789. IN_XR = 2,
  96790. /**
  96791. * Not entered XR mode
  96792. */
  96793. NOT_IN_XR = 3
  96794. }
  96795. /**
  96796. * Helper class used to enable XR
  96797. * @see https://doc.babylonjs.com/how_to/webxr
  96798. */
  96799. export class WebXRExperienceHelper implements IDisposable {
  96800. private scene;
  96801. /**
  96802. * 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
  96803. */
  96804. container: AbstractMesh;
  96805. /**
  96806. * Camera used to render xr content
  96807. */
  96808. camera: WebXRCamera;
  96809. /**
  96810. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  96811. */
  96812. state: WebXRState;
  96813. private _setState;
  96814. private static _TmpVector;
  96815. /**
  96816. * Fires when the state of the experience helper has changed
  96817. */
  96818. onStateChangedObservable: Observable<WebXRState>;
  96819. /** @hidden */
  96820. _sessionManager: WebXRSessionManager;
  96821. private _nonVRCamera;
  96822. private _originalSceneAutoClear;
  96823. private _supported;
  96824. /**
  96825. * Creates the experience helper
  96826. * @param scene the scene to attach the experience helper to
  96827. * @returns a promise for the experience helper
  96828. */
  96829. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  96830. /**
  96831. * Creates a WebXRExperienceHelper
  96832. * @param scene The scene the helper should be created in
  96833. */
  96834. private constructor();
  96835. /**
  96836. * Exits XR mode and returns the scene to its original state
  96837. * @returns promise that resolves after xr mode has exited
  96838. */
  96839. exitXRAsync(): Promise<void>;
  96840. /**
  96841. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  96842. * @param sessionCreationOptions options for the XR session
  96843. * @param frameOfReference frame of reference of the XR session
  96844. * @returns promise that resolves after xr mode has entered
  96845. */
  96846. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  96847. /**
  96848. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  96849. * @param ray ray to cast into the environment
  96850. * @returns Promise which resolves with a collision point in the environment if it exists
  96851. */
  96852. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  96853. /**
  96854. * Updates the global position of the camera by moving the camera's container
  96855. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  96856. * @param position The desired global position of the camera
  96857. */
  96858. setPositionOfCameraUsingContainer(position: Vector3): void;
  96859. /**
  96860. * Rotates the xr camera by rotating the camera's container around the camera's position
  96861. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  96862. * @param rotation the desired quaternion rotation to apply to the camera
  96863. */
  96864. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  96865. /**
  96866. * Checks if the creation options are supported by the xr session
  96867. * @param options creation options
  96868. * @returns true if supported
  96869. */
  96870. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  96871. /**
  96872. * Disposes of the experience helper
  96873. */
  96874. dispose(): void;
  96875. }
  96876. }
  96877. declare module BABYLON {
  96878. /**
  96879. * Button which can be used to enter a different mode of XR
  96880. */
  96881. export class WebXREnterExitUIButton {
  96882. /** button element */
  96883. element: HTMLElement;
  96884. /** XR initialization options for the button */
  96885. initializationOptions: XRSessionCreationOptions;
  96886. /**
  96887. * Creates a WebXREnterExitUIButton
  96888. * @param element button element
  96889. * @param initializationOptions XR initialization options for the button
  96890. */
  96891. constructor(
  96892. /** button element */
  96893. element: HTMLElement,
  96894. /** XR initialization options for the button */
  96895. initializationOptions: XRSessionCreationOptions);
  96896. /**
  96897. * Overwritable function which can be used to update the button's visuals when the state changes
  96898. * @param activeButton the current active button in the UI
  96899. */
  96900. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  96901. }
  96902. /**
  96903. * Options to create the webXR UI
  96904. */
  96905. export class WebXREnterExitUIOptions {
  96906. /**
  96907. * Context to enter xr with
  96908. */
  96909. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  96910. /**
  96911. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  96912. */
  96913. customButtons?: Array<WebXREnterExitUIButton>;
  96914. }
  96915. /**
  96916. * UI to allow the user to enter/exit XR mode
  96917. */
  96918. export class WebXREnterExitUI implements IDisposable {
  96919. private scene;
  96920. private _overlay;
  96921. private _buttons;
  96922. private _activeButton;
  96923. /**
  96924. * Fired every time the active button is changed.
  96925. *
  96926. * When xr is entered via a button that launches xr that button will be the callback parameter
  96927. *
  96928. * When exiting xr the callback parameter will be null)
  96929. */
  96930. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  96931. /**
  96932. * Creates UI to allow the user to enter/exit XR mode
  96933. * @param scene the scene to add the ui to
  96934. * @param helper the xr experience helper to enter/exit xr with
  96935. * @param options options to configure the UI
  96936. * @returns the created ui
  96937. */
  96938. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  96939. private constructor();
  96940. private _updateButtons;
  96941. /**
  96942. * Disposes of the object
  96943. */
  96944. dispose(): void;
  96945. }
  96946. }
  96947. declare module BABYLON {
  96948. /**
  96949. * Represents an XR input
  96950. */
  96951. export class WebXRController {
  96952. /**
  96953. * 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
  96954. */
  96955. grip?: AbstractMesh;
  96956. /**
  96957. * Pointer which can be used to select objects or attach a visible laser to
  96958. */
  96959. pointer: AbstractMesh;
  96960. /**
  96961. * Creates the controller
  96962. * @see https://doc.babylonjs.com/how_to/webxr
  96963. * @param scene the scene which the controller should be associated to
  96964. */
  96965. constructor(scene: Scene);
  96966. /**
  96967. * Disposes of the object
  96968. */
  96969. dispose(): void;
  96970. }
  96971. /**
  96972. * XR input used to track XR inputs such as controllers/rays
  96973. */
  96974. export class WebXRInput implements IDisposable {
  96975. private helper;
  96976. /**
  96977. * XR controllers being tracked
  96978. */
  96979. controllers: Array<WebXRController>;
  96980. private _tmpMatrix;
  96981. private _frameObserver;
  96982. /**
  96983. * Initializes the WebXRInput
  96984. * @param helper experience helper which the input should be created for
  96985. */
  96986. constructor(helper: WebXRExperienceHelper);
  96987. /**
  96988. * Disposes of the object
  96989. */
  96990. dispose(): void;
  96991. }
  96992. }
  96993. declare module BABYLON {
  96994. /**
  96995. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  96996. */
  96997. export class WebXRManagedOutputCanvas implements IDisposable {
  96998. private _canvas;
  96999. /**
  97000. * xrpresent context of the canvas which can be used to display/mirror xr content
  97001. */
  97002. canvasContext: Nullable<WebGLRenderingContext>;
  97003. /**
  97004. * Initializes the canvas to be added/removed upon entering/exiting xr
  97005. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  97006. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  97007. */
  97008. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  97009. /**
  97010. * Disposes of the object
  97011. */
  97012. dispose(): void;
  97013. private _setManagedOutputCanvas;
  97014. private _addCanvas;
  97015. private _removeCanvas;
  97016. }
  97017. }
  97018. declare module BABYLON {
  97019. /**
  97020. * Contains an array of blocks representing the octree
  97021. */
  97022. export interface IOctreeContainer<T> {
  97023. /**
  97024. * Blocks within the octree
  97025. */
  97026. blocks: Array<OctreeBlock<T>>;
  97027. }
  97028. /**
  97029. * Class used to store a cell in an octree
  97030. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97031. */
  97032. export class OctreeBlock<T> {
  97033. /**
  97034. * Gets the content of the current block
  97035. */
  97036. entries: T[];
  97037. /**
  97038. * Gets the list of block children
  97039. */
  97040. blocks: Array<OctreeBlock<T>>;
  97041. private _depth;
  97042. private _maxDepth;
  97043. private _capacity;
  97044. private _minPoint;
  97045. private _maxPoint;
  97046. private _boundingVectors;
  97047. private _creationFunc;
  97048. /**
  97049. * Creates a new block
  97050. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  97051. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  97052. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  97053. * @param depth defines the current depth of this block in the octree
  97054. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  97055. * @param creationFunc defines a callback to call when an element is added to the block
  97056. */
  97057. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  97058. /**
  97059. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  97060. */
  97061. readonly capacity: number;
  97062. /**
  97063. * Gets the minimum vector (in world space) of the block's bounding box
  97064. */
  97065. readonly minPoint: Vector3;
  97066. /**
  97067. * Gets the maximum vector (in world space) of the block's bounding box
  97068. */
  97069. readonly maxPoint: Vector3;
  97070. /**
  97071. * Add a new element to this block
  97072. * @param entry defines the element to add
  97073. */
  97074. addEntry(entry: T): void;
  97075. /**
  97076. * Remove an element from this block
  97077. * @param entry defines the element to remove
  97078. */
  97079. removeEntry(entry: T): void;
  97080. /**
  97081. * Add an array of elements to this block
  97082. * @param entries defines the array of elements to add
  97083. */
  97084. addEntries(entries: T[]): void;
  97085. /**
  97086. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  97087. * @param frustumPlanes defines the frustum planes to test
  97088. * @param selection defines the array to store current content if selection is positive
  97089. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97090. */
  97091. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  97092. /**
  97093. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  97094. * @param sphereCenter defines the bounding sphere center
  97095. * @param sphereRadius defines the bounding sphere radius
  97096. * @param selection defines the array to store current content if selection is positive
  97097. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97098. */
  97099. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  97100. /**
  97101. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  97102. * @param ray defines the ray to test with
  97103. * @param selection defines the array to store current content if selection is positive
  97104. */
  97105. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  97106. /**
  97107. * Subdivide the content into child blocks (this block will then be empty)
  97108. */
  97109. createInnerBlocks(): void;
  97110. /**
  97111. * @hidden
  97112. */
  97113. 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;
  97114. }
  97115. }
  97116. declare module BABYLON {
  97117. /**
  97118. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  97119. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97120. */
  97121. export class Octree<T> {
  97122. /** 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.) */
  97123. maxDepth: number;
  97124. /**
  97125. * Blocks within the octree containing objects
  97126. */
  97127. blocks: Array<OctreeBlock<T>>;
  97128. /**
  97129. * Content stored in the octree
  97130. */
  97131. dynamicContent: T[];
  97132. private _maxBlockCapacity;
  97133. private _selectionContent;
  97134. private _creationFunc;
  97135. /**
  97136. * Creates a octree
  97137. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97138. * @param creationFunc function to be used to instatiate the octree
  97139. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  97140. * @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.)
  97141. */
  97142. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  97143. /** 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.) */
  97144. maxDepth?: number);
  97145. /**
  97146. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  97147. * @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);
  97148. * @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);
  97149. * @param entries meshes to be added to the octree blocks
  97150. */
  97151. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  97152. /**
  97153. * Adds a mesh to the octree
  97154. * @param entry Mesh to add to the octree
  97155. */
  97156. addMesh(entry: T): void;
  97157. /**
  97158. * Remove an element from the octree
  97159. * @param entry defines the element to remove
  97160. */
  97161. removeMesh(entry: T): void;
  97162. /**
  97163. * Selects an array of meshes within the frustum
  97164. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  97165. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  97166. * @returns array of meshes within the frustum
  97167. */
  97168. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  97169. /**
  97170. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  97171. * @param sphereCenter defines the bounding sphere center
  97172. * @param sphereRadius defines the bounding sphere radius
  97173. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97174. * @returns an array of objects that intersect the sphere
  97175. */
  97176. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  97177. /**
  97178. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  97179. * @param ray defines the ray to test with
  97180. * @returns array of intersected objects
  97181. */
  97182. intersectsRay(ray: Ray): SmartArray<T>;
  97183. /**
  97184. * Adds a mesh into the octree block if it intersects the block
  97185. */
  97186. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  97187. /**
  97188. * Adds a submesh into the octree block if it intersects the block
  97189. */
  97190. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  97191. }
  97192. }
  97193. declare module BABYLON {
  97194. interface Scene {
  97195. /**
  97196. * @hidden
  97197. * Backing Filed
  97198. */
  97199. _selectionOctree: Octree<AbstractMesh>;
  97200. /**
  97201. * Gets the octree used to boost mesh selection (picking)
  97202. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97203. */
  97204. selectionOctree: Octree<AbstractMesh>;
  97205. /**
  97206. * Creates or updates the octree used to boost selection (picking)
  97207. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97208. * @param maxCapacity defines the maximum capacity per leaf
  97209. * @param maxDepth defines the maximum depth of the octree
  97210. * @returns an octree of AbstractMesh
  97211. */
  97212. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  97213. }
  97214. interface AbstractMesh {
  97215. /**
  97216. * @hidden
  97217. * Backing Field
  97218. */
  97219. _submeshesOctree: Octree<SubMesh>;
  97220. /**
  97221. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  97222. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  97223. * @param maxCapacity defines the maximum size of each block (64 by default)
  97224. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  97225. * @returns the new octree
  97226. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  97227. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97228. */
  97229. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  97230. }
  97231. /**
  97232. * Defines the octree scene component responsible to manage any octrees
  97233. * in a given scene.
  97234. */
  97235. export class OctreeSceneComponent {
  97236. /**
  97237. * The component name helpfull to identify the component in the list of scene components.
  97238. */
  97239. readonly name: string;
  97240. /**
  97241. * The scene the component belongs to.
  97242. */
  97243. scene: Scene;
  97244. /**
  97245. * Indicates if the meshes have been checked to make sure they are isEnabled()
  97246. */
  97247. readonly checksIsEnabled: boolean;
  97248. /**
  97249. * Creates a new instance of the component for the given scene
  97250. * @param scene Defines the scene to register the component in
  97251. */
  97252. constructor(scene: Scene);
  97253. /**
  97254. * Registers the component in a given scene
  97255. */
  97256. register(): void;
  97257. /**
  97258. * Return the list of active meshes
  97259. * @returns the list of active meshes
  97260. */
  97261. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  97262. /**
  97263. * Return the list of active sub meshes
  97264. * @param mesh The mesh to get the candidates sub meshes from
  97265. * @returns the list of active sub meshes
  97266. */
  97267. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  97268. private _tempRay;
  97269. /**
  97270. * Return the list of sub meshes intersecting with a given local ray
  97271. * @param mesh defines the mesh to find the submesh for
  97272. * @param localRay defines the ray in local space
  97273. * @returns the list of intersecting sub meshes
  97274. */
  97275. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  97276. /**
  97277. * Return the list of sub meshes colliding with a collider
  97278. * @param mesh defines the mesh to find the submesh for
  97279. * @param collider defines the collider to evaluate the collision against
  97280. * @returns the list of colliding sub meshes
  97281. */
  97282. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  97283. /**
  97284. * Rebuilds the elements related to this component in case of
  97285. * context lost for instance.
  97286. */
  97287. rebuild(): void;
  97288. /**
  97289. * Disposes the component and the associated ressources.
  97290. */
  97291. dispose(): void;
  97292. }
  97293. }
  97294. declare module BABYLON {
  97295. /**
  97296. * Class containing static functions to help procedurally build meshes
  97297. */
  97298. export class LinesBuilder {
  97299. /**
  97300. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  97301. * * 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
  97302. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  97303. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  97304. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  97305. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  97306. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  97307. * * 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
  97308. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  97309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97310. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  97311. * @param name defines the name of the new line system
  97312. * @param options defines the options used to create the line system
  97313. * @param scene defines the hosting scene
  97314. * @returns a new line system mesh
  97315. */
  97316. static CreateLineSystem(name: string, options: {
  97317. lines: Vector3[][];
  97318. updatable?: boolean;
  97319. instance?: Nullable<LinesMesh>;
  97320. colors?: Nullable<Color4[][]>;
  97321. useVertexAlpha?: boolean;
  97322. }, scene: Nullable<Scene>): LinesMesh;
  97323. /**
  97324. * Creates a line mesh
  97325. * 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
  97326. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97327. * * The parameter `points` is an array successive Vector3
  97328. * * 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
  97329. * * The optional parameter `colors` is an array of successive Color4, one per line point
  97330. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  97331. * * When updating an instance, remember that only point positions can change, not the number of points
  97332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97333. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  97334. * @param name defines the name of the new line system
  97335. * @param options defines the options used to create the line system
  97336. * @param scene defines the hosting scene
  97337. * @returns a new line mesh
  97338. */
  97339. static CreateLines(name: string, options: {
  97340. points: Vector3[];
  97341. updatable?: boolean;
  97342. instance?: Nullable<LinesMesh>;
  97343. colors?: Color4[];
  97344. useVertexAlpha?: boolean;
  97345. }, scene?: Nullable<Scene>): LinesMesh;
  97346. /**
  97347. * Creates a dashed line mesh
  97348. * * 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
  97349. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97350. * * The parameter `points` is an array successive Vector3
  97351. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  97352. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  97353. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  97354. * * 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
  97355. * * When updating an instance, remember that only point positions can change, not the number of points
  97356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97357. * @param name defines the name of the mesh
  97358. * @param options defines the options used to create the mesh
  97359. * @param scene defines the hosting scene
  97360. * @returns the dashed line mesh
  97361. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  97362. */
  97363. static CreateDashedLines(name: string, options: {
  97364. points: Vector3[];
  97365. dashSize?: number;
  97366. gapSize?: number;
  97367. dashNb?: number;
  97368. updatable?: boolean;
  97369. instance?: LinesMesh;
  97370. }, scene?: Nullable<Scene>): LinesMesh;
  97371. }
  97372. }
  97373. declare module BABYLON {
  97374. /**
  97375. * Renders a layer on top of an existing scene
  97376. */
  97377. export class UtilityLayerRenderer implements IDisposable {
  97378. /** the original scene that will be rendered on top of */
  97379. originalScene: Scene;
  97380. private _pointerCaptures;
  97381. private _lastPointerEvents;
  97382. private static _DefaultUtilityLayer;
  97383. private static _DefaultKeepDepthUtilityLayer;
  97384. /**
  97385. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  97386. */
  97387. pickUtilitySceneFirst: boolean;
  97388. /**
  97389. * 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)
  97390. */
  97391. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  97392. /**
  97393. * 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)
  97394. */
  97395. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  97396. /**
  97397. * The scene that is rendered on top of the original scene
  97398. */
  97399. utilityLayerScene: Scene;
  97400. /**
  97401. * If the utility layer should automatically be rendered on top of existing scene
  97402. */
  97403. shouldRender: boolean;
  97404. /**
  97405. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  97406. */
  97407. onlyCheckPointerDownEvents: boolean;
  97408. /**
  97409. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  97410. */
  97411. processAllEvents: boolean;
  97412. /**
  97413. * Observable raised when the pointer move from the utility layer scene to the main scene
  97414. */
  97415. onPointerOutObservable: Observable<number>;
  97416. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  97417. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  97418. private _afterRenderObserver;
  97419. private _sceneDisposeObserver;
  97420. private _originalPointerObserver;
  97421. /**
  97422. * Instantiates a UtilityLayerRenderer
  97423. * @param originalScene the original scene that will be rendered on top of
  97424. * @param handleEvents boolean indicating if the utility layer should handle events
  97425. */
  97426. constructor(
  97427. /** the original scene that will be rendered on top of */
  97428. originalScene: Scene, handleEvents?: boolean);
  97429. private _notifyObservers;
  97430. /**
  97431. * Renders the utility layers scene on top of the original scene
  97432. */
  97433. render(): void;
  97434. /**
  97435. * Disposes of the renderer
  97436. */
  97437. dispose(): void;
  97438. private _updateCamera;
  97439. }
  97440. }
  97441. declare module BABYLON {
  97442. /**
  97443. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  97444. */
  97445. export class Gizmo implements IDisposable {
  97446. /** The utility layer the gizmo will be added to */
  97447. gizmoLayer: UtilityLayerRenderer;
  97448. /**
  97449. * The root mesh of the gizmo
  97450. */
  97451. _rootMesh: Mesh;
  97452. private _attachedMesh;
  97453. /**
  97454. * Ratio for the scale of the gizmo (Default: 1)
  97455. */
  97456. scaleRatio: number;
  97457. private _tmpMatrix;
  97458. /**
  97459. * If a custom mesh has been set (Default: false)
  97460. */
  97461. protected _customMeshSet: boolean;
  97462. /**
  97463. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  97464. * * When set, interactions will be enabled
  97465. */
  97466. attachedMesh: Nullable<AbstractMesh>;
  97467. /**
  97468. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  97469. * @param mesh The mesh to replace the default mesh of the gizmo
  97470. */
  97471. setCustomMesh(mesh: Mesh): void;
  97472. /**
  97473. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  97474. */
  97475. updateGizmoRotationToMatchAttachedMesh: boolean;
  97476. /**
  97477. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  97478. */
  97479. updateGizmoPositionToMatchAttachedMesh: boolean;
  97480. /**
  97481. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  97482. */
  97483. protected _updateScale: boolean;
  97484. protected _interactionsEnabled: boolean;
  97485. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97486. private _beforeRenderObserver;
  97487. /**
  97488. * Creates a gizmo
  97489. * @param gizmoLayer The utility layer the gizmo will be added to
  97490. */
  97491. constructor(
  97492. /** The utility layer the gizmo will be added to */
  97493. gizmoLayer?: UtilityLayerRenderer);
  97494. private _tempVector;
  97495. /**
  97496. * @hidden
  97497. * Updates the gizmo to match the attached mesh's position/rotation
  97498. */
  97499. protected _update(): void;
  97500. /**
  97501. * Disposes of the gizmo
  97502. */
  97503. dispose(): void;
  97504. }
  97505. }
  97506. declare module BABYLON {
  97507. /**
  97508. * Single axis drag gizmo
  97509. */
  97510. export class AxisDragGizmo extends Gizmo {
  97511. /**
  97512. * Drag behavior responsible for the gizmos dragging interactions
  97513. */
  97514. dragBehavior: PointerDragBehavior;
  97515. private _pointerObserver;
  97516. /**
  97517. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97518. */
  97519. snapDistance: number;
  97520. /**
  97521. * Event that fires each time the gizmo snaps to a new location.
  97522. * * snapDistance is the the change in distance
  97523. */
  97524. onSnapObservable: Observable<{
  97525. snapDistance: number;
  97526. }>;
  97527. /** @hidden */
  97528. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  97529. /** @hidden */
  97530. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  97531. /**
  97532. * Creates an AxisDragGizmo
  97533. * @param gizmoLayer The utility layer the gizmo will be added to
  97534. * @param dragAxis The axis which the gizmo will be able to drag on
  97535. * @param color The color of the gizmo
  97536. */
  97537. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97538. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97539. /**
  97540. * Disposes of the gizmo
  97541. */
  97542. dispose(): void;
  97543. }
  97544. }
  97545. declare module BABYLON.Debug {
  97546. /**
  97547. * The Axes viewer will show 3 axes in a specific point in space
  97548. */
  97549. export class AxesViewer {
  97550. private _xAxis;
  97551. private _yAxis;
  97552. private _zAxis;
  97553. private _scaleLinesFactor;
  97554. private _instanced;
  97555. /**
  97556. * Gets the hosting scene
  97557. */
  97558. scene: Scene;
  97559. /**
  97560. * Gets or sets a number used to scale line length
  97561. */
  97562. scaleLines: number;
  97563. /** Gets the node hierarchy used to render x-axis */
  97564. readonly xAxis: TransformNode;
  97565. /** Gets the node hierarchy used to render y-axis */
  97566. readonly yAxis: TransformNode;
  97567. /** Gets the node hierarchy used to render z-axis */
  97568. readonly zAxis: TransformNode;
  97569. /**
  97570. * Creates a new AxesViewer
  97571. * @param scene defines the hosting scene
  97572. * @param scaleLines defines a number used to scale line length (1 by default)
  97573. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  97574. * @param xAxis defines the node hierarchy used to render the x-axis
  97575. * @param yAxis defines the node hierarchy used to render the y-axis
  97576. * @param zAxis defines the node hierarchy used to render the z-axis
  97577. */
  97578. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  97579. /**
  97580. * Force the viewer to update
  97581. * @param position defines the position of the viewer
  97582. * @param xaxis defines the x axis of the viewer
  97583. * @param yaxis defines the y axis of the viewer
  97584. * @param zaxis defines the z axis of the viewer
  97585. */
  97586. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  97587. /**
  97588. * Creates an instance of this axes viewer.
  97589. * @returns a new axes viewer with instanced meshes
  97590. */
  97591. createInstance(): AxesViewer;
  97592. /** Releases resources */
  97593. dispose(): void;
  97594. private static _SetRenderingGroupId;
  97595. }
  97596. }
  97597. declare module BABYLON.Debug {
  97598. /**
  97599. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  97600. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  97601. */
  97602. export class BoneAxesViewer extends AxesViewer {
  97603. /**
  97604. * Gets or sets the target mesh where to display the axes viewer
  97605. */
  97606. mesh: Nullable<Mesh>;
  97607. /**
  97608. * Gets or sets the target bone where to display the axes viewer
  97609. */
  97610. bone: Nullable<Bone>;
  97611. /** Gets current position */
  97612. pos: Vector3;
  97613. /** Gets direction of X axis */
  97614. xaxis: Vector3;
  97615. /** Gets direction of Y axis */
  97616. yaxis: Vector3;
  97617. /** Gets direction of Z axis */
  97618. zaxis: Vector3;
  97619. /**
  97620. * Creates a new BoneAxesViewer
  97621. * @param scene defines the hosting scene
  97622. * @param bone defines the target bone
  97623. * @param mesh defines the target mesh
  97624. * @param scaleLines defines a scaling factor for line length (1 by default)
  97625. */
  97626. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  97627. /**
  97628. * Force the viewer to update
  97629. */
  97630. update(): void;
  97631. /** Releases resources */
  97632. dispose(): void;
  97633. }
  97634. }
  97635. declare module BABYLON {
  97636. /**
  97637. * Interface used to define scene explorer extensibility option
  97638. */
  97639. export interface IExplorerExtensibilityOption {
  97640. /**
  97641. * Define the option label
  97642. */
  97643. label: string;
  97644. /**
  97645. * Defines the action to execute on click
  97646. */
  97647. action: (entity: any) => void;
  97648. }
  97649. /**
  97650. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  97651. */
  97652. export interface IExplorerExtensibilityGroup {
  97653. /**
  97654. * Defines a predicate to test if a given type mut be extended
  97655. */
  97656. predicate: (entity: any) => boolean;
  97657. /**
  97658. * Gets the list of options added to a type
  97659. */
  97660. entries: IExplorerExtensibilityOption[];
  97661. }
  97662. /**
  97663. * Interface used to define the options to use to create the Inspector
  97664. */
  97665. export interface IInspectorOptions {
  97666. /**
  97667. * Display in overlay mode (default: false)
  97668. */
  97669. overlay?: boolean;
  97670. /**
  97671. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  97672. */
  97673. globalRoot?: HTMLElement;
  97674. /**
  97675. * Display the Scene explorer
  97676. */
  97677. showExplorer?: boolean;
  97678. /**
  97679. * Display the property inspector
  97680. */
  97681. showInspector?: boolean;
  97682. /**
  97683. * Display in embed mode (both panes on the right)
  97684. */
  97685. embedMode?: boolean;
  97686. /**
  97687. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  97688. */
  97689. handleResize?: boolean;
  97690. /**
  97691. * Allow the panes to popup (default: true)
  97692. */
  97693. enablePopup?: boolean;
  97694. /**
  97695. * Allow the panes to be closed by users (default: true)
  97696. */
  97697. enableClose?: boolean;
  97698. /**
  97699. * Optional list of extensibility entries
  97700. */
  97701. explorerExtensibility?: IExplorerExtensibilityGroup[];
  97702. /**
  97703. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  97704. */
  97705. inspectorURL?: string;
  97706. }
  97707. interface Scene {
  97708. /**
  97709. * @hidden
  97710. * Backing field
  97711. */
  97712. _debugLayer: DebugLayer;
  97713. /**
  97714. * Gets the debug layer (aka Inspector) associated with the scene
  97715. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97716. */
  97717. debugLayer: DebugLayer;
  97718. }
  97719. /**
  97720. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97721. * what is happening in your scene
  97722. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97723. */
  97724. export class DebugLayer {
  97725. /**
  97726. * Define the url to get the inspector script from.
  97727. * By default it uses the babylonjs CDN.
  97728. * @ignoreNaming
  97729. */
  97730. static InspectorURL: string;
  97731. private _scene;
  97732. private BJSINSPECTOR;
  97733. /**
  97734. * Observable triggered when a property is changed through the inspector.
  97735. */
  97736. onPropertyChangedObservable: Observable<{
  97737. object: any;
  97738. property: string;
  97739. value: any;
  97740. initialValue: any;
  97741. }>;
  97742. /**
  97743. * Instantiates a new debug layer.
  97744. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97745. * what is happening in your scene
  97746. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97747. * @param scene Defines the scene to inspect
  97748. */
  97749. constructor(scene: Scene);
  97750. /** Creates the inspector window. */
  97751. private _createInspector;
  97752. /**
  97753. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  97754. * @param entity defines the entity to select
  97755. * @param lineContainerTitle defines the specific block to highlight
  97756. */
  97757. select(entity: any, lineContainerTitle?: string): void;
  97758. /** Get the inspector from bundle or global */
  97759. private _getGlobalInspector;
  97760. /**
  97761. * Get if the inspector is visible or not.
  97762. * @returns true if visible otherwise, false
  97763. */
  97764. isVisible(): boolean;
  97765. /**
  97766. * Hide the inspector and close its window.
  97767. */
  97768. hide(): void;
  97769. /**
  97770. * Launch the debugLayer.
  97771. * @param config Define the configuration of the inspector
  97772. * @return a promise fulfilled when the debug layer is visible
  97773. */
  97774. show(config?: IInspectorOptions): Promise<DebugLayer>;
  97775. }
  97776. }
  97777. declare module BABYLON {
  97778. /**
  97779. * Class containing static functions to help procedurally build meshes
  97780. */
  97781. export class BoxBuilder {
  97782. /**
  97783. * Creates a box mesh
  97784. * * The parameter `size` sets the size (float) of each box side (default 1)
  97785. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  97786. * * 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)
  97787. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  97788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97791. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  97792. * @param name defines the name of the mesh
  97793. * @param options defines the options used to create the mesh
  97794. * @param scene defines the hosting scene
  97795. * @returns the box mesh
  97796. */
  97797. static CreateBox(name: string, options: {
  97798. size?: number;
  97799. width?: number;
  97800. height?: number;
  97801. depth?: number;
  97802. faceUV?: Vector4[];
  97803. faceColors?: Color4[];
  97804. sideOrientation?: number;
  97805. frontUVs?: Vector4;
  97806. backUVs?: Vector4;
  97807. updatable?: boolean;
  97808. }, scene?: Nullable<Scene>): Mesh;
  97809. }
  97810. }
  97811. declare module BABYLON {
  97812. /**
  97813. * Class containing static functions to help procedurally build meshes
  97814. */
  97815. export class SphereBuilder {
  97816. /**
  97817. * Creates a sphere mesh
  97818. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  97819. * * 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`)
  97820. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  97821. * * 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
  97822. * * 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)
  97823. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97824. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97826. * @param name defines the name of the mesh
  97827. * @param options defines the options used to create the mesh
  97828. * @param scene defines the hosting scene
  97829. * @returns the sphere mesh
  97830. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  97831. */
  97832. static CreateSphere(name: string, options: {
  97833. segments?: number;
  97834. diameter?: number;
  97835. diameterX?: number;
  97836. diameterY?: number;
  97837. diameterZ?: number;
  97838. arc?: number;
  97839. slice?: number;
  97840. sideOrientation?: number;
  97841. frontUVs?: Vector4;
  97842. backUVs?: Vector4;
  97843. updatable?: boolean;
  97844. }, scene: any): Mesh;
  97845. }
  97846. }
  97847. declare module BABYLON.Debug {
  97848. /**
  97849. * Used to show the physics impostor around the specific mesh
  97850. */
  97851. export class PhysicsViewer {
  97852. /** @hidden */
  97853. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  97854. /** @hidden */
  97855. protected _meshes: Array<Nullable<AbstractMesh>>;
  97856. /** @hidden */
  97857. protected _scene: Nullable<Scene>;
  97858. /** @hidden */
  97859. protected _numMeshes: number;
  97860. /** @hidden */
  97861. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  97862. private _renderFunction;
  97863. private _utilityLayer;
  97864. private _debugBoxMesh;
  97865. private _debugSphereMesh;
  97866. private _debugMaterial;
  97867. /**
  97868. * Creates a new PhysicsViewer
  97869. * @param scene defines the hosting scene
  97870. */
  97871. constructor(scene: Scene);
  97872. /** @hidden */
  97873. protected _updateDebugMeshes(): void;
  97874. /**
  97875. * Renders a specified physic impostor
  97876. * @param impostor defines the impostor to render
  97877. * @returns the new debug mesh used to render the impostor
  97878. */
  97879. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  97880. /**
  97881. * Hides a specified physic impostor
  97882. * @param impostor defines the impostor to hide
  97883. */
  97884. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  97885. private _getDebugMaterial;
  97886. private _getDebugBoxMesh;
  97887. private _getDebugSphereMesh;
  97888. private _getDebugMesh;
  97889. /** Releases all resources */
  97890. dispose(): void;
  97891. }
  97892. }
  97893. declare module BABYLON {
  97894. /**
  97895. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  97896. * in order to better appreciate the issue one might have.
  97897. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  97898. */
  97899. export class RayHelper {
  97900. /**
  97901. * Defines the ray we are currently tryin to visualize.
  97902. */
  97903. ray: Nullable<Ray>;
  97904. private _renderPoints;
  97905. private _renderLine;
  97906. private _renderFunction;
  97907. private _scene;
  97908. private _updateToMeshFunction;
  97909. private _attachedToMesh;
  97910. private _meshSpaceDirection;
  97911. private _meshSpaceOrigin;
  97912. /**
  97913. * Helper function to create a colored helper in a scene in one line.
  97914. * @param ray Defines the ray we are currently tryin to visualize
  97915. * @param scene Defines the scene the ray is used in
  97916. * @param color Defines the color we want to see the ray in
  97917. * @returns The newly created ray helper.
  97918. */
  97919. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  97920. /**
  97921. * Instantiate a new ray helper.
  97922. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  97923. * in order to better appreciate the issue one might have.
  97924. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  97925. * @param ray Defines the ray we are currently tryin to visualize
  97926. */
  97927. constructor(ray: Ray);
  97928. /**
  97929. * Shows the ray we are willing to debug.
  97930. * @param scene Defines the scene the ray needs to be rendered in
  97931. * @param color Defines the color the ray needs to be rendered in
  97932. */
  97933. show(scene: Scene, color?: Color3): void;
  97934. /**
  97935. * Hides the ray we are debugging.
  97936. */
  97937. hide(): void;
  97938. private _render;
  97939. /**
  97940. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  97941. * @param mesh Defines the mesh we want the helper attached to
  97942. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  97943. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  97944. * @param length Defines the length of the ray
  97945. */
  97946. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  97947. /**
  97948. * Detach the ray helper from the mesh it has previously been attached to.
  97949. */
  97950. detachFromMesh(): void;
  97951. private _updateToMesh;
  97952. /**
  97953. * Dispose the helper and release its associated resources.
  97954. */
  97955. dispose(): void;
  97956. }
  97957. }
  97958. declare module BABYLON.Debug {
  97959. /**
  97960. * Class used to render a debug view of a given skeleton
  97961. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  97962. */
  97963. export class SkeletonViewer {
  97964. /** defines the skeleton to render */
  97965. skeleton: Skeleton;
  97966. /** defines the mesh attached to the skeleton */
  97967. mesh: AbstractMesh;
  97968. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  97969. autoUpdateBonesMatrices: boolean;
  97970. /** defines the rendering group id to use with the viewer */
  97971. renderingGroupId: number;
  97972. /** Gets or sets the color used to render the skeleton */
  97973. color: Color3;
  97974. private _scene;
  97975. private _debugLines;
  97976. private _debugMesh;
  97977. private _isEnabled;
  97978. private _renderFunction;
  97979. private _utilityLayer;
  97980. /**
  97981. * Returns the mesh used to render the bones
  97982. */
  97983. readonly debugMesh: Nullable<LinesMesh>;
  97984. /**
  97985. * Creates a new SkeletonViewer
  97986. * @param skeleton defines the skeleton to render
  97987. * @param mesh defines the mesh attached to the skeleton
  97988. * @param scene defines the hosting scene
  97989. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  97990. * @param renderingGroupId defines the rendering group id to use with the viewer
  97991. */
  97992. constructor(
  97993. /** defines the skeleton to render */
  97994. skeleton: Skeleton,
  97995. /** defines the mesh attached to the skeleton */
  97996. mesh: AbstractMesh, scene: Scene,
  97997. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  97998. autoUpdateBonesMatrices?: boolean,
  97999. /** defines the rendering group id to use with the viewer */
  98000. renderingGroupId?: number);
  98001. /** Gets or sets a boolean indicating if the viewer is enabled */
  98002. isEnabled: boolean;
  98003. private _getBonePosition;
  98004. private _getLinesForBonesWithLength;
  98005. private _getLinesForBonesNoLength;
  98006. /** Update the viewer to sync with current skeleton state */
  98007. update(): void;
  98008. /** Release associated resources */
  98009. dispose(): void;
  98010. }
  98011. }
  98012. declare module BABYLON {
  98013. /**
  98014. * Options to create the null engine
  98015. */
  98016. export class NullEngineOptions {
  98017. /**
  98018. * Render width (Default: 512)
  98019. */
  98020. renderWidth: number;
  98021. /**
  98022. * Render height (Default: 256)
  98023. */
  98024. renderHeight: number;
  98025. /**
  98026. * Texture size (Default: 512)
  98027. */
  98028. textureSize: number;
  98029. /**
  98030. * If delta time between frames should be constant
  98031. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98032. */
  98033. deterministicLockstep: boolean;
  98034. /**
  98035. * Maximum about of steps between frames (Default: 4)
  98036. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98037. */
  98038. lockstepMaxSteps: number;
  98039. }
  98040. /**
  98041. * The null engine class provides support for headless version of babylon.js.
  98042. * This can be used in server side scenario or for testing purposes
  98043. */
  98044. export class NullEngine extends Engine {
  98045. private _options;
  98046. /**
  98047. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98048. */
  98049. isDeterministicLockStep(): boolean;
  98050. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  98051. getLockstepMaxSteps(): number;
  98052. /**
  98053. * Sets hardware scaling, used to save performance if needed
  98054. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98055. */
  98056. getHardwareScalingLevel(): number;
  98057. constructor(options?: NullEngineOptions);
  98058. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  98059. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  98060. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  98061. getRenderWidth(useScreen?: boolean): number;
  98062. getRenderHeight(useScreen?: boolean): number;
  98063. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  98064. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  98065. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  98066. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  98067. bindSamplers(effect: Effect): void;
  98068. enableEffect(effect: Effect): void;
  98069. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98070. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  98071. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  98072. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  98073. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  98074. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  98075. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  98076. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  98077. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  98078. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  98079. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  98080. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  98081. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  98082. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  98083. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  98084. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  98085. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  98086. setFloat(uniform: WebGLUniformLocation, value: number): void;
  98087. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  98088. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  98089. setBool(uniform: WebGLUniformLocation, bool: number): void;
  98090. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  98091. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  98092. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  98093. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98094. bindBuffers(vertexBuffers: {
  98095. [key: string]: VertexBuffer;
  98096. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  98097. wipeCaches(bruteForce?: boolean): void;
  98098. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  98099. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  98100. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98101. /** @hidden */
  98102. _createTexture(): WebGLTexture;
  98103. /** @hidden */
  98104. _releaseTexture(texture: InternalTexture): void;
  98105. 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;
  98106. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  98107. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  98108. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  98109. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  98110. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  98111. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  98112. areAllEffectsReady(): boolean;
  98113. /**
  98114. * @hidden
  98115. * Get the current error code of the webGL context
  98116. * @returns the error code
  98117. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  98118. */
  98119. getError(): number;
  98120. /** @hidden */
  98121. _getUnpackAlignement(): number;
  98122. /** @hidden */
  98123. _unpackFlipY(value: boolean): void;
  98124. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  98125. /**
  98126. * Updates a dynamic vertex buffer.
  98127. * @param vertexBuffer the vertex buffer to update
  98128. * @param data the data used to update the vertex buffer
  98129. * @param byteOffset the byte offset of the data (optional)
  98130. * @param byteLength the byte length of the data (optional)
  98131. */
  98132. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  98133. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  98134. /** @hidden */
  98135. _bindTexture(channel: number, texture: InternalTexture): void;
  98136. /** @hidden */
  98137. _releaseBuffer(buffer: WebGLBuffer): boolean;
  98138. releaseEffects(): void;
  98139. displayLoadingUI(): void;
  98140. hideLoadingUI(): void;
  98141. /** @hidden */
  98142. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98143. /** @hidden */
  98144. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98145. /** @hidden */
  98146. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98147. /** @hidden */
  98148. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  98149. }
  98150. }
  98151. declare module BABYLON {
  98152. /** @hidden */
  98153. export class _OcclusionDataStorage {
  98154. /** @hidden */
  98155. occlusionInternalRetryCounter: number;
  98156. /** @hidden */
  98157. isOcclusionQueryInProgress: boolean;
  98158. /** @hidden */
  98159. isOccluded: boolean;
  98160. /** @hidden */
  98161. occlusionRetryCount: number;
  98162. /** @hidden */
  98163. occlusionType: number;
  98164. /** @hidden */
  98165. occlusionQueryAlgorithmType: number;
  98166. }
  98167. interface Engine {
  98168. /**
  98169. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  98170. * @return the new query
  98171. */
  98172. createQuery(): WebGLQuery;
  98173. /**
  98174. * Delete and release a webGL query
  98175. * @param query defines the query to delete
  98176. * @return the current engine
  98177. */
  98178. deleteQuery(query: WebGLQuery): Engine;
  98179. /**
  98180. * Check if a given query has resolved and got its value
  98181. * @param query defines the query to check
  98182. * @returns true if the query got its value
  98183. */
  98184. isQueryResultAvailable(query: WebGLQuery): boolean;
  98185. /**
  98186. * Gets the value of a given query
  98187. * @param query defines the query to check
  98188. * @returns the value of the query
  98189. */
  98190. getQueryResult(query: WebGLQuery): number;
  98191. /**
  98192. * Initiates an occlusion query
  98193. * @param algorithmType defines the algorithm to use
  98194. * @param query defines the query to use
  98195. * @returns the current engine
  98196. * @see http://doc.babylonjs.com/features/occlusionquery
  98197. */
  98198. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  98199. /**
  98200. * Ends an occlusion query
  98201. * @see http://doc.babylonjs.com/features/occlusionquery
  98202. * @param algorithmType defines the algorithm to use
  98203. * @returns the current engine
  98204. */
  98205. endOcclusionQuery(algorithmType: number): Engine;
  98206. /**
  98207. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  98208. * Please note that only one query can be issued at a time
  98209. * @returns a time token used to track the time span
  98210. */
  98211. startTimeQuery(): Nullable<_TimeToken>;
  98212. /**
  98213. * Ends a time query
  98214. * @param token defines the token used to measure the time span
  98215. * @returns the time spent (in ns)
  98216. */
  98217. endTimeQuery(token: _TimeToken): int;
  98218. /** @hidden */
  98219. _currentNonTimestampToken: Nullable<_TimeToken>;
  98220. /** @hidden */
  98221. _createTimeQuery(): WebGLQuery;
  98222. /** @hidden */
  98223. _deleteTimeQuery(query: WebGLQuery): void;
  98224. /** @hidden */
  98225. _getGlAlgorithmType(algorithmType: number): number;
  98226. /** @hidden */
  98227. _getTimeQueryResult(query: WebGLQuery): any;
  98228. /** @hidden */
  98229. _getTimeQueryAvailability(query: WebGLQuery): any;
  98230. }
  98231. interface AbstractMesh {
  98232. /**
  98233. * Backing filed
  98234. * @hidden
  98235. */
  98236. __occlusionDataStorage: _OcclusionDataStorage;
  98237. /**
  98238. * Access property
  98239. * @hidden
  98240. */
  98241. _occlusionDataStorage: _OcclusionDataStorage;
  98242. /**
  98243. * 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.
  98244. * The default value is -1 which means don't break the query and wait till the result
  98245. * @see http://doc.babylonjs.com/features/occlusionquery
  98246. */
  98247. occlusionRetryCount: number;
  98248. /**
  98249. * 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:
  98250. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  98251. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  98252. * * 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.
  98253. * @see http://doc.babylonjs.com/features/occlusionquery
  98254. */
  98255. occlusionType: number;
  98256. /**
  98257. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  98258. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  98259. * * 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.
  98260. * @see http://doc.babylonjs.com/features/occlusionquery
  98261. */
  98262. occlusionQueryAlgorithmType: number;
  98263. /**
  98264. * 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
  98265. * @see http://doc.babylonjs.com/features/occlusionquery
  98266. */
  98267. isOccluded: boolean;
  98268. /**
  98269. * Flag to check the progress status of the query
  98270. * @see http://doc.babylonjs.com/features/occlusionquery
  98271. */
  98272. isOcclusionQueryInProgress: boolean;
  98273. }
  98274. }
  98275. declare module BABYLON {
  98276. /** @hidden */
  98277. export var _forceTransformFeedbackToBundle: boolean;
  98278. interface Engine {
  98279. /**
  98280. * Creates a webGL transform feedback object
  98281. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  98282. * @returns the webGL transform feedback object
  98283. */
  98284. createTransformFeedback(): WebGLTransformFeedback;
  98285. /**
  98286. * Delete a webGL transform feedback object
  98287. * @param value defines the webGL transform feedback object to delete
  98288. */
  98289. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  98290. /**
  98291. * Bind a webGL transform feedback object to the webgl context
  98292. * @param value defines the webGL transform feedback object to bind
  98293. */
  98294. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  98295. /**
  98296. * Begins a transform feedback operation
  98297. * @param usePoints defines if points or triangles must be used
  98298. */
  98299. beginTransformFeedback(usePoints: boolean): void;
  98300. /**
  98301. * Ends a transform feedback operation
  98302. */
  98303. endTransformFeedback(): void;
  98304. /**
  98305. * Specify the varyings to use with transform feedback
  98306. * @param program defines the associated webGL program
  98307. * @param value defines the list of strings representing the varying names
  98308. */
  98309. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  98310. /**
  98311. * Bind a webGL buffer for a transform feedback operation
  98312. * @param value defines the webGL buffer to bind
  98313. */
  98314. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  98315. }
  98316. }
  98317. declare module BABYLON {
  98318. /**
  98319. * Gather the list of clipboard event types as constants.
  98320. */
  98321. export class ClipboardEventTypes {
  98322. /**
  98323. * The clipboard event is fired when a copy command is active (pressed).
  98324. */
  98325. static readonly COPY: number;
  98326. /**
  98327. * The clipboard event is fired when a cut command is active (pressed).
  98328. */
  98329. static readonly CUT: number;
  98330. /**
  98331. * The clipboard event is fired when a paste command is active (pressed).
  98332. */
  98333. static readonly PASTE: number;
  98334. }
  98335. /**
  98336. * This class is used to store clipboard related info for the onClipboardObservable event.
  98337. */
  98338. export class ClipboardInfo {
  98339. /**
  98340. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98341. */
  98342. type: number;
  98343. /**
  98344. * Defines the related dom event
  98345. */
  98346. event: ClipboardEvent;
  98347. /**
  98348. *Creates an instance of ClipboardInfo.
  98349. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  98350. * @param event Defines the related dom event
  98351. */
  98352. constructor(
  98353. /**
  98354. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98355. */
  98356. type: number,
  98357. /**
  98358. * Defines the related dom event
  98359. */
  98360. event: ClipboardEvent);
  98361. /**
  98362. * Get the clipboard event's type from the keycode.
  98363. * @param keyCode Defines the keyCode for the current keyboard event.
  98364. * @return {number}
  98365. */
  98366. static GetTypeFromCharacter(keyCode: number): number;
  98367. }
  98368. }
  98369. declare module BABYLON {
  98370. /**
  98371. * Class used to represent data loading progression
  98372. */
  98373. export class SceneLoaderProgressEvent {
  98374. /** defines if data length to load can be evaluated */
  98375. readonly lengthComputable: boolean;
  98376. /** defines the loaded data length */
  98377. readonly loaded: number;
  98378. /** defines the data length to load */
  98379. readonly total: number;
  98380. /**
  98381. * Create a new progress event
  98382. * @param lengthComputable defines if data length to load can be evaluated
  98383. * @param loaded defines the loaded data length
  98384. * @param total defines the data length to load
  98385. */
  98386. constructor(
  98387. /** defines if data length to load can be evaluated */
  98388. lengthComputable: boolean,
  98389. /** defines the loaded data length */
  98390. loaded: number,
  98391. /** defines the data length to load */
  98392. total: number);
  98393. /**
  98394. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  98395. * @param event defines the source event
  98396. * @returns a new SceneLoaderProgressEvent
  98397. */
  98398. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  98399. }
  98400. /**
  98401. * Interface used by SceneLoader plugins to define supported file extensions
  98402. */
  98403. export interface ISceneLoaderPluginExtensions {
  98404. /**
  98405. * Defines the list of supported extensions
  98406. */
  98407. [extension: string]: {
  98408. isBinary: boolean;
  98409. };
  98410. }
  98411. /**
  98412. * Interface used by SceneLoader plugin factory
  98413. */
  98414. export interface ISceneLoaderPluginFactory {
  98415. /**
  98416. * Defines the name of the factory
  98417. */
  98418. name: string;
  98419. /**
  98420. * Function called to create a new plugin
  98421. * @return the new plugin
  98422. */
  98423. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  98424. /**
  98425. * Boolean indicating if the plugin can direct load specific data
  98426. */
  98427. canDirectLoad?: (data: string) => boolean;
  98428. }
  98429. /**
  98430. * Interface used to define a SceneLoader plugin
  98431. */
  98432. export interface ISceneLoaderPlugin {
  98433. /**
  98434. * The friendly name of this plugin.
  98435. */
  98436. name: string;
  98437. /**
  98438. * The file extensions supported by this plugin.
  98439. */
  98440. extensions: string | ISceneLoaderPluginExtensions;
  98441. /**
  98442. * Import meshes into a scene.
  98443. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98444. * @param scene The scene to import into
  98445. * @param data The data to import
  98446. * @param rootUrl The root url for scene and resources
  98447. * @param meshes The meshes array to import into
  98448. * @param particleSystems The particle systems array to import into
  98449. * @param skeletons The skeletons array to import into
  98450. * @param onError The callback when import fails
  98451. * @returns True if successful or false otherwise
  98452. */
  98453. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  98454. /**
  98455. * Load into a scene.
  98456. * @param scene The scene to load into
  98457. * @param data The data to import
  98458. * @param rootUrl The root url for scene and resources
  98459. * @param onError The callback when import fails
  98460. * @returns true if successful or false otherwise
  98461. */
  98462. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  98463. /**
  98464. * The callback that returns true if the data can be directly loaded.
  98465. */
  98466. canDirectLoad?: (data: string) => boolean;
  98467. /**
  98468. * The callback that allows custom handling of the root url based on the response url.
  98469. */
  98470. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98471. /**
  98472. * Load into an asset container.
  98473. * @param scene The scene to load into
  98474. * @param data The data to import
  98475. * @param rootUrl The root url for scene and resources
  98476. * @param onError The callback when import fails
  98477. * @returns The loaded asset container
  98478. */
  98479. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  98480. }
  98481. /**
  98482. * Interface used to define an async SceneLoader plugin
  98483. */
  98484. export interface ISceneLoaderPluginAsync {
  98485. /**
  98486. * The friendly name of this plugin.
  98487. */
  98488. name: string;
  98489. /**
  98490. * The file extensions supported by this plugin.
  98491. */
  98492. extensions: string | ISceneLoaderPluginExtensions;
  98493. /**
  98494. * Import meshes into a scene.
  98495. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98496. * @param scene The scene to import into
  98497. * @param data The data to import
  98498. * @param rootUrl The root url for scene and resources
  98499. * @param onProgress The callback when the load progresses
  98500. * @param fileName Defines the name of the file to load
  98501. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  98502. */
  98503. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  98504. meshes: AbstractMesh[];
  98505. particleSystems: IParticleSystem[];
  98506. skeletons: Skeleton[];
  98507. animationGroups: AnimationGroup[];
  98508. }>;
  98509. /**
  98510. * Load into a scene.
  98511. * @param scene The scene to load into
  98512. * @param data The data to import
  98513. * @param rootUrl The root url for scene and resources
  98514. * @param onProgress The callback when the load progresses
  98515. * @param fileName Defines the name of the file to load
  98516. * @returns Nothing
  98517. */
  98518. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  98519. /**
  98520. * The callback that returns true if the data can be directly loaded.
  98521. */
  98522. canDirectLoad?: (data: string) => boolean;
  98523. /**
  98524. * The callback that allows custom handling of the root url based on the response url.
  98525. */
  98526. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98527. /**
  98528. * Load into an asset container.
  98529. * @param scene The scene to load into
  98530. * @param data The data to import
  98531. * @param rootUrl The root url for scene and resources
  98532. * @param onProgress The callback when the load progresses
  98533. * @param fileName Defines the name of the file to load
  98534. * @returns The loaded asset container
  98535. */
  98536. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  98537. }
  98538. /**
  98539. * Class used to load scene from various file formats using registered plugins
  98540. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  98541. */
  98542. export class SceneLoader {
  98543. /**
  98544. * No logging while loading
  98545. */
  98546. static readonly NO_LOGGING: number;
  98547. /**
  98548. * Minimal logging while loading
  98549. */
  98550. static readonly MINIMAL_LOGGING: number;
  98551. /**
  98552. * Summary logging while loading
  98553. */
  98554. static readonly SUMMARY_LOGGING: number;
  98555. /**
  98556. * Detailled logging while loading
  98557. */
  98558. static readonly DETAILED_LOGGING: number;
  98559. /**
  98560. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  98561. */
  98562. static ForceFullSceneLoadingForIncremental: boolean;
  98563. /**
  98564. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  98565. */
  98566. static ShowLoadingScreen: boolean;
  98567. /**
  98568. * Defines the current logging level (while loading the scene)
  98569. * @ignorenaming
  98570. */
  98571. static loggingLevel: number;
  98572. /**
  98573. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  98574. */
  98575. static CleanBoneMatrixWeights: boolean;
  98576. /**
  98577. * Event raised when a plugin is used to load a scene
  98578. */
  98579. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  98580. private static _registeredPlugins;
  98581. private static _getDefaultPlugin;
  98582. private static _getPluginForExtension;
  98583. private static _getPluginForDirectLoad;
  98584. private static _getPluginForFilename;
  98585. private static _getDirectLoad;
  98586. private static _loadData;
  98587. private static _getFileInfo;
  98588. /**
  98589. * Gets a plugin that can load the given extension
  98590. * @param extension defines the extension to load
  98591. * @returns a plugin or null if none works
  98592. */
  98593. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  98594. /**
  98595. * Gets a boolean indicating that the given extension can be loaded
  98596. * @param extension defines the extension to load
  98597. * @returns true if the extension is supported
  98598. */
  98599. static IsPluginForExtensionAvailable(extension: string): boolean;
  98600. /**
  98601. * Adds a new plugin to the list of registered plugins
  98602. * @param plugin defines the plugin to add
  98603. */
  98604. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  98605. /**
  98606. * Import meshes into a scene
  98607. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98608. * @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)
  98609. * @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)
  98610. * @param scene the instance of BABYLON.Scene to append to
  98611. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  98612. * @param onProgress a callback with a progress event for each file being loaded
  98613. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98614. * @param pluginExtension the extension used to determine the plugin
  98615. * @returns The loaded plugin
  98616. */
  98617. 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>;
  98618. /**
  98619. * Import meshes into a scene
  98620. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98621. * @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)
  98622. * @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)
  98623. * @param scene the instance of BABYLON.Scene to append to
  98624. * @param onProgress a callback with a progress event for each file being loaded
  98625. * @param pluginExtension the extension used to determine the plugin
  98626. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  98627. */
  98628. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  98629. meshes: AbstractMesh[];
  98630. particleSystems: IParticleSystem[];
  98631. skeletons: Skeleton[];
  98632. animationGroups: AnimationGroup[];
  98633. }>;
  98634. /**
  98635. * Load a scene
  98636. * @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)
  98637. * @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)
  98638. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98639. * @param onSuccess a callback with the scene when import succeeds
  98640. * @param onProgress a callback with a progress event for each file being loaded
  98641. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98642. * @param pluginExtension the extension used to determine the plugin
  98643. * @returns The loaded plugin
  98644. */
  98645. 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>;
  98646. /**
  98647. * Load a scene
  98648. * @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)
  98649. * @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)
  98650. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98651. * @param onProgress a callback with a progress event for each file being loaded
  98652. * @param pluginExtension the extension used to determine the plugin
  98653. * @returns The loaded scene
  98654. */
  98655. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98656. /**
  98657. * Append a scene
  98658. * @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)
  98659. * @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)
  98660. * @param scene is the instance of BABYLON.Scene to append to
  98661. * @param onSuccess a callback with the scene when import succeeds
  98662. * @param onProgress a callback with a progress event for each file being loaded
  98663. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98664. * @param pluginExtension the extension used to determine the plugin
  98665. * @returns The loaded plugin
  98666. */
  98667. 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>;
  98668. /**
  98669. * Append a scene
  98670. * @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)
  98671. * @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)
  98672. * @param scene is the instance of BABYLON.Scene to append to
  98673. * @param onProgress a callback with a progress event for each file being loaded
  98674. * @param pluginExtension the extension used to determine the plugin
  98675. * @returns The given scene
  98676. */
  98677. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98678. /**
  98679. * Load a scene into an asset container
  98680. * @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)
  98681. * @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)
  98682. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  98683. * @param onSuccess a callback with the scene when import succeeds
  98684. * @param onProgress a callback with a progress event for each file being loaded
  98685. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98686. * @param pluginExtension the extension used to determine the plugin
  98687. * @returns The loaded plugin
  98688. */
  98689. 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>;
  98690. /**
  98691. * Load a scene into an asset container
  98692. * @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)
  98693. * @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)
  98694. * @param scene is the instance of Scene to append to
  98695. * @param onProgress a callback with a progress event for each file being loaded
  98696. * @param pluginExtension the extension used to determine the plugin
  98697. * @returns The loaded asset container
  98698. */
  98699. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  98700. }
  98701. }
  98702. declare module BABYLON {
  98703. /**
  98704. * Google Daydream controller
  98705. */
  98706. export class DaydreamController extends WebVRController {
  98707. /**
  98708. * Base Url for the controller model.
  98709. */
  98710. static MODEL_BASE_URL: string;
  98711. /**
  98712. * File name for the controller model.
  98713. */
  98714. static MODEL_FILENAME: string;
  98715. /**
  98716. * Gamepad Id prefix used to identify Daydream Controller.
  98717. */
  98718. static readonly GAMEPAD_ID_PREFIX: string;
  98719. /**
  98720. * Creates a new DaydreamController from a gamepad
  98721. * @param vrGamepad the gamepad that the controller should be created from
  98722. */
  98723. constructor(vrGamepad: any);
  98724. /**
  98725. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98726. * @param scene scene in which to add meshes
  98727. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98728. */
  98729. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98730. /**
  98731. * Called once for each button that changed state since the last frame
  98732. * @param buttonIdx Which button index changed
  98733. * @param state New state of the button
  98734. * @param changes Which properties on the state changed since last frame
  98735. */
  98736. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98737. }
  98738. }
  98739. declare module BABYLON {
  98740. /**
  98741. * Gear VR Controller
  98742. */
  98743. export class GearVRController extends WebVRController {
  98744. /**
  98745. * Base Url for the controller model.
  98746. */
  98747. static MODEL_BASE_URL: string;
  98748. /**
  98749. * File name for the controller model.
  98750. */
  98751. static MODEL_FILENAME: string;
  98752. /**
  98753. * Gamepad Id prefix used to identify this controller.
  98754. */
  98755. static readonly GAMEPAD_ID_PREFIX: string;
  98756. private readonly _buttonIndexToObservableNameMap;
  98757. /**
  98758. * Creates a new GearVRController from a gamepad
  98759. * @param vrGamepad the gamepad that the controller should be created from
  98760. */
  98761. constructor(vrGamepad: any);
  98762. /**
  98763. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98764. * @param scene scene in which to add meshes
  98765. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98766. */
  98767. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98768. /**
  98769. * Called once for each button that changed state since the last frame
  98770. * @param buttonIdx Which button index changed
  98771. * @param state New state of the button
  98772. * @param changes Which properties on the state changed since last frame
  98773. */
  98774. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98775. }
  98776. }
  98777. declare module BABYLON {
  98778. /**
  98779. * Generic Controller
  98780. */
  98781. export class GenericController extends WebVRController {
  98782. /**
  98783. * Base Url for the controller model.
  98784. */
  98785. static readonly MODEL_BASE_URL: string;
  98786. /**
  98787. * File name for the controller model.
  98788. */
  98789. static readonly MODEL_FILENAME: string;
  98790. /**
  98791. * Creates a new GenericController from a gamepad
  98792. * @param vrGamepad the gamepad that the controller should be created from
  98793. */
  98794. constructor(vrGamepad: any);
  98795. /**
  98796. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98797. * @param scene scene in which to add meshes
  98798. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98799. */
  98800. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98801. /**
  98802. * Called once for each button that changed state since the last frame
  98803. * @param buttonIdx Which button index changed
  98804. * @param state New state of the button
  98805. * @param changes Which properties on the state changed since last frame
  98806. */
  98807. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98808. }
  98809. }
  98810. declare module BABYLON {
  98811. /**
  98812. * Oculus Touch Controller
  98813. */
  98814. export class OculusTouchController extends WebVRController {
  98815. /**
  98816. * Base Url for the controller model.
  98817. */
  98818. static MODEL_BASE_URL: string;
  98819. /**
  98820. * File name for the left controller model.
  98821. */
  98822. static MODEL_LEFT_FILENAME: string;
  98823. /**
  98824. * File name for the right controller model.
  98825. */
  98826. static MODEL_RIGHT_FILENAME: string;
  98827. /**
  98828. * Fired when the secondary trigger on this controller is modified
  98829. */
  98830. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  98831. /**
  98832. * Fired when the thumb rest on this controller is modified
  98833. */
  98834. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  98835. /**
  98836. * Creates a new OculusTouchController from a gamepad
  98837. * @param vrGamepad the gamepad that the controller should be created from
  98838. */
  98839. constructor(vrGamepad: any);
  98840. /**
  98841. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98842. * @param scene scene in which to add meshes
  98843. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98844. */
  98845. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98846. /**
  98847. * Fired when the A button on this controller is modified
  98848. */
  98849. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98850. /**
  98851. * Fired when the B button on this controller is modified
  98852. */
  98853. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98854. /**
  98855. * Fired when the X button on this controller is modified
  98856. */
  98857. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98858. /**
  98859. * Fired when the Y button on this controller is modified
  98860. */
  98861. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98862. /**
  98863. * Called once for each button that changed state since the last frame
  98864. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  98865. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  98866. * 2) secondary trigger (same)
  98867. * 3) A (right) X (left), touch, pressed = value
  98868. * 4) B / Y
  98869. * 5) thumb rest
  98870. * @param buttonIdx Which button index changed
  98871. * @param state New state of the button
  98872. * @param changes Which properties on the state changed since last frame
  98873. */
  98874. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98875. }
  98876. }
  98877. declare module BABYLON {
  98878. /**
  98879. * Vive Controller
  98880. */
  98881. export class ViveController extends WebVRController {
  98882. /**
  98883. * Base Url for the controller model.
  98884. */
  98885. static MODEL_BASE_URL: string;
  98886. /**
  98887. * File name for the controller model.
  98888. */
  98889. static MODEL_FILENAME: string;
  98890. /**
  98891. * Creates a new ViveController from a gamepad
  98892. * @param vrGamepad the gamepad that the controller should be created from
  98893. */
  98894. constructor(vrGamepad: any);
  98895. /**
  98896. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98897. * @param scene scene in which to add meshes
  98898. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98899. */
  98900. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98901. /**
  98902. * Fired when the left button on this controller is modified
  98903. */
  98904. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98905. /**
  98906. * Fired when the right button on this controller is modified
  98907. */
  98908. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98909. /**
  98910. * Fired when the menu button on this controller is modified
  98911. */
  98912. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98913. /**
  98914. * Called once for each button that changed state since the last frame
  98915. * Vive mapping:
  98916. * 0: touchpad
  98917. * 1: trigger
  98918. * 2: left AND right buttons
  98919. * 3: menu button
  98920. * @param buttonIdx Which button index changed
  98921. * @param state New state of the button
  98922. * @param changes Which properties on the state changed since last frame
  98923. */
  98924. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98925. }
  98926. }
  98927. declare module BABYLON {
  98928. /**
  98929. * Defines the WindowsMotionController object that the state of the windows motion controller
  98930. */
  98931. export class WindowsMotionController extends WebVRController {
  98932. /**
  98933. * The base url used to load the left and right controller models
  98934. */
  98935. static MODEL_BASE_URL: string;
  98936. /**
  98937. * The name of the left controller model file
  98938. */
  98939. static MODEL_LEFT_FILENAME: string;
  98940. /**
  98941. * The name of the right controller model file
  98942. */
  98943. static MODEL_RIGHT_FILENAME: string;
  98944. /**
  98945. * The controller name prefix for this controller type
  98946. */
  98947. static readonly GAMEPAD_ID_PREFIX: string;
  98948. /**
  98949. * The controller id pattern for this controller type
  98950. */
  98951. private static readonly GAMEPAD_ID_PATTERN;
  98952. private _loadedMeshInfo;
  98953. private readonly _mapping;
  98954. /**
  98955. * Fired when the trackpad on this controller is clicked
  98956. */
  98957. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  98958. /**
  98959. * Fired when the trackpad on this controller is modified
  98960. */
  98961. onTrackpadValuesChangedObservable: Observable<StickValues>;
  98962. /**
  98963. * The current x and y values of this controller's trackpad
  98964. */
  98965. trackpad: StickValues;
  98966. /**
  98967. * Creates a new WindowsMotionController from a gamepad
  98968. * @param vrGamepad the gamepad that the controller should be created from
  98969. */
  98970. constructor(vrGamepad: any);
  98971. /**
  98972. * Fired when the trigger on this controller is modified
  98973. */
  98974. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98975. /**
  98976. * Fired when the menu button on this controller is modified
  98977. */
  98978. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98979. /**
  98980. * Fired when the grip button on this controller is modified
  98981. */
  98982. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98983. /**
  98984. * Fired when the thumbstick button on this controller is modified
  98985. */
  98986. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98987. /**
  98988. * Fired when the touchpad button on this controller is modified
  98989. */
  98990. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98991. /**
  98992. * Fired when the touchpad values on this controller are modified
  98993. */
  98994. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  98995. private _updateTrackpad;
  98996. /**
  98997. * Called once per frame by the engine.
  98998. */
  98999. update(): void;
  99000. /**
  99001. * Called once for each button that changed state since the last frame
  99002. * @param buttonIdx Which button index changed
  99003. * @param state New state of the button
  99004. * @param changes Which properties on the state changed since last frame
  99005. */
  99006. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99007. /**
  99008. * Moves the buttons on the controller mesh based on their current state
  99009. * @param buttonName the name of the button to move
  99010. * @param buttonValue the value of the button which determines the buttons new position
  99011. */
  99012. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  99013. /**
  99014. * Moves the axis on the controller mesh based on its current state
  99015. * @param axis the index of the axis
  99016. * @param axisValue the value of the axis which determines the meshes new position
  99017. * @hidden
  99018. */
  99019. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  99020. /**
  99021. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99022. * @param scene scene in which to add meshes
  99023. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99024. */
  99025. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  99026. /**
  99027. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  99028. * can be transformed by button presses and axes values, based on this._mapping.
  99029. *
  99030. * @param scene scene in which the meshes exist
  99031. * @param meshes list of meshes that make up the controller model to process
  99032. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  99033. */
  99034. private processModel;
  99035. private createMeshInfo;
  99036. /**
  99037. * Gets the ray of the controller in the direction the controller is pointing
  99038. * @param length the length the resulting ray should be
  99039. * @returns a ray in the direction the controller is pointing
  99040. */
  99041. getForwardRay(length?: number): Ray;
  99042. /**
  99043. * Disposes of the controller
  99044. */
  99045. dispose(): void;
  99046. }
  99047. }
  99048. declare module BABYLON {
  99049. /**
  99050. * Single axis scale gizmo
  99051. */
  99052. export class AxisScaleGizmo extends Gizmo {
  99053. private _coloredMaterial;
  99054. /**
  99055. * Drag behavior responsible for the gizmos dragging interactions
  99056. */
  99057. dragBehavior: PointerDragBehavior;
  99058. private _pointerObserver;
  99059. /**
  99060. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99061. */
  99062. snapDistance: number;
  99063. /**
  99064. * Event that fires each time the gizmo snaps to a new location.
  99065. * * snapDistance is the the change in distance
  99066. */
  99067. onSnapObservable: Observable<{
  99068. snapDistance: number;
  99069. }>;
  99070. /**
  99071. * If the scaling operation should be done on all axis (default: false)
  99072. */
  99073. uniformScaling: boolean;
  99074. /**
  99075. * Creates an AxisScaleGizmo
  99076. * @param gizmoLayer The utility layer the gizmo will be added to
  99077. * @param dragAxis The axis which the gizmo will be able to scale on
  99078. * @param color The color of the gizmo
  99079. */
  99080. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99081. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99082. /**
  99083. * Disposes of the gizmo
  99084. */
  99085. dispose(): void;
  99086. /**
  99087. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  99088. * @param mesh The mesh to replace the default mesh of the gizmo
  99089. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  99090. */
  99091. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  99092. }
  99093. }
  99094. declare module BABYLON {
  99095. /**
  99096. * Bounding box gizmo
  99097. */
  99098. export class BoundingBoxGizmo extends Gizmo {
  99099. private _lineBoundingBox;
  99100. private _rotateSpheresParent;
  99101. private _scaleBoxesParent;
  99102. private _boundingDimensions;
  99103. private _renderObserver;
  99104. private _pointerObserver;
  99105. private _scaleDragSpeed;
  99106. private _tmpQuaternion;
  99107. private _tmpVector;
  99108. private _tmpRotationMatrix;
  99109. /**
  99110. * 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)
  99111. */
  99112. ignoreChildren: boolean;
  99113. /**
  99114. * 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)
  99115. */
  99116. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  99117. /**
  99118. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  99119. */
  99120. rotationSphereSize: number;
  99121. /**
  99122. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  99123. */
  99124. scaleBoxSize: number;
  99125. /**
  99126. * 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)
  99127. */
  99128. fixedDragMeshScreenSize: boolean;
  99129. /**
  99130. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  99131. */
  99132. fixedDragMeshScreenSizeDistanceFactor: number;
  99133. /**
  99134. * Fired when a rotation sphere or scale box is dragged
  99135. */
  99136. onDragStartObservable: Observable<{}>;
  99137. /**
  99138. * Fired when a scale box is dragged
  99139. */
  99140. onScaleBoxDragObservable: Observable<{}>;
  99141. /**
  99142. * Fired when a scale box drag is ended
  99143. */
  99144. onScaleBoxDragEndObservable: Observable<{}>;
  99145. /**
  99146. * Fired when a rotation sphere is dragged
  99147. */
  99148. onRotationSphereDragObservable: Observable<{}>;
  99149. /**
  99150. * Fired when a rotation sphere drag is ended
  99151. */
  99152. onRotationSphereDragEndObservable: Observable<{}>;
  99153. /**
  99154. * 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)
  99155. */
  99156. scalePivot: Nullable<Vector3>;
  99157. private _anchorMesh;
  99158. private _existingMeshScale;
  99159. private _dragMesh;
  99160. private pointerDragBehavior;
  99161. private coloredMaterial;
  99162. private hoverColoredMaterial;
  99163. /**
  99164. * Sets the color of the bounding box gizmo
  99165. * @param color the color to set
  99166. */
  99167. setColor(color: Color3): void;
  99168. /**
  99169. * Creates an BoundingBoxGizmo
  99170. * @param gizmoLayer The utility layer the gizmo will be added to
  99171. * @param color The color of the gizmo
  99172. */
  99173. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99174. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99175. private _selectNode;
  99176. /**
  99177. * Updates the bounding box information for the Gizmo
  99178. */
  99179. updateBoundingBox(): void;
  99180. private _updateRotationSpheres;
  99181. private _updateScaleBoxes;
  99182. /**
  99183. * Enables rotation on the specified axis and disables rotation on the others
  99184. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  99185. */
  99186. setEnabledRotationAxis(axis: string): void;
  99187. /**
  99188. * Enables/disables scaling
  99189. * @param enable if scaling should be enabled
  99190. */
  99191. setEnabledScaling(enable: boolean): void;
  99192. private _updateDummy;
  99193. /**
  99194. * Enables a pointer drag behavior on the bounding box of the gizmo
  99195. */
  99196. enableDragBehavior(): void;
  99197. /**
  99198. * Disposes of the gizmo
  99199. */
  99200. dispose(): void;
  99201. /**
  99202. * 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)
  99203. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  99204. * @returns the bounding box mesh with the passed in mesh as a child
  99205. */
  99206. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  99207. /**
  99208. * CustomMeshes are not supported by this gizmo
  99209. * @param mesh The mesh to replace the default mesh of the gizmo
  99210. */
  99211. setCustomMesh(mesh: Mesh): void;
  99212. }
  99213. }
  99214. declare module BABYLON {
  99215. /**
  99216. * Single plane rotation gizmo
  99217. */
  99218. export class PlaneRotationGizmo extends Gizmo {
  99219. /**
  99220. * Drag behavior responsible for the gizmos dragging interactions
  99221. */
  99222. dragBehavior: PointerDragBehavior;
  99223. private _pointerObserver;
  99224. /**
  99225. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  99226. */
  99227. snapDistance: number;
  99228. /**
  99229. * Event that fires each time the gizmo snaps to a new location.
  99230. * * snapDistance is the the change in distance
  99231. */
  99232. onSnapObservable: Observable<{
  99233. snapDistance: number;
  99234. }>;
  99235. /**
  99236. * Creates a PlaneRotationGizmo
  99237. * @param gizmoLayer The utility layer the gizmo will be added to
  99238. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  99239. * @param color The color of the gizmo
  99240. * @param tessellation Amount of tessellation to be used when creating rotation circles
  99241. */
  99242. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  99243. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99244. /**
  99245. * Disposes of the gizmo
  99246. */
  99247. dispose(): void;
  99248. }
  99249. }
  99250. declare module BABYLON {
  99251. /**
  99252. * Gizmo that enables rotating a mesh along 3 axis
  99253. */
  99254. export class RotationGizmo extends Gizmo {
  99255. /**
  99256. * Internal gizmo used for interactions on the x axis
  99257. */
  99258. xGizmo: PlaneRotationGizmo;
  99259. /**
  99260. * Internal gizmo used for interactions on the y axis
  99261. */
  99262. yGizmo: PlaneRotationGizmo;
  99263. /**
  99264. * Internal gizmo used for interactions on the z axis
  99265. */
  99266. zGizmo: PlaneRotationGizmo;
  99267. /** Fires an event when any of it's sub gizmos are dragged */
  99268. onDragStartObservable: Observable<{}>;
  99269. /** Fires an event when any of it's sub gizmos are released from dragging */
  99270. onDragEndObservable: Observable<{}>;
  99271. attachedMesh: Nullable<AbstractMesh>;
  99272. /**
  99273. * Creates a RotationGizmo
  99274. * @param gizmoLayer The utility layer the gizmo will be added to
  99275. * @param tessellation Amount of tessellation to be used when creating rotation circles
  99276. */
  99277. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  99278. updateGizmoRotationToMatchAttachedMesh: boolean;
  99279. /**
  99280. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99281. */
  99282. snapDistance: number;
  99283. /**
  99284. * Ratio for the scale of the gizmo (Default: 1)
  99285. */
  99286. scaleRatio: number;
  99287. /**
  99288. * Disposes of the gizmo
  99289. */
  99290. dispose(): void;
  99291. /**
  99292. * CustomMeshes are not supported by this gizmo
  99293. * @param mesh The mesh to replace the default mesh of the gizmo
  99294. */
  99295. setCustomMesh(mesh: Mesh): void;
  99296. }
  99297. }
  99298. declare module BABYLON {
  99299. /**
  99300. * Gizmo that enables dragging a mesh along 3 axis
  99301. */
  99302. export class PositionGizmo extends Gizmo {
  99303. /**
  99304. * Internal gizmo used for interactions on the x axis
  99305. */
  99306. xGizmo: AxisDragGizmo;
  99307. /**
  99308. * Internal gizmo used for interactions on the y axis
  99309. */
  99310. yGizmo: AxisDragGizmo;
  99311. /**
  99312. * Internal gizmo used for interactions on the z axis
  99313. */
  99314. zGizmo: AxisDragGizmo;
  99315. /** Fires an event when any of it's sub gizmos are dragged */
  99316. onDragStartObservable: Observable<{}>;
  99317. /** Fires an event when any of it's sub gizmos are released from dragging */
  99318. onDragEndObservable: Observable<{}>;
  99319. attachedMesh: Nullable<AbstractMesh>;
  99320. /**
  99321. * Creates a PositionGizmo
  99322. * @param gizmoLayer The utility layer the gizmo will be added to
  99323. */
  99324. constructor(gizmoLayer?: UtilityLayerRenderer);
  99325. updateGizmoRotationToMatchAttachedMesh: boolean;
  99326. /**
  99327. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99328. */
  99329. snapDistance: number;
  99330. /**
  99331. * Ratio for the scale of the gizmo (Default: 1)
  99332. */
  99333. scaleRatio: number;
  99334. /**
  99335. * Disposes of the gizmo
  99336. */
  99337. dispose(): void;
  99338. /**
  99339. * CustomMeshes are not supported by this gizmo
  99340. * @param mesh The mesh to replace the default mesh of the gizmo
  99341. */
  99342. setCustomMesh(mesh: Mesh): void;
  99343. }
  99344. }
  99345. declare module BABYLON {
  99346. /**
  99347. * Class containing static functions to help procedurally build meshes
  99348. */
  99349. export class PolyhedronBuilder {
  99350. /**
  99351. * Creates a polyhedron mesh
  99352. * * 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
  99353. * * The parameter `size` (positive float, default 1) sets the polygon size
  99354. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  99355. * * 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`
  99356. * * 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
  99357. * * 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)`)
  99358. * * 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
  99359. * * 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
  99360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99361. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99363. * @param name defines the name of the mesh
  99364. * @param options defines the options used to create the mesh
  99365. * @param scene defines the hosting scene
  99366. * @returns the polyhedron mesh
  99367. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  99368. */
  99369. static CreatePolyhedron(name: string, options: {
  99370. type?: number;
  99371. size?: number;
  99372. sizeX?: number;
  99373. sizeY?: number;
  99374. sizeZ?: number;
  99375. custom?: any;
  99376. faceUV?: Vector4[];
  99377. faceColors?: Color4[];
  99378. flat?: boolean;
  99379. updatable?: boolean;
  99380. sideOrientation?: number;
  99381. frontUVs?: Vector4;
  99382. backUVs?: Vector4;
  99383. }, scene: Scene): Mesh;
  99384. }
  99385. }
  99386. declare module BABYLON {
  99387. /**
  99388. * Gizmo that enables scaling a mesh along 3 axis
  99389. */
  99390. export class ScaleGizmo extends Gizmo {
  99391. /**
  99392. * Internal gizmo used for interactions on the x axis
  99393. */
  99394. xGizmo: AxisScaleGizmo;
  99395. /**
  99396. * Internal gizmo used for interactions on the y axis
  99397. */
  99398. yGizmo: AxisScaleGizmo;
  99399. /**
  99400. * Internal gizmo used for interactions on the z axis
  99401. */
  99402. zGizmo: AxisScaleGizmo;
  99403. /**
  99404. * Internal gizmo used to scale all axis equally
  99405. */
  99406. uniformScaleGizmo: AxisScaleGizmo;
  99407. /** Fires an event when any of it's sub gizmos are dragged */
  99408. onDragStartObservable: Observable<{}>;
  99409. /** Fires an event when any of it's sub gizmos are released from dragging */
  99410. onDragEndObservable: Observable<{}>;
  99411. attachedMesh: Nullable<AbstractMesh>;
  99412. /**
  99413. * Creates a ScaleGizmo
  99414. * @param gizmoLayer The utility layer the gizmo will be added to
  99415. */
  99416. constructor(gizmoLayer?: UtilityLayerRenderer);
  99417. updateGizmoRotationToMatchAttachedMesh: boolean;
  99418. /**
  99419. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99420. */
  99421. snapDistance: number;
  99422. /**
  99423. * Ratio for the scale of the gizmo (Default: 1)
  99424. */
  99425. scaleRatio: number;
  99426. /**
  99427. * Disposes of the gizmo
  99428. */
  99429. dispose(): void;
  99430. }
  99431. }
  99432. declare module BABYLON {
  99433. /**
  99434. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  99435. */
  99436. export class GizmoManager implements IDisposable {
  99437. private scene;
  99438. /**
  99439. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  99440. */
  99441. gizmos: {
  99442. positionGizmo: Nullable<PositionGizmo>;
  99443. rotationGizmo: Nullable<RotationGizmo>;
  99444. scaleGizmo: Nullable<ScaleGizmo>;
  99445. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  99446. };
  99447. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  99448. clearGizmoOnEmptyPointerEvent: boolean;
  99449. /** Fires an event when the manager is attached to a mesh */
  99450. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  99451. private _gizmosEnabled;
  99452. private _pointerObserver;
  99453. private _attachedMesh;
  99454. private _boundingBoxColor;
  99455. private _defaultUtilityLayer;
  99456. private _defaultKeepDepthUtilityLayer;
  99457. /**
  99458. * When bounding box gizmo is enabled, this can be used to track drag/end events
  99459. */
  99460. boundingBoxDragBehavior: SixDofDragBehavior;
  99461. /**
  99462. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  99463. */
  99464. attachableMeshes: Nullable<Array<AbstractMesh>>;
  99465. /**
  99466. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  99467. */
  99468. usePointerToAttachGizmos: boolean;
  99469. /**
  99470. * Instatiates a gizmo manager
  99471. * @param scene the scene to overlay the gizmos on top of
  99472. */
  99473. constructor(scene: Scene);
  99474. /**
  99475. * Attaches a set of gizmos to the specified mesh
  99476. * @param mesh The mesh the gizmo's should be attached to
  99477. */
  99478. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  99479. /**
  99480. * If the position gizmo is enabled
  99481. */
  99482. positionGizmoEnabled: boolean;
  99483. /**
  99484. * If the rotation gizmo is enabled
  99485. */
  99486. rotationGizmoEnabled: boolean;
  99487. /**
  99488. * If the scale gizmo is enabled
  99489. */
  99490. scaleGizmoEnabled: boolean;
  99491. /**
  99492. * If the boundingBox gizmo is enabled
  99493. */
  99494. boundingBoxGizmoEnabled: boolean;
  99495. /**
  99496. * Disposes of the gizmo manager
  99497. */
  99498. dispose(): void;
  99499. }
  99500. }
  99501. declare module BABYLON {
  99502. /**
  99503. * Gizmo that enables viewing a light
  99504. */
  99505. export class LightGizmo extends Gizmo {
  99506. private _box;
  99507. /**
  99508. * Creates a LightGizmo
  99509. * @param gizmoLayer The utility layer the gizmo will be added to
  99510. */
  99511. constructor(gizmoLayer?: UtilityLayerRenderer);
  99512. private _light;
  99513. /**
  99514. * The light that the gizmo is attached to
  99515. */
  99516. light: Nullable<Light>;
  99517. /**
  99518. * @hidden
  99519. * Updates the gizmo to match the attached mesh's position/rotation
  99520. */
  99521. protected _update(): void;
  99522. }
  99523. }
  99524. declare module BABYLON {
  99525. /** @hidden */
  99526. export var backgroundFragmentDeclaration: {
  99527. name: string;
  99528. shader: string;
  99529. };
  99530. }
  99531. declare module BABYLON {
  99532. /** @hidden */
  99533. export var backgroundUboDeclaration: {
  99534. name: string;
  99535. shader: string;
  99536. };
  99537. }
  99538. declare module BABYLON {
  99539. /** @hidden */
  99540. export var backgroundPixelShader: {
  99541. name: string;
  99542. shader: string;
  99543. };
  99544. }
  99545. declare module BABYLON {
  99546. /** @hidden */
  99547. export var backgroundVertexDeclaration: {
  99548. name: string;
  99549. shader: string;
  99550. };
  99551. }
  99552. declare module BABYLON {
  99553. /** @hidden */
  99554. export var backgroundVertexShader: {
  99555. name: string;
  99556. shader: string;
  99557. };
  99558. }
  99559. declare module BABYLON {
  99560. /**
  99561. * Background material used to create an efficient environement around your scene.
  99562. */
  99563. export class BackgroundMaterial extends PushMaterial {
  99564. /**
  99565. * Standard reflectance value at parallel view angle.
  99566. */
  99567. static StandardReflectance0: number;
  99568. /**
  99569. * Standard reflectance value at grazing angle.
  99570. */
  99571. static StandardReflectance90: number;
  99572. protected _primaryColor: Color3;
  99573. /**
  99574. * Key light Color (multiply against the environement texture)
  99575. */
  99576. primaryColor: Color3;
  99577. protected __perceptualColor: Nullable<Color3>;
  99578. /**
  99579. * Experimental Internal Use Only.
  99580. *
  99581. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  99582. * This acts as a helper to set the primary color to a more "human friendly" value.
  99583. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  99584. * output color as close as possible from the chosen value.
  99585. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  99586. * part of lighting setup.)
  99587. */
  99588. _perceptualColor: Nullable<Color3>;
  99589. protected _primaryColorShadowLevel: float;
  99590. /**
  99591. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  99592. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  99593. */
  99594. primaryColorShadowLevel: float;
  99595. protected _primaryColorHighlightLevel: float;
  99596. /**
  99597. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  99598. * The primary color is used at the level chosen to define what the white area would look.
  99599. */
  99600. primaryColorHighlightLevel: float;
  99601. protected _reflectionTexture: Nullable<BaseTexture>;
  99602. /**
  99603. * Reflection Texture used in the material.
  99604. * Should be author in a specific way for the best result (refer to the documentation).
  99605. */
  99606. reflectionTexture: Nullable<BaseTexture>;
  99607. protected _reflectionBlur: float;
  99608. /**
  99609. * Reflection Texture level of blur.
  99610. *
  99611. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  99612. * texture twice.
  99613. */
  99614. reflectionBlur: float;
  99615. protected _diffuseTexture: Nullable<BaseTexture>;
  99616. /**
  99617. * Diffuse Texture used in the material.
  99618. * Should be author in a specific way for the best result (refer to the documentation).
  99619. */
  99620. diffuseTexture: Nullable<BaseTexture>;
  99621. protected _shadowLights: Nullable<IShadowLight[]>;
  99622. /**
  99623. * Specify the list of lights casting shadow on the material.
  99624. * All scene shadow lights will be included if null.
  99625. */
  99626. shadowLights: Nullable<IShadowLight[]>;
  99627. protected _shadowLevel: float;
  99628. /**
  99629. * Helps adjusting the shadow to a softer level if required.
  99630. * 0 means black shadows and 1 means no shadows.
  99631. */
  99632. shadowLevel: float;
  99633. protected _sceneCenter: Vector3;
  99634. /**
  99635. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  99636. * It is usually zero but might be interesting to modify according to your setup.
  99637. */
  99638. sceneCenter: Vector3;
  99639. protected _opacityFresnel: boolean;
  99640. /**
  99641. * This helps specifying that the material is falling off to the sky box at grazing angle.
  99642. * This helps ensuring a nice transition when the camera goes under the ground.
  99643. */
  99644. opacityFresnel: boolean;
  99645. protected _reflectionFresnel: boolean;
  99646. /**
  99647. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  99648. * This helps adding a mirror texture on the ground.
  99649. */
  99650. reflectionFresnel: boolean;
  99651. protected _reflectionFalloffDistance: number;
  99652. /**
  99653. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  99654. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  99655. */
  99656. reflectionFalloffDistance: number;
  99657. protected _reflectionAmount: number;
  99658. /**
  99659. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  99660. */
  99661. reflectionAmount: number;
  99662. protected _reflectionReflectance0: number;
  99663. /**
  99664. * This specifies the weight of the reflection at grazing angle.
  99665. */
  99666. reflectionReflectance0: number;
  99667. protected _reflectionReflectance90: number;
  99668. /**
  99669. * This specifies the weight of the reflection at a perpendicular point of view.
  99670. */
  99671. reflectionReflectance90: number;
  99672. /**
  99673. * Sets the reflection reflectance fresnel values according to the default standard
  99674. * empirically know to work well :-)
  99675. */
  99676. reflectionStandardFresnelWeight: number;
  99677. protected _useRGBColor: boolean;
  99678. /**
  99679. * Helps to directly use the maps channels instead of their level.
  99680. */
  99681. useRGBColor: boolean;
  99682. protected _enableNoise: boolean;
  99683. /**
  99684. * This helps reducing the banding effect that could occur on the background.
  99685. */
  99686. enableNoise: boolean;
  99687. /**
  99688. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99689. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  99690. * Recommended to be keep at 1.0 except for special cases.
  99691. */
  99692. fovMultiplier: number;
  99693. private _fovMultiplier;
  99694. /**
  99695. * Enable the FOV adjustment feature controlled by fovMultiplier.
  99696. */
  99697. useEquirectangularFOV: boolean;
  99698. private _maxSimultaneousLights;
  99699. /**
  99700. * Number of Simultaneous lights allowed on the material.
  99701. */
  99702. maxSimultaneousLights: int;
  99703. /**
  99704. * Default configuration related to image processing available in the Background Material.
  99705. */
  99706. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99707. /**
  99708. * Keep track of the image processing observer to allow dispose and replace.
  99709. */
  99710. private _imageProcessingObserver;
  99711. /**
  99712. * Attaches a new image processing configuration to the PBR Material.
  99713. * @param configuration (if null the scene configuration will be use)
  99714. */
  99715. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99716. /**
  99717. * Gets the image processing configuration used either in this material.
  99718. */
  99719. /**
  99720. * Sets the Default image processing configuration used either in the this material.
  99721. *
  99722. * If sets to null, the scene one is in use.
  99723. */
  99724. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  99725. /**
  99726. * Gets wether the color curves effect is enabled.
  99727. */
  99728. /**
  99729. * Sets wether the color curves effect is enabled.
  99730. */
  99731. cameraColorCurvesEnabled: boolean;
  99732. /**
  99733. * Gets wether the color grading effect is enabled.
  99734. */
  99735. /**
  99736. * Gets wether the color grading effect is enabled.
  99737. */
  99738. cameraColorGradingEnabled: boolean;
  99739. /**
  99740. * Gets wether tonemapping is enabled or not.
  99741. */
  99742. /**
  99743. * Sets wether tonemapping is enabled or not
  99744. */
  99745. cameraToneMappingEnabled: boolean;
  99746. /**
  99747. * The camera exposure used on this material.
  99748. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99749. * This corresponds to a photographic exposure.
  99750. */
  99751. /**
  99752. * The camera exposure used on this material.
  99753. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99754. * This corresponds to a photographic exposure.
  99755. */
  99756. cameraExposure: float;
  99757. /**
  99758. * Gets The camera contrast used on this material.
  99759. */
  99760. /**
  99761. * Sets The camera contrast used on this material.
  99762. */
  99763. cameraContrast: float;
  99764. /**
  99765. * Gets the Color Grading 2D Lookup Texture.
  99766. */
  99767. /**
  99768. * Sets the Color Grading 2D Lookup Texture.
  99769. */
  99770. cameraColorGradingTexture: Nullable<BaseTexture>;
  99771. /**
  99772. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99773. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99774. * 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;
  99775. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99776. */
  99777. /**
  99778. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99779. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99780. * 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;
  99781. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99782. */
  99783. cameraColorCurves: Nullable<ColorCurves>;
  99784. /**
  99785. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  99786. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  99787. */
  99788. switchToBGR: boolean;
  99789. private _renderTargets;
  99790. private _reflectionControls;
  99791. private _white;
  99792. private _primaryShadowColor;
  99793. private _primaryHighlightColor;
  99794. /**
  99795. * Instantiates a Background Material in the given scene
  99796. * @param name The friendly name of the material
  99797. * @param scene The scene to add the material to
  99798. */
  99799. constructor(name: string, scene: Scene);
  99800. /**
  99801. * Gets a boolean indicating that current material needs to register RTT
  99802. */
  99803. readonly hasRenderTargetTextures: boolean;
  99804. /**
  99805. * The entire material has been created in order to prevent overdraw.
  99806. * @returns false
  99807. */
  99808. needAlphaTesting(): boolean;
  99809. /**
  99810. * The entire material has been created in order to prevent overdraw.
  99811. * @returns true if blending is enable
  99812. */
  99813. needAlphaBlending(): boolean;
  99814. /**
  99815. * Checks wether the material is ready to be rendered for a given mesh.
  99816. * @param mesh The mesh to render
  99817. * @param subMesh The submesh to check against
  99818. * @param useInstances Specify wether or not the material is used with instances
  99819. * @returns true if all the dependencies are ready (Textures, Effects...)
  99820. */
  99821. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99822. /**
  99823. * Compute the primary color according to the chosen perceptual color.
  99824. */
  99825. private _computePrimaryColorFromPerceptualColor;
  99826. /**
  99827. * Compute the highlights and shadow colors according to their chosen levels.
  99828. */
  99829. private _computePrimaryColors;
  99830. /**
  99831. * Build the uniform buffer used in the material.
  99832. */
  99833. buildUniformLayout(): void;
  99834. /**
  99835. * Unbind the material.
  99836. */
  99837. unbind(): void;
  99838. /**
  99839. * Bind only the world matrix to the material.
  99840. * @param world The world matrix to bind.
  99841. */
  99842. bindOnlyWorldMatrix(world: Matrix): void;
  99843. /**
  99844. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  99845. * @param world The world matrix to bind.
  99846. * @param subMesh The submesh to bind for.
  99847. */
  99848. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99849. /**
  99850. * Dispose the material.
  99851. * @param forceDisposeEffect Force disposal of the associated effect.
  99852. * @param forceDisposeTextures Force disposal of the associated textures.
  99853. */
  99854. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99855. /**
  99856. * Clones the material.
  99857. * @param name The cloned name.
  99858. * @returns The cloned material.
  99859. */
  99860. clone(name: string): BackgroundMaterial;
  99861. /**
  99862. * Serializes the current material to its JSON representation.
  99863. * @returns The JSON representation.
  99864. */
  99865. serialize(): any;
  99866. /**
  99867. * Gets the class name of the material
  99868. * @returns "BackgroundMaterial"
  99869. */
  99870. getClassName(): string;
  99871. /**
  99872. * Parse a JSON input to create back a background material.
  99873. * @param source The JSON data to parse
  99874. * @param scene The scene to create the parsed material in
  99875. * @param rootUrl The root url of the assets the material depends upon
  99876. * @returns the instantiated BackgroundMaterial.
  99877. */
  99878. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  99879. }
  99880. }
  99881. declare module BABYLON {
  99882. /**
  99883. * Represents the different options available during the creation of
  99884. * a Environment helper.
  99885. *
  99886. * This can control the default ground, skybox and image processing setup of your scene.
  99887. */
  99888. export interface IEnvironmentHelperOptions {
  99889. /**
  99890. * Specifies wether or not to create a ground.
  99891. * True by default.
  99892. */
  99893. createGround: boolean;
  99894. /**
  99895. * Specifies the ground size.
  99896. * 15 by default.
  99897. */
  99898. groundSize: number;
  99899. /**
  99900. * The texture used on the ground for the main color.
  99901. * Comes from the BabylonJS CDN by default.
  99902. *
  99903. * Remarks: Can be either a texture or a url.
  99904. */
  99905. groundTexture: string | BaseTexture;
  99906. /**
  99907. * The color mixed in the ground texture by default.
  99908. * BabylonJS clearColor by default.
  99909. */
  99910. groundColor: Color3;
  99911. /**
  99912. * Specifies the ground opacity.
  99913. * 1 by default.
  99914. */
  99915. groundOpacity: number;
  99916. /**
  99917. * Enables the ground to receive shadows.
  99918. * True by default.
  99919. */
  99920. enableGroundShadow: boolean;
  99921. /**
  99922. * Helps preventing the shadow to be fully black on the ground.
  99923. * 0.5 by default.
  99924. */
  99925. groundShadowLevel: number;
  99926. /**
  99927. * Creates a mirror texture attach to the ground.
  99928. * false by default.
  99929. */
  99930. enableGroundMirror: boolean;
  99931. /**
  99932. * Specifies the ground mirror size ratio.
  99933. * 0.3 by default as the default kernel is 64.
  99934. */
  99935. groundMirrorSizeRatio: number;
  99936. /**
  99937. * Specifies the ground mirror blur kernel size.
  99938. * 64 by default.
  99939. */
  99940. groundMirrorBlurKernel: number;
  99941. /**
  99942. * Specifies the ground mirror visibility amount.
  99943. * 1 by default
  99944. */
  99945. groundMirrorAmount: number;
  99946. /**
  99947. * Specifies the ground mirror reflectance weight.
  99948. * This uses the standard weight of the background material to setup the fresnel effect
  99949. * of the mirror.
  99950. * 1 by default.
  99951. */
  99952. groundMirrorFresnelWeight: number;
  99953. /**
  99954. * Specifies the ground mirror Falloff distance.
  99955. * This can helps reducing the size of the reflection.
  99956. * 0 by Default.
  99957. */
  99958. groundMirrorFallOffDistance: number;
  99959. /**
  99960. * Specifies the ground mirror texture type.
  99961. * Unsigned Int by Default.
  99962. */
  99963. groundMirrorTextureType: number;
  99964. /**
  99965. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  99966. * the shown objects.
  99967. */
  99968. groundYBias: number;
  99969. /**
  99970. * Specifies wether or not to create a skybox.
  99971. * True by default.
  99972. */
  99973. createSkybox: boolean;
  99974. /**
  99975. * Specifies the skybox size.
  99976. * 20 by default.
  99977. */
  99978. skyboxSize: number;
  99979. /**
  99980. * The texture used on the skybox for the main color.
  99981. * Comes from the BabylonJS CDN by default.
  99982. *
  99983. * Remarks: Can be either a texture or a url.
  99984. */
  99985. skyboxTexture: string | BaseTexture;
  99986. /**
  99987. * The color mixed in the skybox texture by default.
  99988. * BabylonJS clearColor by default.
  99989. */
  99990. skyboxColor: Color3;
  99991. /**
  99992. * The background rotation around the Y axis of the scene.
  99993. * This helps aligning the key lights of your scene with the background.
  99994. * 0 by default.
  99995. */
  99996. backgroundYRotation: number;
  99997. /**
  99998. * Compute automatically the size of the elements to best fit with the scene.
  99999. */
  100000. sizeAuto: boolean;
  100001. /**
  100002. * Default position of the rootMesh if autoSize is not true.
  100003. */
  100004. rootPosition: Vector3;
  100005. /**
  100006. * Sets up the image processing in the scene.
  100007. * true by default.
  100008. */
  100009. setupImageProcessing: boolean;
  100010. /**
  100011. * The texture used as your environment texture in the scene.
  100012. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  100013. *
  100014. * Remarks: Can be either a texture or a url.
  100015. */
  100016. environmentTexture: string | BaseTexture;
  100017. /**
  100018. * The value of the exposure to apply to the scene.
  100019. * 0.6 by default if setupImageProcessing is true.
  100020. */
  100021. cameraExposure: number;
  100022. /**
  100023. * The value of the contrast to apply to the scene.
  100024. * 1.6 by default if setupImageProcessing is true.
  100025. */
  100026. cameraContrast: number;
  100027. /**
  100028. * Specifies wether or not tonemapping should be enabled in the scene.
  100029. * true by default if setupImageProcessing is true.
  100030. */
  100031. toneMappingEnabled: boolean;
  100032. }
  100033. /**
  100034. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  100035. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  100036. * It also helps with the default setup of your imageProcessing configuration.
  100037. */
  100038. export class EnvironmentHelper {
  100039. /**
  100040. * Default ground texture URL.
  100041. */
  100042. private static _groundTextureCDNUrl;
  100043. /**
  100044. * Default skybox texture URL.
  100045. */
  100046. private static _skyboxTextureCDNUrl;
  100047. /**
  100048. * Default environment texture URL.
  100049. */
  100050. private static _environmentTextureCDNUrl;
  100051. /**
  100052. * Creates the default options for the helper.
  100053. */
  100054. private static _getDefaultOptions;
  100055. private _rootMesh;
  100056. /**
  100057. * Gets the root mesh created by the helper.
  100058. */
  100059. readonly rootMesh: Mesh;
  100060. private _skybox;
  100061. /**
  100062. * Gets the skybox created by the helper.
  100063. */
  100064. readonly skybox: Nullable<Mesh>;
  100065. private _skyboxTexture;
  100066. /**
  100067. * Gets the skybox texture created by the helper.
  100068. */
  100069. readonly skyboxTexture: Nullable<BaseTexture>;
  100070. private _skyboxMaterial;
  100071. /**
  100072. * Gets the skybox material created by the helper.
  100073. */
  100074. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  100075. private _ground;
  100076. /**
  100077. * Gets the ground mesh created by the helper.
  100078. */
  100079. readonly ground: Nullable<Mesh>;
  100080. private _groundTexture;
  100081. /**
  100082. * Gets the ground texture created by the helper.
  100083. */
  100084. readonly groundTexture: Nullable<BaseTexture>;
  100085. private _groundMirror;
  100086. /**
  100087. * Gets the ground mirror created by the helper.
  100088. */
  100089. readonly groundMirror: Nullable<MirrorTexture>;
  100090. /**
  100091. * Gets the ground mirror render list to helps pushing the meshes
  100092. * you wish in the ground reflection.
  100093. */
  100094. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  100095. private _groundMaterial;
  100096. /**
  100097. * Gets the ground material created by the helper.
  100098. */
  100099. readonly groundMaterial: Nullable<BackgroundMaterial>;
  100100. /**
  100101. * Stores the creation options.
  100102. */
  100103. private readonly _scene;
  100104. private _options;
  100105. /**
  100106. * This observable will be notified with any error during the creation of the environment,
  100107. * mainly texture creation errors.
  100108. */
  100109. onErrorObservable: Observable<{
  100110. message?: string;
  100111. exception?: any;
  100112. }>;
  100113. /**
  100114. * constructor
  100115. * @param options Defines the options we want to customize the helper
  100116. * @param scene The scene to add the material to
  100117. */
  100118. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  100119. /**
  100120. * Updates the background according to the new options
  100121. * @param options
  100122. */
  100123. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  100124. /**
  100125. * Sets the primary color of all the available elements.
  100126. * @param color the main color to affect to the ground and the background
  100127. */
  100128. setMainColor(color: Color3): void;
  100129. /**
  100130. * Setup the image processing according to the specified options.
  100131. */
  100132. private _setupImageProcessing;
  100133. /**
  100134. * Setup the environment texture according to the specified options.
  100135. */
  100136. private _setupEnvironmentTexture;
  100137. /**
  100138. * Setup the background according to the specified options.
  100139. */
  100140. private _setupBackground;
  100141. /**
  100142. * Get the scene sizes according to the setup.
  100143. */
  100144. private _getSceneSize;
  100145. /**
  100146. * Setup the ground according to the specified options.
  100147. */
  100148. private _setupGround;
  100149. /**
  100150. * Setup the ground material according to the specified options.
  100151. */
  100152. private _setupGroundMaterial;
  100153. /**
  100154. * Setup the ground diffuse texture according to the specified options.
  100155. */
  100156. private _setupGroundDiffuseTexture;
  100157. /**
  100158. * Setup the ground mirror texture according to the specified options.
  100159. */
  100160. private _setupGroundMirrorTexture;
  100161. /**
  100162. * Setup the ground to receive the mirror texture.
  100163. */
  100164. private _setupMirrorInGroundMaterial;
  100165. /**
  100166. * Setup the skybox according to the specified options.
  100167. */
  100168. private _setupSkybox;
  100169. /**
  100170. * Setup the skybox material according to the specified options.
  100171. */
  100172. private _setupSkyboxMaterial;
  100173. /**
  100174. * Setup the skybox reflection texture according to the specified options.
  100175. */
  100176. private _setupSkyboxReflectionTexture;
  100177. private _errorHandler;
  100178. /**
  100179. * Dispose all the elements created by the Helper.
  100180. */
  100181. dispose(): void;
  100182. }
  100183. }
  100184. declare module BABYLON {
  100185. /**
  100186. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  100187. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  100188. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  100189. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  100190. */
  100191. export class PhotoDome extends TransformNode {
  100192. private _useDirectMapping;
  100193. /**
  100194. * The texture being displayed on the sphere
  100195. */
  100196. protected _photoTexture: Texture;
  100197. /**
  100198. * Gets or sets the texture being displayed on the sphere
  100199. */
  100200. photoTexture: Texture;
  100201. /**
  100202. * Observable raised when an error occured while loading the 360 image
  100203. */
  100204. onLoadErrorObservable: Observable<string>;
  100205. /**
  100206. * The skybox material
  100207. */
  100208. protected _material: BackgroundMaterial;
  100209. /**
  100210. * The surface used for the skybox
  100211. */
  100212. protected _mesh: Mesh;
  100213. /**
  100214. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  100215. * Also see the options.resolution property.
  100216. */
  100217. fovMultiplier: number;
  100218. /**
  100219. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  100220. * @param name Element's name, child elements will append suffixes for their own names.
  100221. * @param urlsOfPhoto defines the url of the photo to display
  100222. * @param options defines an object containing optional or exposed sub element properties
  100223. * @param onError defines a callback called when an error occured while loading the texture
  100224. */
  100225. constructor(name: string, urlOfPhoto: string, options: {
  100226. resolution?: number;
  100227. size?: number;
  100228. useDirectMapping?: boolean;
  100229. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  100230. /**
  100231. * Releases resources associated with this node.
  100232. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100233. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100234. */
  100235. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100236. }
  100237. }
  100238. declare module BABYLON {
  100239. /**
  100240. * Class used to host texture specific utilities
  100241. */
  100242. export class TextureTools {
  100243. /**
  100244. * Uses the GPU to create a copy texture rescaled at a given size
  100245. * @param texture Texture to copy from
  100246. * @param width defines the desired width
  100247. * @param height defines the desired height
  100248. * @param useBilinearMode defines if bilinear mode has to be used
  100249. * @return the generated texture
  100250. */
  100251. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  100252. /**
  100253. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  100254. * @param scene defines the hosting scene
  100255. * @returns the environment BRDF texture
  100256. */
  100257. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  100258. private static _environmentBRDFBase64Texture;
  100259. }
  100260. }
  100261. declare module BABYLON {
  100262. /**
  100263. * @hidden
  100264. */
  100265. export interface IMaterialClearCoatDefines {
  100266. CLEARCOAT: boolean;
  100267. CLEARCOAT_DEFAULTIOR: boolean;
  100268. CLEARCOAT_TEXTURE: boolean;
  100269. CLEARCOAT_TEXTUREDIRECTUV: number;
  100270. CLEARCOAT_BUMP: boolean;
  100271. CLEARCOAT_BUMPDIRECTUV: number;
  100272. CLEARCOAT_TINT: boolean;
  100273. CLEARCOAT_TINT_TEXTURE: boolean;
  100274. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  100275. /** @hidden */
  100276. _areTexturesDirty: boolean;
  100277. }
  100278. /**
  100279. * Define the code related to the clear coat parameters of the pbr material.
  100280. */
  100281. export class PBRClearCoatConfiguration {
  100282. /**
  100283. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100284. * The default fits with a polyurethane material.
  100285. */
  100286. private static readonly _DefaultIndiceOfRefraction;
  100287. private _isEnabled;
  100288. /**
  100289. * Defines if the clear coat is enabled in the material.
  100290. */
  100291. isEnabled: boolean;
  100292. /**
  100293. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  100294. */
  100295. intensity: number;
  100296. /**
  100297. * Defines the clear coat layer roughness.
  100298. */
  100299. roughness: number;
  100300. private _indiceOfRefraction;
  100301. /**
  100302. * Defines the indice of refraction of the clear coat.
  100303. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100304. * The default fits with a polyurethane material.
  100305. * Changing the default value is more performance intensive.
  100306. */
  100307. indiceOfRefraction: number;
  100308. private _texture;
  100309. /**
  100310. * Stores the clear coat values in a texture.
  100311. */
  100312. texture: Nullable<BaseTexture>;
  100313. private _bumpTexture;
  100314. /**
  100315. * Define the clear coat specific bump texture.
  100316. */
  100317. bumpTexture: Nullable<BaseTexture>;
  100318. private _isTintEnabled;
  100319. /**
  100320. * Defines if the clear coat tint is enabled in the material.
  100321. */
  100322. isTintEnabled: boolean;
  100323. /**
  100324. * Defines if the clear coat tint is enabled in the material.
  100325. * This is only use if tint is enabled
  100326. */
  100327. tintColor: Color3;
  100328. /**
  100329. * Defines if the distance at which the tint color should be found in the
  100330. * clear coat media.
  100331. * This is only use if tint is enabled
  100332. */
  100333. tintColorAtDistance: number;
  100334. /**
  100335. * Defines the clear coat layer thickness.
  100336. * This is only use if tint is enabled
  100337. */
  100338. tintThickness: number;
  100339. private _tintTexture;
  100340. /**
  100341. * Stores the clear tint values in a texture.
  100342. * rgb is tint
  100343. * a is a thickness factor
  100344. */
  100345. tintTexture: Nullable<BaseTexture>;
  100346. /** @hidden */
  100347. private _internalMarkAllSubMeshesAsTexturesDirty;
  100348. /** @hidden */
  100349. _markAllSubMeshesAsTexturesDirty(): void;
  100350. /**
  100351. * Instantiate a new istance of clear coat configuration.
  100352. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100353. */
  100354. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100355. /**
  100356. * Specifies that the submesh is ready to be used.
  100357. * @param defines the list of "defines" to update.
  100358. * @param scene defines the scene the material belongs to.
  100359. * @param engine defines the engine the material belongs to.
  100360. * @param disableBumpMap defines wether the material disables bump or not.
  100361. * @returns - boolean indicating that the submesh is ready or not.
  100362. */
  100363. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  100364. /**
  100365. * Checks to see if a texture is used in the material.
  100366. * @param defines the list of "defines" to update.
  100367. * @param scene defines the scene to the material belongs to.
  100368. */
  100369. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  100370. /**
  100371. * Binds the material data.
  100372. * @param uniformBuffer defines the Uniform buffer to fill in.
  100373. * @param scene defines the scene the material belongs to.
  100374. * @param engine defines the engine the material belongs to.
  100375. * @param disableBumpMap defines wether the material disables bump or not.
  100376. * @param isFrozen defines wether the material is frozen or not.
  100377. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  100378. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  100379. */
  100380. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  100381. /**
  100382. * Checks to see if a texture is used in the material.
  100383. * @param texture - Base texture to use.
  100384. * @returns - Boolean specifying if a texture is used in the material.
  100385. */
  100386. hasTexture(texture: BaseTexture): boolean;
  100387. /**
  100388. * Returns an array of the actively used textures.
  100389. * @param activeTextures Array of BaseTextures
  100390. */
  100391. getActiveTextures(activeTextures: BaseTexture[]): void;
  100392. /**
  100393. * Returns the animatable textures.
  100394. * @param animatables Array of animatable textures.
  100395. */
  100396. getAnimatables(animatables: IAnimatable[]): void;
  100397. /**
  100398. * Disposes the resources of the material.
  100399. * @param forceDisposeTextures - Forces the disposal of all textures.
  100400. */
  100401. dispose(forceDisposeTextures?: boolean): void;
  100402. /**
  100403. * Get the current class name of the texture useful for serialization or dynamic coding.
  100404. * @returns "PBRClearCoatConfiguration"
  100405. */
  100406. getClassName(): string;
  100407. /**
  100408. * Add fallbacks to the effect fallbacks list.
  100409. * @param defines defines the Base texture to use.
  100410. * @param fallbacks defines the current fallback list.
  100411. * @param currentRank defines the current fallback rank.
  100412. * @returns the new fallback rank.
  100413. */
  100414. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100415. /**
  100416. * Add the required uniforms to the current list.
  100417. * @param uniforms defines the current uniform list.
  100418. */
  100419. static AddUniforms(uniforms: string[]): void;
  100420. /**
  100421. * Add the required samplers to the current list.
  100422. * @param samplers defines the current sampler list.
  100423. */
  100424. static AddSamplers(samplers: string[]): void;
  100425. /**
  100426. * Add the required uniforms to the current buffer.
  100427. * @param uniformBuffer defines the current uniform buffer.
  100428. */
  100429. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100430. /**
  100431. * Makes a duplicate of the current configuration into another one.
  100432. * @param clearCoatConfiguration define the config where to copy the info
  100433. */
  100434. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  100435. /**
  100436. * Serializes this clear coat configuration.
  100437. * @returns - An object with the serialized config.
  100438. */
  100439. serialize(): any;
  100440. /**
  100441. * Parses a Clear Coat Configuration from a serialized object.
  100442. * @param source - Serialized object.
  100443. */
  100444. parse(source: any): void;
  100445. }
  100446. }
  100447. declare module BABYLON {
  100448. /**
  100449. * @hidden
  100450. */
  100451. export interface IMaterialAnisotropicDefines {
  100452. ANISOTROPIC: boolean;
  100453. ANISOTROPIC_TEXTURE: boolean;
  100454. ANISOTROPIC_TEXTUREDIRECTUV: number;
  100455. MAINUV1: boolean;
  100456. _areTexturesDirty: boolean;
  100457. _needUVs: boolean;
  100458. }
  100459. /**
  100460. * Define the code related to the anisotropic parameters of the pbr material.
  100461. */
  100462. export class PBRAnisotropicConfiguration {
  100463. private _isEnabled;
  100464. /**
  100465. * Defines if the anisotropy is enabled in the material.
  100466. */
  100467. isEnabled: boolean;
  100468. /**
  100469. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  100470. */
  100471. intensity: number;
  100472. /**
  100473. * Defines if the effect is along the tangents, bitangents or in between.
  100474. * By default, the effect is "strectching" the highlights along the tangents.
  100475. */
  100476. direction: Vector2;
  100477. private _texture;
  100478. /**
  100479. * Stores the anisotropy values in a texture.
  100480. * rg is direction (like normal from -1 to 1)
  100481. * b is a intensity
  100482. */
  100483. texture: Nullable<BaseTexture>;
  100484. /** @hidden */
  100485. private _internalMarkAllSubMeshesAsTexturesDirty;
  100486. /** @hidden */
  100487. _markAllSubMeshesAsTexturesDirty(): void;
  100488. /**
  100489. * Instantiate a new istance of anisotropy configuration.
  100490. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100491. */
  100492. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100493. /**
  100494. * Specifies that the submesh is ready to be used.
  100495. * @param defines the list of "defines" to update.
  100496. * @param scene defines the scene the material belongs to.
  100497. * @returns - boolean indicating that the submesh is ready or not.
  100498. */
  100499. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  100500. /**
  100501. * Checks to see if a texture is used in the material.
  100502. * @param defines the list of "defines" to update.
  100503. * @param mesh the mesh we are preparing the defines for.
  100504. * @param scene defines the scene the material belongs to.
  100505. */
  100506. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  100507. /**
  100508. * Binds the material data.
  100509. * @param uniformBuffer defines the Uniform buffer to fill in.
  100510. * @param scene defines the scene the material belongs to.
  100511. * @param isFrozen defines wether the material is frozen or not.
  100512. */
  100513. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  100514. /**
  100515. * Checks to see if a texture is used in the material.
  100516. * @param texture - Base texture to use.
  100517. * @returns - Boolean specifying if a texture is used in the material.
  100518. */
  100519. hasTexture(texture: BaseTexture): boolean;
  100520. /**
  100521. * Returns an array of the actively used textures.
  100522. * @param activeTextures Array of BaseTextures
  100523. */
  100524. getActiveTextures(activeTextures: BaseTexture[]): void;
  100525. /**
  100526. * Returns the animatable textures.
  100527. * @param animatables Array of animatable textures.
  100528. */
  100529. getAnimatables(animatables: IAnimatable[]): void;
  100530. /**
  100531. * Disposes the resources of the material.
  100532. * @param forceDisposeTextures - Forces the disposal of all textures.
  100533. */
  100534. dispose(forceDisposeTextures?: boolean): void;
  100535. /**
  100536. * Get the current class name of the texture useful for serialization or dynamic coding.
  100537. * @returns "PBRAnisotropicConfiguration"
  100538. */
  100539. getClassName(): string;
  100540. /**
  100541. * Add fallbacks to the effect fallbacks list.
  100542. * @param defines defines the Base texture to use.
  100543. * @param fallbacks defines the current fallback list.
  100544. * @param currentRank defines the current fallback rank.
  100545. * @returns the new fallback rank.
  100546. */
  100547. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100548. /**
  100549. * Add the required uniforms to the current list.
  100550. * @param uniforms defines the current uniform list.
  100551. */
  100552. static AddUniforms(uniforms: string[]): void;
  100553. /**
  100554. * Add the required uniforms to the current buffer.
  100555. * @param uniformBuffer defines the current uniform buffer.
  100556. */
  100557. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100558. /**
  100559. * Add the required samplers to the current list.
  100560. * @param samplers defines the current sampler list.
  100561. */
  100562. static AddSamplers(samplers: string[]): void;
  100563. /**
  100564. * Makes a duplicate of the current configuration into another one.
  100565. * @param anisotropicConfiguration define the config where to copy the info
  100566. */
  100567. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  100568. /**
  100569. * Serializes this anisotropy configuration.
  100570. * @returns - An object with the serialized config.
  100571. */
  100572. serialize(): any;
  100573. /**
  100574. * Parses a anisotropy Configuration from a serialized object.
  100575. * @param source - Serialized object.
  100576. */
  100577. parse(source: any): void;
  100578. }
  100579. }
  100580. declare module BABYLON {
  100581. /**
  100582. * @hidden
  100583. */
  100584. export interface IMaterialBRDFDefines {
  100585. BRDF_V_HEIGHT_CORRELATED: boolean;
  100586. MS_BRDF_ENERGY_CONSERVATION: boolean;
  100587. /** @hidden */
  100588. _areMiscDirty: boolean;
  100589. }
  100590. /**
  100591. * Define the code related to the BRDF parameters of the pbr material.
  100592. */
  100593. export class PBRBRDFConfiguration {
  100594. private _useEnergyConservation;
  100595. /**
  100596. * Defines if the material uses energy conservation.
  100597. */
  100598. useEnergyConservation: boolean;
  100599. private _useSmithVisibilityHeightCorrelated;
  100600. /**
  100601. * LEGACY Mode set to false
  100602. * Defines if the material uses height smith correlated visibility term.
  100603. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  100604. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  100605. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  100606. * Not relying on height correlated will also disable energy conservation.
  100607. */
  100608. useSmithVisibilityHeightCorrelated: boolean;
  100609. /** @hidden */
  100610. private _internalMarkAllSubMeshesAsMiscDirty;
  100611. /** @hidden */
  100612. _markAllSubMeshesAsMiscDirty(): void;
  100613. /**
  100614. * Instantiate a new istance of clear coat configuration.
  100615. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  100616. */
  100617. constructor(markAllSubMeshesAsMiscDirty: () => void);
  100618. /**
  100619. * Checks to see if a texture is used in the material.
  100620. * @param defines the list of "defines" to update.
  100621. */
  100622. prepareDefines(defines: IMaterialBRDFDefines): void;
  100623. /**
  100624. * Get the current class name of the texture useful for serialization or dynamic coding.
  100625. * @returns "PBRClearCoatConfiguration"
  100626. */
  100627. getClassName(): string;
  100628. /**
  100629. * Makes a duplicate of the current configuration into another one.
  100630. * @param brdfConfiguration define the config where to copy the info
  100631. */
  100632. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  100633. /**
  100634. * Serializes this BRDF configuration.
  100635. * @returns - An object with the serialized config.
  100636. */
  100637. serialize(): any;
  100638. /**
  100639. * Parses a BRDF Configuration from a serialized object.
  100640. * @param source - Serialized object.
  100641. */
  100642. parse(source: any): void;
  100643. }
  100644. }
  100645. declare module BABYLON {
  100646. /**
  100647. * @hidden
  100648. */
  100649. export interface IMaterialSheenDefines {
  100650. SHEEN: boolean;
  100651. SHEEN_TEXTURE: boolean;
  100652. SHEEN_TEXTUREDIRECTUV: number;
  100653. SHEEN_LINKWITHALBEDO: boolean;
  100654. /** @hidden */
  100655. _areTexturesDirty: boolean;
  100656. }
  100657. /**
  100658. * Define the code related to the Sheen parameters of the pbr material.
  100659. */
  100660. export class PBRSheenConfiguration {
  100661. private _isEnabled;
  100662. /**
  100663. * Defines if the material uses sheen.
  100664. */
  100665. isEnabled: boolean;
  100666. private _linkSheenWithAlbedo;
  100667. /**
  100668. * Defines if the sheen is linked to the sheen color.
  100669. */
  100670. linkSheenWithAlbedo: boolean;
  100671. /**
  100672. * Defines the sheen intensity.
  100673. */
  100674. intensity: number;
  100675. /**
  100676. * Defines the sheen color.
  100677. */
  100678. color: Color3;
  100679. private _texture;
  100680. /**
  100681. * Stores the sheen tint values in a texture.
  100682. * rgb is tint
  100683. * a is a intensity
  100684. */
  100685. texture: Nullable<BaseTexture>;
  100686. /** @hidden */
  100687. private _internalMarkAllSubMeshesAsTexturesDirty;
  100688. /** @hidden */
  100689. _markAllSubMeshesAsTexturesDirty(): void;
  100690. /**
  100691. * Instantiate a new istance of clear coat configuration.
  100692. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100693. */
  100694. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100695. /**
  100696. * Specifies that the submesh is ready to be used.
  100697. * @param defines the list of "defines" to update.
  100698. * @param scene defines the scene the material belongs to.
  100699. * @returns - boolean indicating that the submesh is ready or not.
  100700. */
  100701. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  100702. /**
  100703. * Checks to see if a texture is used in the material.
  100704. * @param defines the list of "defines" to update.
  100705. * @param scene defines the scene the material belongs to.
  100706. */
  100707. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  100708. /**
  100709. * Binds the material data.
  100710. * @param uniformBuffer defines the Uniform buffer to fill in.
  100711. * @param scene defines the scene the material belongs to.
  100712. * @param isFrozen defines wether the material is frozen or not.
  100713. */
  100714. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  100715. /**
  100716. * Checks to see if a texture is used in the material.
  100717. * @param texture - Base texture to use.
  100718. * @returns - Boolean specifying if a texture is used in the material.
  100719. */
  100720. hasTexture(texture: BaseTexture): boolean;
  100721. /**
  100722. * Returns an array of the actively used textures.
  100723. * @param activeTextures Array of BaseTextures
  100724. */
  100725. getActiveTextures(activeTextures: BaseTexture[]): void;
  100726. /**
  100727. * Returns the animatable textures.
  100728. * @param animatables Array of animatable textures.
  100729. */
  100730. getAnimatables(animatables: IAnimatable[]): void;
  100731. /**
  100732. * Disposes the resources of the material.
  100733. * @param forceDisposeTextures - Forces the disposal of all textures.
  100734. */
  100735. dispose(forceDisposeTextures?: boolean): void;
  100736. /**
  100737. * Get the current class name of the texture useful for serialization or dynamic coding.
  100738. * @returns "PBRSheenConfiguration"
  100739. */
  100740. getClassName(): string;
  100741. /**
  100742. * Add fallbacks to the effect fallbacks list.
  100743. * @param defines defines the Base texture to use.
  100744. * @param fallbacks defines the current fallback list.
  100745. * @param currentRank defines the current fallback rank.
  100746. * @returns the new fallback rank.
  100747. */
  100748. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100749. /**
  100750. * Add the required uniforms to the current list.
  100751. * @param uniforms defines the current uniform list.
  100752. */
  100753. static AddUniforms(uniforms: string[]): void;
  100754. /**
  100755. * Add the required uniforms to the current buffer.
  100756. * @param uniformBuffer defines the current uniform buffer.
  100757. */
  100758. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100759. /**
  100760. * Add the required samplers to the current list.
  100761. * @param samplers defines the current sampler list.
  100762. */
  100763. static AddSamplers(samplers: string[]): void;
  100764. /**
  100765. * Makes a duplicate of the current configuration into another one.
  100766. * @param sheenConfiguration define the config where to copy the info
  100767. */
  100768. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  100769. /**
  100770. * Serializes this BRDF configuration.
  100771. * @returns - An object with the serialized config.
  100772. */
  100773. serialize(): any;
  100774. /**
  100775. * Parses a Sheen Configuration from a serialized object.
  100776. * @param source - Serialized object.
  100777. */
  100778. parse(source: any): void;
  100779. }
  100780. }
  100781. declare module BABYLON {
  100782. /** @hidden */
  100783. export var pbrFragmentDeclaration: {
  100784. name: string;
  100785. shader: string;
  100786. };
  100787. }
  100788. declare module BABYLON {
  100789. /** @hidden */
  100790. export var pbrUboDeclaration: {
  100791. name: string;
  100792. shader: string;
  100793. };
  100794. }
  100795. declare module BABYLON {
  100796. /** @hidden */
  100797. export var pbrFunctions: {
  100798. name: string;
  100799. shader: string;
  100800. };
  100801. }
  100802. declare module BABYLON {
  100803. /** @hidden */
  100804. export var harmonicsFunctions: {
  100805. name: string;
  100806. shader: string;
  100807. };
  100808. }
  100809. declare module BABYLON {
  100810. /** @hidden */
  100811. export var pbrPreLightingFunctions: {
  100812. name: string;
  100813. shader: string;
  100814. };
  100815. }
  100816. declare module BABYLON {
  100817. /** @hidden */
  100818. export var pbrFalloffLightingFunctions: {
  100819. name: string;
  100820. shader: string;
  100821. };
  100822. }
  100823. declare module BABYLON {
  100824. /** @hidden */
  100825. export var pbrLightingFunctions: {
  100826. name: string;
  100827. shader: string;
  100828. };
  100829. }
  100830. declare module BABYLON {
  100831. /** @hidden */
  100832. export var pbrDebug: {
  100833. name: string;
  100834. shader: string;
  100835. };
  100836. }
  100837. declare module BABYLON {
  100838. /** @hidden */
  100839. export var pbrPixelShader: {
  100840. name: string;
  100841. shader: string;
  100842. };
  100843. }
  100844. declare module BABYLON {
  100845. /** @hidden */
  100846. export var pbrVertexDeclaration: {
  100847. name: string;
  100848. shader: string;
  100849. };
  100850. }
  100851. declare module BABYLON {
  100852. /** @hidden */
  100853. export var pbrVertexShader: {
  100854. name: string;
  100855. shader: string;
  100856. };
  100857. }
  100858. declare module BABYLON {
  100859. /**
  100860. * The Physically based material base class of BJS.
  100861. *
  100862. * This offers the main features of a standard PBR material.
  100863. * For more information, please refer to the documentation :
  100864. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  100865. */
  100866. export abstract class PBRBaseMaterial extends PushMaterial {
  100867. /**
  100868. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  100869. */
  100870. static readonly PBRMATERIAL_OPAQUE: number;
  100871. /**
  100872. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  100873. */
  100874. static readonly PBRMATERIAL_ALPHATEST: number;
  100875. /**
  100876. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100877. */
  100878. static readonly PBRMATERIAL_ALPHABLEND: number;
  100879. /**
  100880. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100881. * They are also discarded below the alpha cutoff threshold to improve performances.
  100882. */
  100883. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  100884. /**
  100885. * Defines the default value of how much AO map is occluding the analytical lights
  100886. * (point spot...).
  100887. */
  100888. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  100889. /**
  100890. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  100891. */
  100892. static readonly LIGHTFALLOFF_PHYSICAL: number;
  100893. /**
  100894. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  100895. * to enhance interoperability with other engines.
  100896. */
  100897. static readonly LIGHTFALLOFF_GLTF: number;
  100898. /**
  100899. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  100900. * to enhance interoperability with other materials.
  100901. */
  100902. static readonly LIGHTFALLOFF_STANDARD: number;
  100903. /**
  100904. * Intensity of the direct lights e.g. the four lights available in your scene.
  100905. * This impacts both the direct diffuse and specular highlights.
  100906. */
  100907. protected _directIntensity: number;
  100908. /**
  100909. * Intensity of the emissive part of the material.
  100910. * This helps controlling the emissive effect without modifying the emissive color.
  100911. */
  100912. protected _emissiveIntensity: number;
  100913. /**
  100914. * Intensity of the environment e.g. how much the environment will light the object
  100915. * either through harmonics for rough material or through the refelction for shiny ones.
  100916. */
  100917. protected _environmentIntensity: number;
  100918. /**
  100919. * This is a special control allowing the reduction of the specular highlights coming from the
  100920. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  100921. */
  100922. protected _specularIntensity: number;
  100923. /**
  100924. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  100925. */
  100926. private _lightingInfos;
  100927. /**
  100928. * Debug Control allowing disabling the bump map on this material.
  100929. */
  100930. protected _disableBumpMap: boolean;
  100931. /**
  100932. * AKA Diffuse Texture in standard nomenclature.
  100933. */
  100934. protected _albedoTexture: BaseTexture;
  100935. /**
  100936. * AKA Occlusion Texture in other nomenclature.
  100937. */
  100938. protected _ambientTexture: BaseTexture;
  100939. /**
  100940. * AKA Occlusion Texture Intensity in other nomenclature.
  100941. */
  100942. protected _ambientTextureStrength: number;
  100943. /**
  100944. * Defines how much the AO map is occluding the analytical lights (point spot...).
  100945. * 1 means it completely occludes it
  100946. * 0 mean it has no impact
  100947. */
  100948. protected _ambientTextureImpactOnAnalyticalLights: number;
  100949. /**
  100950. * Stores the alpha values in a texture.
  100951. */
  100952. protected _opacityTexture: BaseTexture;
  100953. /**
  100954. * Stores the reflection values in a texture.
  100955. */
  100956. protected _reflectionTexture: BaseTexture;
  100957. /**
  100958. * Stores the refraction values in a texture.
  100959. */
  100960. protected _refractionTexture: BaseTexture;
  100961. /**
  100962. * Stores the emissive values in a texture.
  100963. */
  100964. protected _emissiveTexture: BaseTexture;
  100965. /**
  100966. * AKA Specular texture in other nomenclature.
  100967. */
  100968. protected _reflectivityTexture: BaseTexture;
  100969. /**
  100970. * Used to switch from specular/glossiness to metallic/roughness workflow.
  100971. */
  100972. protected _metallicTexture: BaseTexture;
  100973. /**
  100974. * Specifies the metallic scalar of the metallic/roughness workflow.
  100975. * Can also be used to scale the metalness values of the metallic texture.
  100976. */
  100977. protected _metallic: Nullable<number>;
  100978. /**
  100979. * Specifies the roughness scalar of the metallic/roughness workflow.
  100980. * Can also be used to scale the roughness values of the metallic texture.
  100981. */
  100982. protected _roughness: Nullable<number>;
  100983. /**
  100984. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  100985. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  100986. */
  100987. protected _microSurfaceTexture: BaseTexture;
  100988. /**
  100989. * Stores surface normal data used to displace a mesh in a texture.
  100990. */
  100991. protected _bumpTexture: BaseTexture;
  100992. /**
  100993. * Stores the pre-calculated light information of a mesh in a texture.
  100994. */
  100995. protected _lightmapTexture: BaseTexture;
  100996. /**
  100997. * The color of a material in ambient lighting.
  100998. */
  100999. protected _ambientColor: Color3;
  101000. /**
  101001. * AKA Diffuse Color in other nomenclature.
  101002. */
  101003. protected _albedoColor: Color3;
  101004. /**
  101005. * AKA Specular Color in other nomenclature.
  101006. */
  101007. protected _reflectivityColor: Color3;
  101008. /**
  101009. * The color applied when light is reflected from a material.
  101010. */
  101011. protected _reflectionColor: Color3;
  101012. /**
  101013. * The color applied when light is emitted from a material.
  101014. */
  101015. protected _emissiveColor: Color3;
  101016. /**
  101017. * AKA Glossiness in other nomenclature.
  101018. */
  101019. protected _microSurface: number;
  101020. /**
  101021. * source material index of refraction (IOR)' / 'destination material IOR.
  101022. */
  101023. protected _indexOfRefraction: number;
  101024. /**
  101025. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101026. */
  101027. protected _invertRefractionY: boolean;
  101028. /**
  101029. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101030. * Materials half opaque for instance using refraction could benefit from this control.
  101031. */
  101032. protected _linkRefractionWithTransparency: boolean;
  101033. /**
  101034. * Specifies that the material will use the light map as a show map.
  101035. */
  101036. protected _useLightmapAsShadowmap: boolean;
  101037. /**
  101038. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  101039. * makes the reflect vector face the model (under horizon).
  101040. */
  101041. protected _useHorizonOcclusion: boolean;
  101042. /**
  101043. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  101044. * too much the area relying on ambient texture to define their ambient occlusion.
  101045. */
  101046. protected _useRadianceOcclusion: boolean;
  101047. /**
  101048. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  101049. */
  101050. protected _useAlphaFromAlbedoTexture: boolean;
  101051. /**
  101052. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  101053. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101054. */
  101055. protected _useSpecularOverAlpha: boolean;
  101056. /**
  101057. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  101058. */
  101059. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  101060. /**
  101061. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  101062. */
  101063. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  101064. /**
  101065. * Specifies if the metallic texture contains the roughness information in its green channel.
  101066. */
  101067. protected _useRoughnessFromMetallicTextureGreen: boolean;
  101068. /**
  101069. * Specifies if the metallic texture contains the metallness information in its blue channel.
  101070. */
  101071. protected _useMetallnessFromMetallicTextureBlue: boolean;
  101072. /**
  101073. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  101074. */
  101075. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  101076. /**
  101077. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  101078. */
  101079. protected _useAmbientInGrayScale: boolean;
  101080. /**
  101081. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  101082. * The material will try to infer what glossiness each pixel should be.
  101083. */
  101084. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  101085. /**
  101086. * Defines the falloff type used in this material.
  101087. * It by default is Physical.
  101088. */
  101089. protected _lightFalloff: number;
  101090. /**
  101091. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101092. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101093. */
  101094. protected _useRadianceOverAlpha: boolean;
  101095. /**
  101096. * Allows using an object space normal map (instead of tangent space).
  101097. */
  101098. protected _useObjectSpaceNormalMap: boolean;
  101099. /**
  101100. * Allows using the bump map in parallax mode.
  101101. */
  101102. protected _useParallax: boolean;
  101103. /**
  101104. * Allows using the bump map in parallax occlusion mode.
  101105. */
  101106. protected _useParallaxOcclusion: boolean;
  101107. /**
  101108. * Controls the scale bias of the parallax mode.
  101109. */
  101110. protected _parallaxScaleBias: number;
  101111. /**
  101112. * If sets to true, disables all the lights affecting the material.
  101113. */
  101114. protected _disableLighting: boolean;
  101115. /**
  101116. * Number of Simultaneous lights allowed on the material.
  101117. */
  101118. protected _maxSimultaneousLights: number;
  101119. /**
  101120. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  101121. */
  101122. protected _invertNormalMapX: boolean;
  101123. /**
  101124. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  101125. */
  101126. protected _invertNormalMapY: boolean;
  101127. /**
  101128. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101129. */
  101130. protected _twoSidedLighting: boolean;
  101131. /**
  101132. * Defines the alpha limits in alpha test mode.
  101133. */
  101134. protected _alphaCutOff: number;
  101135. /**
  101136. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101137. */
  101138. protected _forceAlphaTest: boolean;
  101139. /**
  101140. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101141. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  101142. */
  101143. protected _useAlphaFresnel: boolean;
  101144. /**
  101145. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101146. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  101147. */
  101148. protected _useLinearAlphaFresnel: boolean;
  101149. /**
  101150. * The transparency mode of the material.
  101151. */
  101152. protected _transparencyMode: Nullable<number>;
  101153. /**
  101154. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  101155. * from cos thetav and roughness:
  101156. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  101157. */
  101158. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  101159. /**
  101160. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  101161. */
  101162. protected _forceIrradianceInFragment: boolean;
  101163. /**
  101164. * Force normal to face away from face.
  101165. */
  101166. protected _forceNormalForward: boolean;
  101167. /**
  101168. * Enables specular anti aliasing in the PBR shader.
  101169. * It will both interacts on the Geometry for analytical and IBL lighting.
  101170. * It also prefilter the roughness map based on the bump values.
  101171. */
  101172. protected _enableSpecularAntiAliasing: boolean;
  101173. /**
  101174. * Default configuration related to image processing available in the PBR Material.
  101175. */
  101176. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101177. /**
  101178. * Keep track of the image processing observer to allow dispose and replace.
  101179. */
  101180. private _imageProcessingObserver;
  101181. /**
  101182. * Attaches a new image processing configuration to the PBR Material.
  101183. * @param configuration
  101184. */
  101185. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101186. /**
  101187. * Stores the available render targets.
  101188. */
  101189. private _renderTargets;
  101190. /**
  101191. * Sets the global ambient color for the material used in lighting calculations.
  101192. */
  101193. private _globalAmbientColor;
  101194. /**
  101195. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  101196. */
  101197. private _useLogarithmicDepth;
  101198. /**
  101199. * If set to true, no lighting calculations will be applied.
  101200. */
  101201. private _unlit;
  101202. private _debugMode;
  101203. /**
  101204. * @hidden
  101205. * This is reserved for the inspector.
  101206. * Defines the material debug mode.
  101207. * It helps seeing only some components of the material while troubleshooting.
  101208. */
  101209. debugMode: number;
  101210. /**
  101211. * @hidden
  101212. * This is reserved for the inspector.
  101213. * Specify from where on screen the debug mode should start.
  101214. * The value goes from -1 (full screen) to 1 (not visible)
  101215. * It helps with side by side comparison against the final render
  101216. * This defaults to -1
  101217. */
  101218. private debugLimit;
  101219. /**
  101220. * @hidden
  101221. * This is reserved for the inspector.
  101222. * As the default viewing range might not be enough (if the ambient is really small for instance)
  101223. * You can use the factor to better multiply the final value.
  101224. */
  101225. private debugFactor;
  101226. /**
  101227. * Defines the clear coat layer parameters for the material.
  101228. */
  101229. readonly clearCoat: PBRClearCoatConfiguration;
  101230. /**
  101231. * Defines the anisotropic parameters for the material.
  101232. */
  101233. readonly anisotropy: PBRAnisotropicConfiguration;
  101234. /**
  101235. * Defines the BRDF parameters for the material.
  101236. */
  101237. readonly brdf: PBRBRDFConfiguration;
  101238. /**
  101239. * Defines the Sheen parameters for the material.
  101240. */
  101241. readonly sheen: PBRSheenConfiguration;
  101242. /**
  101243. * Instantiates a new PBRMaterial instance.
  101244. *
  101245. * @param name The material name
  101246. * @param scene The scene the material will be use in.
  101247. */
  101248. constructor(name: string, scene: Scene);
  101249. /**
  101250. * Gets a boolean indicating that current material needs to register RTT
  101251. */
  101252. readonly hasRenderTargetTextures: boolean;
  101253. /**
  101254. * Gets the name of the material class.
  101255. */
  101256. getClassName(): string;
  101257. /**
  101258. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  101259. */
  101260. /**
  101261. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  101262. */
  101263. useLogarithmicDepth: boolean;
  101264. /**
  101265. * Gets the current transparency mode.
  101266. */
  101267. /**
  101268. * Sets the transparency mode of the material.
  101269. *
  101270. * | Value | Type | Description |
  101271. * | ----- | ----------------------------------- | ----------- |
  101272. * | 0 | OPAQUE | |
  101273. * | 1 | ALPHATEST | |
  101274. * | 2 | ALPHABLEND | |
  101275. * | 3 | ALPHATESTANDBLEND | |
  101276. *
  101277. */
  101278. transparencyMode: Nullable<number>;
  101279. /**
  101280. * Returns true if alpha blending should be disabled.
  101281. */
  101282. private readonly _disableAlphaBlending;
  101283. /**
  101284. * Specifies whether or not this material should be rendered in alpha blend mode.
  101285. */
  101286. needAlphaBlending(): boolean;
  101287. /**
  101288. * Specifies if the mesh will require alpha blending.
  101289. * @param mesh - BJS mesh.
  101290. */
  101291. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  101292. /**
  101293. * Specifies whether or not this material should be rendered in alpha test mode.
  101294. */
  101295. needAlphaTesting(): boolean;
  101296. /**
  101297. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  101298. */
  101299. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  101300. /**
  101301. * Gets the texture used for the alpha test.
  101302. */
  101303. getAlphaTestTexture(): BaseTexture;
  101304. /**
  101305. * Specifies that the submesh is ready to be used.
  101306. * @param mesh - BJS mesh.
  101307. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  101308. * @param useInstances - Specifies that instances should be used.
  101309. * @returns - boolean indicating that the submesh is ready or not.
  101310. */
  101311. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101312. /**
  101313. * Specifies if the material uses metallic roughness workflow.
  101314. * @returns boolean specifiying if the material uses metallic roughness workflow.
  101315. */
  101316. isMetallicWorkflow(): boolean;
  101317. private _prepareEffect;
  101318. private _prepareDefines;
  101319. /**
  101320. * Force shader compilation
  101321. */
  101322. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  101323. clipPlane: boolean;
  101324. }>): void;
  101325. /**
  101326. * Initializes the uniform buffer layout for the shader.
  101327. */
  101328. buildUniformLayout(): void;
  101329. /**
  101330. * Unbinds the textures.
  101331. */
  101332. unbind(): void;
  101333. /**
  101334. * Binds the submesh data.
  101335. * @param world - The world matrix.
  101336. * @param mesh - The BJS mesh.
  101337. * @param subMesh - A submesh of the BJS mesh.
  101338. */
  101339. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101340. /**
  101341. * Returns the animatable textures.
  101342. * @returns - Array of animatable textures.
  101343. */
  101344. getAnimatables(): IAnimatable[];
  101345. /**
  101346. * Returns the texture used for reflections.
  101347. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  101348. */
  101349. private _getReflectionTexture;
  101350. /**
  101351. * Returns the texture used for refraction or null if none is used.
  101352. * @returns - Refection texture if present. If no refraction texture and refraction
  101353. * is linked with transparency, returns environment texture. Otherwise, returns null.
  101354. */
  101355. private _getRefractionTexture;
  101356. /**
  101357. * Returns an array of the actively used textures.
  101358. * @returns - Array of BaseTextures
  101359. */
  101360. getActiveTextures(): BaseTexture[];
  101361. /**
  101362. * Checks to see if a texture is used in the material.
  101363. * @param texture - Base texture to use.
  101364. * @returns - Boolean specifying if a texture is used in the material.
  101365. */
  101366. hasTexture(texture: BaseTexture): boolean;
  101367. /**
  101368. * Disposes the resources of the material.
  101369. * @param forceDisposeEffect - Forces the disposal of effects.
  101370. * @param forceDisposeTextures - Forces the disposal of all textures.
  101371. */
  101372. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101373. }
  101374. }
  101375. declare module BABYLON {
  101376. /**
  101377. * The Physically based material of BJS.
  101378. *
  101379. * This offers the main features of a standard PBR material.
  101380. * For more information, please refer to the documentation :
  101381. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  101382. */
  101383. export class PBRMaterial extends PBRBaseMaterial {
  101384. /**
  101385. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101386. */
  101387. static readonly PBRMATERIAL_OPAQUE: number;
  101388. /**
  101389. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101390. */
  101391. static readonly PBRMATERIAL_ALPHATEST: number;
  101392. /**
  101393. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101394. */
  101395. static readonly PBRMATERIAL_ALPHABLEND: number;
  101396. /**
  101397. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101398. * They are also discarded below the alpha cutoff threshold to improve performances.
  101399. */
  101400. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  101401. /**
  101402. * Defines the default value of how much AO map is occluding the analytical lights
  101403. * (point spot...).
  101404. */
  101405. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  101406. /**
  101407. * Intensity of the direct lights e.g. the four lights available in your scene.
  101408. * This impacts both the direct diffuse and specular highlights.
  101409. */
  101410. directIntensity: number;
  101411. /**
  101412. * Intensity of the emissive part of the material.
  101413. * This helps controlling the emissive effect without modifying the emissive color.
  101414. */
  101415. emissiveIntensity: number;
  101416. /**
  101417. * Intensity of the environment e.g. how much the environment will light the object
  101418. * either through harmonics for rough material or through the refelction for shiny ones.
  101419. */
  101420. environmentIntensity: number;
  101421. /**
  101422. * This is a special control allowing the reduction of the specular highlights coming from the
  101423. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  101424. */
  101425. specularIntensity: number;
  101426. /**
  101427. * Debug Control allowing disabling the bump map on this material.
  101428. */
  101429. disableBumpMap: boolean;
  101430. /**
  101431. * AKA Diffuse Texture in standard nomenclature.
  101432. */
  101433. albedoTexture: BaseTexture;
  101434. /**
  101435. * AKA Occlusion Texture in other nomenclature.
  101436. */
  101437. ambientTexture: BaseTexture;
  101438. /**
  101439. * AKA Occlusion Texture Intensity in other nomenclature.
  101440. */
  101441. ambientTextureStrength: number;
  101442. /**
  101443. * Defines how much the AO map is occluding the analytical lights (point spot...).
  101444. * 1 means it completely occludes it
  101445. * 0 mean it has no impact
  101446. */
  101447. ambientTextureImpactOnAnalyticalLights: number;
  101448. /**
  101449. * Stores the alpha values in a texture.
  101450. */
  101451. opacityTexture: BaseTexture;
  101452. /**
  101453. * Stores the reflection values in a texture.
  101454. */
  101455. reflectionTexture: Nullable<BaseTexture>;
  101456. /**
  101457. * Stores the emissive values in a texture.
  101458. */
  101459. emissiveTexture: BaseTexture;
  101460. /**
  101461. * AKA Specular texture in other nomenclature.
  101462. */
  101463. reflectivityTexture: BaseTexture;
  101464. /**
  101465. * Used to switch from specular/glossiness to metallic/roughness workflow.
  101466. */
  101467. metallicTexture: BaseTexture;
  101468. /**
  101469. * Specifies the metallic scalar of the metallic/roughness workflow.
  101470. * Can also be used to scale the metalness values of the metallic texture.
  101471. */
  101472. metallic: Nullable<number>;
  101473. /**
  101474. * Specifies the roughness scalar of the metallic/roughness workflow.
  101475. * Can also be used to scale the roughness values of the metallic texture.
  101476. */
  101477. roughness: Nullable<number>;
  101478. /**
  101479. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  101480. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  101481. */
  101482. microSurfaceTexture: BaseTexture;
  101483. /**
  101484. * Stores surface normal data used to displace a mesh in a texture.
  101485. */
  101486. bumpTexture: BaseTexture;
  101487. /**
  101488. * Stores the pre-calculated light information of a mesh in a texture.
  101489. */
  101490. lightmapTexture: BaseTexture;
  101491. /**
  101492. * Stores the refracted light information in a texture.
  101493. */
  101494. refractionTexture: BaseTexture;
  101495. /**
  101496. * The color of a material in ambient lighting.
  101497. */
  101498. ambientColor: Color3;
  101499. /**
  101500. * AKA Diffuse Color in other nomenclature.
  101501. */
  101502. albedoColor: Color3;
  101503. /**
  101504. * AKA Specular Color in other nomenclature.
  101505. */
  101506. reflectivityColor: Color3;
  101507. /**
  101508. * The color reflected from the material.
  101509. */
  101510. reflectionColor: Color3;
  101511. /**
  101512. * The color emitted from the material.
  101513. */
  101514. emissiveColor: Color3;
  101515. /**
  101516. * AKA Glossiness in other nomenclature.
  101517. */
  101518. microSurface: number;
  101519. /**
  101520. * source material index of refraction (IOR)' / 'destination material IOR.
  101521. */
  101522. indexOfRefraction: number;
  101523. /**
  101524. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101525. */
  101526. invertRefractionY: boolean;
  101527. /**
  101528. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101529. * Materials half opaque for instance using refraction could benefit from this control.
  101530. */
  101531. linkRefractionWithTransparency: boolean;
  101532. /**
  101533. * If true, the light map contains occlusion information instead of lighting info.
  101534. */
  101535. useLightmapAsShadowmap: boolean;
  101536. /**
  101537. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  101538. */
  101539. useAlphaFromAlbedoTexture: boolean;
  101540. /**
  101541. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101542. */
  101543. forceAlphaTest: boolean;
  101544. /**
  101545. * Defines the alpha limits in alpha test mode.
  101546. */
  101547. alphaCutOff: number;
  101548. /**
  101549. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101550. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101551. */
  101552. useSpecularOverAlpha: boolean;
  101553. /**
  101554. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  101555. */
  101556. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  101557. /**
  101558. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  101559. */
  101560. useRoughnessFromMetallicTextureAlpha: boolean;
  101561. /**
  101562. * Specifies if the metallic texture contains the roughness information in its green channel.
  101563. */
  101564. useRoughnessFromMetallicTextureGreen: boolean;
  101565. /**
  101566. * Specifies if the metallic texture contains the metallness information in its blue channel.
  101567. */
  101568. useMetallnessFromMetallicTextureBlue: boolean;
  101569. /**
  101570. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  101571. */
  101572. useAmbientOcclusionFromMetallicTextureRed: boolean;
  101573. /**
  101574. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  101575. */
  101576. useAmbientInGrayScale: boolean;
  101577. /**
  101578. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  101579. * The material will try to infer what glossiness each pixel should be.
  101580. */
  101581. useAutoMicroSurfaceFromReflectivityMap: boolean;
  101582. /**
  101583. * BJS is using an harcoded light falloff based on a manually sets up range.
  101584. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101585. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101586. */
  101587. /**
  101588. * BJS is using an harcoded light falloff based on a manually sets up range.
  101589. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101590. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101591. */
  101592. usePhysicalLightFalloff: boolean;
  101593. /**
  101594. * In order to support the falloff compatibility with gltf, a special mode has been added
  101595. * to reproduce the gltf light falloff.
  101596. */
  101597. /**
  101598. * In order to support the falloff compatibility with gltf, a special mode has been added
  101599. * to reproduce the gltf light falloff.
  101600. */
  101601. useGLTFLightFalloff: boolean;
  101602. /**
  101603. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101604. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101605. */
  101606. useRadianceOverAlpha: boolean;
  101607. /**
  101608. * Allows using an object space normal map (instead of tangent space).
  101609. */
  101610. useObjectSpaceNormalMap: boolean;
  101611. /**
  101612. * Allows using the bump map in parallax mode.
  101613. */
  101614. useParallax: boolean;
  101615. /**
  101616. * Allows using the bump map in parallax occlusion mode.
  101617. */
  101618. useParallaxOcclusion: boolean;
  101619. /**
  101620. * Controls the scale bias of the parallax mode.
  101621. */
  101622. parallaxScaleBias: number;
  101623. /**
  101624. * If sets to true, disables all the lights affecting the material.
  101625. */
  101626. disableLighting: boolean;
  101627. /**
  101628. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  101629. */
  101630. forceIrradianceInFragment: boolean;
  101631. /**
  101632. * Number of Simultaneous lights allowed on the material.
  101633. */
  101634. maxSimultaneousLights: number;
  101635. /**
  101636. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101637. */
  101638. invertNormalMapX: boolean;
  101639. /**
  101640. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101641. */
  101642. invertNormalMapY: boolean;
  101643. /**
  101644. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101645. */
  101646. twoSidedLighting: boolean;
  101647. /**
  101648. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101649. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  101650. */
  101651. useAlphaFresnel: boolean;
  101652. /**
  101653. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101654. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  101655. */
  101656. useLinearAlphaFresnel: boolean;
  101657. /**
  101658. * Let user defines the brdf lookup texture used for IBL.
  101659. * A default 8bit version is embedded but you could point at :
  101660. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  101661. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  101662. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101663. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  101664. */
  101665. environmentBRDFTexture: Nullable<BaseTexture>;
  101666. /**
  101667. * Force normal to face away from face.
  101668. */
  101669. forceNormalForward: boolean;
  101670. /**
  101671. * Enables specular anti aliasing in the PBR shader.
  101672. * It will both interacts on the Geometry for analytical and IBL lighting.
  101673. * It also prefilter the roughness map based on the bump values.
  101674. */
  101675. enableSpecularAntiAliasing: boolean;
  101676. /**
  101677. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  101678. * makes the reflect vector face the model (under horizon).
  101679. */
  101680. useHorizonOcclusion: boolean;
  101681. /**
  101682. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  101683. * too much the area relying on ambient texture to define their ambient occlusion.
  101684. */
  101685. useRadianceOcclusion: boolean;
  101686. /**
  101687. * If set to true, no lighting calculations will be applied.
  101688. */
  101689. unlit: boolean;
  101690. /**
  101691. * Gets the image processing configuration used either in this material.
  101692. */
  101693. /**
  101694. * Sets the Default image processing configuration used either in the this material.
  101695. *
  101696. * If sets to null, the scene one is in use.
  101697. */
  101698. imageProcessingConfiguration: ImageProcessingConfiguration;
  101699. /**
  101700. * Gets wether the color curves effect is enabled.
  101701. */
  101702. /**
  101703. * Sets wether the color curves effect is enabled.
  101704. */
  101705. cameraColorCurvesEnabled: boolean;
  101706. /**
  101707. * Gets wether the color grading effect is enabled.
  101708. */
  101709. /**
  101710. * Gets wether the color grading effect is enabled.
  101711. */
  101712. cameraColorGradingEnabled: boolean;
  101713. /**
  101714. * Gets wether tonemapping is enabled or not.
  101715. */
  101716. /**
  101717. * Sets wether tonemapping is enabled or not
  101718. */
  101719. cameraToneMappingEnabled: boolean;
  101720. /**
  101721. * The camera exposure used on this material.
  101722. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101723. * This corresponds to a photographic exposure.
  101724. */
  101725. /**
  101726. * The camera exposure used on this material.
  101727. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101728. * This corresponds to a photographic exposure.
  101729. */
  101730. cameraExposure: number;
  101731. /**
  101732. * Gets The camera contrast used on this material.
  101733. */
  101734. /**
  101735. * Sets The camera contrast used on this material.
  101736. */
  101737. cameraContrast: number;
  101738. /**
  101739. * Gets the Color Grading 2D Lookup Texture.
  101740. */
  101741. /**
  101742. * Sets the Color Grading 2D Lookup Texture.
  101743. */
  101744. cameraColorGradingTexture: Nullable<BaseTexture>;
  101745. /**
  101746. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101747. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101748. * 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;
  101749. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101750. */
  101751. /**
  101752. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101753. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101754. * 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;
  101755. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101756. */
  101757. cameraColorCurves: Nullable<ColorCurves>;
  101758. /**
  101759. * Instantiates a new PBRMaterial instance.
  101760. *
  101761. * @param name The material name
  101762. * @param scene The scene the material will be use in.
  101763. */
  101764. constructor(name: string, scene: Scene);
  101765. /**
  101766. * Returns the name of this material class.
  101767. */
  101768. getClassName(): string;
  101769. /**
  101770. * Makes a duplicate of the current material.
  101771. * @param name - name to use for the new material.
  101772. */
  101773. clone(name: string): PBRMaterial;
  101774. /**
  101775. * Serializes this PBR Material.
  101776. * @returns - An object with the serialized material.
  101777. */
  101778. serialize(): any;
  101779. /**
  101780. * Parses a PBR Material from a serialized object.
  101781. * @param source - Serialized object.
  101782. * @param scene - BJS scene instance.
  101783. * @param rootUrl - url for the scene object
  101784. * @returns - PBRMaterial
  101785. */
  101786. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  101787. }
  101788. }
  101789. declare module BABYLON {
  101790. /**
  101791. * Direct draw surface info
  101792. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  101793. */
  101794. export interface DDSInfo {
  101795. /**
  101796. * Width of the texture
  101797. */
  101798. width: number;
  101799. /**
  101800. * Width of the texture
  101801. */
  101802. height: number;
  101803. /**
  101804. * Number of Mipmaps for the texture
  101805. * @see https://en.wikipedia.org/wiki/Mipmap
  101806. */
  101807. mipmapCount: number;
  101808. /**
  101809. * If the textures format is a known fourCC format
  101810. * @see https://www.fourcc.org/
  101811. */
  101812. isFourCC: boolean;
  101813. /**
  101814. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  101815. */
  101816. isRGB: boolean;
  101817. /**
  101818. * If the texture is a lumincance format
  101819. */
  101820. isLuminance: boolean;
  101821. /**
  101822. * If this is a cube texture
  101823. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  101824. */
  101825. isCube: boolean;
  101826. /**
  101827. * If the texture is a compressed format eg. FOURCC_DXT1
  101828. */
  101829. isCompressed: boolean;
  101830. /**
  101831. * The dxgiFormat of the texture
  101832. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  101833. */
  101834. dxgiFormat: number;
  101835. /**
  101836. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  101837. */
  101838. textureType: number;
  101839. /**
  101840. * Sphericle polynomial created for the dds texture
  101841. */
  101842. sphericalPolynomial?: SphericalPolynomial;
  101843. }
  101844. /**
  101845. * Class used to provide DDS decompression tools
  101846. */
  101847. export class DDSTools {
  101848. /**
  101849. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  101850. */
  101851. static StoreLODInAlphaChannel: boolean;
  101852. /**
  101853. * Gets DDS information from an array buffer
  101854. * @param arrayBuffer defines the array buffer to read data from
  101855. * @returns the DDS information
  101856. */
  101857. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  101858. private static _FloatView;
  101859. private static _Int32View;
  101860. private static _ToHalfFloat;
  101861. private static _FromHalfFloat;
  101862. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  101863. private static _GetHalfFloatRGBAArrayBuffer;
  101864. private static _GetFloatRGBAArrayBuffer;
  101865. private static _GetFloatAsUIntRGBAArrayBuffer;
  101866. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  101867. private static _GetRGBAArrayBuffer;
  101868. private static _ExtractLongWordOrder;
  101869. private static _GetRGBArrayBuffer;
  101870. private static _GetLuminanceArrayBuffer;
  101871. /**
  101872. * Uploads DDS Levels to a Babylon Texture
  101873. * @hidden
  101874. */
  101875. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  101876. }
  101877. interface Engine {
  101878. /**
  101879. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  101880. * @param rootUrl defines the url where the file to load is located
  101881. * @param scene defines the current scene
  101882. * @param lodScale defines scale to apply to the mip map selection
  101883. * @param lodOffset defines offset to apply to the mip map selection
  101884. * @param onLoad defines an optional callback raised when the texture is loaded
  101885. * @param onError defines an optional callback raised if there is an issue to load the texture
  101886. * @param format defines the format of the data
  101887. * @param forcedExtension defines the extension to use to pick the right loader
  101888. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  101889. * @returns the cube texture as an InternalTexture
  101890. */
  101891. 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;
  101892. }
  101893. }
  101894. declare module BABYLON {
  101895. /**
  101896. * Implementation of the DDS Texture Loader.
  101897. * @hidden
  101898. */
  101899. export class _DDSTextureLoader implements IInternalTextureLoader {
  101900. /**
  101901. * Defines wether the loader supports cascade loading the different faces.
  101902. */
  101903. readonly supportCascades: boolean;
  101904. /**
  101905. * This returns if the loader support the current file information.
  101906. * @param extension defines the file extension of the file being loaded
  101907. * @param textureFormatInUse defines the current compressed format in use iun the engine
  101908. * @param fallback defines the fallback internal texture if any
  101909. * @param isBase64 defines whether the texture is encoded as a base64
  101910. * @param isBuffer defines whether the texture data are stored as a buffer
  101911. * @returns true if the loader can load the specified file
  101912. */
  101913. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  101914. /**
  101915. * Transform the url before loading if required.
  101916. * @param rootUrl the url of the texture
  101917. * @param textureFormatInUse defines the current compressed format in use iun the engine
  101918. * @returns the transformed texture
  101919. */
  101920. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  101921. /**
  101922. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  101923. * @param rootUrl the url of the texture
  101924. * @param textureFormatInUse defines the current compressed format in use iun the engine
  101925. * @returns the fallback texture
  101926. */
  101927. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  101928. /**
  101929. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  101930. * @param data contains the texture data
  101931. * @param texture defines the BabylonJS internal texture
  101932. * @param createPolynomials will be true if polynomials have been requested
  101933. * @param onLoad defines the callback to trigger once the texture is ready
  101934. * @param onError defines the callback to trigger in case of error
  101935. */
  101936. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  101937. /**
  101938. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  101939. * @param data contains the texture data
  101940. * @param texture defines the BabylonJS internal texture
  101941. * @param callback defines the method to call once ready to upload
  101942. */
  101943. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  101944. }
  101945. }
  101946. declare module BABYLON {
  101947. /** @hidden */
  101948. export var rgbdEncodePixelShader: {
  101949. name: string;
  101950. shader: string;
  101951. };
  101952. }
  101953. declare module BABYLON {
  101954. /** @hidden */
  101955. export var rgbdDecodePixelShader: {
  101956. name: string;
  101957. shader: string;
  101958. };
  101959. }
  101960. declare module BABYLON {
  101961. /**
  101962. * Raw texture data and descriptor sufficient for WebGL texture upload
  101963. */
  101964. export interface EnvironmentTextureInfo {
  101965. /**
  101966. * Version of the environment map
  101967. */
  101968. version: number;
  101969. /**
  101970. * Width of image
  101971. */
  101972. width: number;
  101973. /**
  101974. * Irradiance information stored in the file.
  101975. */
  101976. irradiance: any;
  101977. /**
  101978. * Specular information stored in the file.
  101979. */
  101980. specular: any;
  101981. }
  101982. /**
  101983. * Sets of helpers addressing the serialization and deserialization of environment texture
  101984. * stored in a BabylonJS env file.
  101985. * Those files are usually stored as .env files.
  101986. */
  101987. export class EnvironmentTextureTools {
  101988. /**
  101989. * Magic number identifying the env file.
  101990. */
  101991. private static _MagicBytes;
  101992. /**
  101993. * Gets the environment info from an env file.
  101994. * @param data The array buffer containing the .env bytes.
  101995. * @returns the environment file info (the json header) if successfully parsed.
  101996. */
  101997. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  101998. /**
  101999. * Creates an environment texture from a loaded cube texture.
  102000. * @param texture defines the cube texture to convert in env file
  102001. * @return a promise containing the environment data if succesfull.
  102002. */
  102003. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  102004. /**
  102005. * Creates a JSON representation of the spherical data.
  102006. * @param texture defines the texture containing the polynomials
  102007. * @return the JSON representation of the spherical info
  102008. */
  102009. private static _CreateEnvTextureIrradiance;
  102010. /**
  102011. * Uploads the texture info contained in the env file to the GPU.
  102012. * @param texture defines the internal texture to upload to
  102013. * @param arrayBuffer defines the buffer cotaining the data to load
  102014. * @param info defines the texture info retrieved through the GetEnvInfo method
  102015. * @returns a promise
  102016. */
  102017. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  102018. /**
  102019. * Uploads the levels of image data to the GPU.
  102020. * @param texture defines the internal texture to upload to
  102021. * @param imageData defines the array buffer views of image data [mipmap][face]
  102022. * @returns a promise
  102023. */
  102024. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  102025. /**
  102026. * Uploads spherical polynomials information to the texture.
  102027. * @param texture defines the texture we are trying to upload the information to
  102028. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  102029. */
  102030. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  102031. /** @hidden */
  102032. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  102033. }
  102034. }
  102035. declare module BABYLON {
  102036. /**
  102037. * Implementation of the ENV Texture Loader.
  102038. * @hidden
  102039. */
  102040. export class _ENVTextureLoader implements IInternalTextureLoader {
  102041. /**
  102042. * Defines wether the loader supports cascade loading the different faces.
  102043. */
  102044. readonly supportCascades: boolean;
  102045. /**
  102046. * This returns if the loader support the current file information.
  102047. * @param extension defines the file extension of the file being loaded
  102048. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102049. * @param fallback defines the fallback internal texture if any
  102050. * @param isBase64 defines whether the texture is encoded as a base64
  102051. * @param isBuffer defines whether the texture data are stored as a buffer
  102052. * @returns true if the loader can load the specified file
  102053. */
  102054. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102055. /**
  102056. * Transform the url before loading if required.
  102057. * @param rootUrl the url of the texture
  102058. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102059. * @returns the transformed texture
  102060. */
  102061. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102062. /**
  102063. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102064. * @param rootUrl the url of the texture
  102065. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102066. * @returns the fallback texture
  102067. */
  102068. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102069. /**
  102070. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102071. * @param data contains the texture data
  102072. * @param texture defines the BabylonJS internal texture
  102073. * @param createPolynomials will be true if polynomials have been requested
  102074. * @param onLoad defines the callback to trigger once the texture is ready
  102075. * @param onError defines the callback to trigger in case of error
  102076. */
  102077. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102078. /**
  102079. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102080. * @param data contains the texture data
  102081. * @param texture defines the BabylonJS internal texture
  102082. * @param callback defines the method to call once ready to upload
  102083. */
  102084. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102085. }
  102086. }
  102087. declare module BABYLON {
  102088. /**
  102089. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  102090. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  102091. */
  102092. export class KhronosTextureContainer {
  102093. /** contents of the KTX container file */
  102094. arrayBuffer: any;
  102095. private static HEADER_LEN;
  102096. private static COMPRESSED_2D;
  102097. private static COMPRESSED_3D;
  102098. private static TEX_2D;
  102099. private static TEX_3D;
  102100. /**
  102101. * Gets the openGL type
  102102. */
  102103. glType: number;
  102104. /**
  102105. * Gets the openGL type size
  102106. */
  102107. glTypeSize: number;
  102108. /**
  102109. * Gets the openGL format
  102110. */
  102111. glFormat: number;
  102112. /**
  102113. * Gets the openGL internal format
  102114. */
  102115. glInternalFormat: number;
  102116. /**
  102117. * Gets the base internal format
  102118. */
  102119. glBaseInternalFormat: number;
  102120. /**
  102121. * Gets image width in pixel
  102122. */
  102123. pixelWidth: number;
  102124. /**
  102125. * Gets image height in pixel
  102126. */
  102127. pixelHeight: number;
  102128. /**
  102129. * Gets image depth in pixels
  102130. */
  102131. pixelDepth: number;
  102132. /**
  102133. * Gets the number of array elements
  102134. */
  102135. numberOfArrayElements: number;
  102136. /**
  102137. * Gets the number of faces
  102138. */
  102139. numberOfFaces: number;
  102140. /**
  102141. * Gets the number of mipmap levels
  102142. */
  102143. numberOfMipmapLevels: number;
  102144. /**
  102145. * Gets the bytes of key value data
  102146. */
  102147. bytesOfKeyValueData: number;
  102148. /**
  102149. * Gets the load type
  102150. */
  102151. loadType: number;
  102152. /**
  102153. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  102154. */
  102155. isInvalid: boolean;
  102156. /**
  102157. * Creates a new KhronosTextureContainer
  102158. * @param arrayBuffer contents of the KTX container file
  102159. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  102160. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  102161. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  102162. */
  102163. constructor(
  102164. /** contents of the KTX container file */
  102165. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  102166. /**
  102167. * Uploads KTX content to a Babylon Texture.
  102168. * It is assumed that the texture has already been created & is currently bound
  102169. * @hidden
  102170. */
  102171. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  102172. private _upload2DCompressedLevels;
  102173. }
  102174. }
  102175. declare module BABYLON {
  102176. /**
  102177. * Implementation of the KTX Texture Loader.
  102178. * @hidden
  102179. */
  102180. export class _KTXTextureLoader implements IInternalTextureLoader {
  102181. /**
  102182. * Defines wether the loader supports cascade loading the different faces.
  102183. */
  102184. readonly supportCascades: boolean;
  102185. /**
  102186. * This returns if the loader support the current file information.
  102187. * @param extension defines the file extension of the file being loaded
  102188. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102189. * @param fallback defines the fallback internal texture if any
  102190. * @param isBase64 defines whether the texture is encoded as a base64
  102191. * @param isBuffer defines whether the texture data are stored as a buffer
  102192. * @returns true if the loader can load the specified file
  102193. */
  102194. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102195. /**
  102196. * Transform the url before loading if required.
  102197. * @param rootUrl the url of the texture
  102198. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102199. * @returns the transformed texture
  102200. */
  102201. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102202. /**
  102203. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102204. * @param rootUrl the url of the texture
  102205. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102206. * @returns the fallback texture
  102207. */
  102208. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102209. /**
  102210. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102211. * @param data contains the texture data
  102212. * @param texture defines the BabylonJS internal texture
  102213. * @param createPolynomials will be true if polynomials have been requested
  102214. * @param onLoad defines the callback to trigger once the texture is ready
  102215. * @param onError defines the callback to trigger in case of error
  102216. */
  102217. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102218. /**
  102219. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102220. * @param data contains the texture data
  102221. * @param texture defines the BabylonJS internal texture
  102222. * @param callback defines the method to call once ready to upload
  102223. */
  102224. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  102225. }
  102226. }
  102227. declare module BABYLON {
  102228. /** @hidden */
  102229. export var _forceSceneHelpersToBundle: boolean;
  102230. interface Scene {
  102231. /**
  102232. * Creates a default light for the scene.
  102233. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  102234. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  102235. */
  102236. createDefaultLight(replace?: boolean): void;
  102237. /**
  102238. * Creates a default camera for the scene.
  102239. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  102240. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  102241. * @param replace has default false, when true replaces the active camera in the scene
  102242. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  102243. */
  102244. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  102245. /**
  102246. * Creates a default camera and a default light.
  102247. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  102248. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  102249. * @param replace has the default false, when true replaces the active camera/light in the scene
  102250. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  102251. */
  102252. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  102253. /**
  102254. * Creates a new sky box
  102255. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  102256. * @param environmentTexture defines the texture to use as environment texture
  102257. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  102258. * @param scale defines the overall scale of the skybox
  102259. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  102260. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  102261. * @returns a new mesh holding the sky box
  102262. */
  102263. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  102264. /**
  102265. * Creates a new environment
  102266. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  102267. * @param options defines the options you can use to configure the environment
  102268. * @returns the new EnvironmentHelper
  102269. */
  102270. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  102271. /**
  102272. * Creates a new VREXperienceHelper
  102273. * @see http://doc.babylonjs.com/how_to/webvr_helper
  102274. * @param webVROptions defines the options used to create the new VREXperienceHelper
  102275. * @returns a new VREXperienceHelper
  102276. */
  102277. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  102278. /**
  102279. * Creates a new XREXperienceHelper
  102280. * @see http://doc.babylonjs.com/how_to/webxr
  102281. * @returns a promise for a new XREXperienceHelper
  102282. */
  102283. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  102284. }
  102285. }
  102286. declare module BABYLON {
  102287. /**
  102288. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  102289. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  102290. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  102291. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  102292. */
  102293. export class VideoDome extends TransformNode {
  102294. /**
  102295. * Define the video source as a Monoscopic panoramic 360 video.
  102296. */
  102297. static readonly MODE_MONOSCOPIC: number;
  102298. /**
  102299. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  102300. */
  102301. static readonly MODE_TOPBOTTOM: number;
  102302. /**
  102303. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  102304. */
  102305. static readonly MODE_SIDEBYSIDE: number;
  102306. private _useDirectMapping;
  102307. /**
  102308. * The video texture being displayed on the sphere
  102309. */
  102310. protected _videoTexture: VideoTexture;
  102311. /**
  102312. * Gets the video texture being displayed on the sphere
  102313. */
  102314. readonly videoTexture: VideoTexture;
  102315. /**
  102316. * The skybox material
  102317. */
  102318. protected _material: BackgroundMaterial;
  102319. /**
  102320. * The surface used for the skybox
  102321. */
  102322. protected _mesh: Mesh;
  102323. /**
  102324. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102325. * Also see the options.resolution property.
  102326. */
  102327. fovMultiplier: number;
  102328. private _videoMode;
  102329. /**
  102330. * Gets or set the current video mode for the video. It can be:
  102331. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  102332. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  102333. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  102334. */
  102335. videoMode: number;
  102336. /**
  102337. * Oberserver used in Stereoscopic VR Mode.
  102338. */
  102339. private _onBeforeCameraRenderObserver;
  102340. /**
  102341. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  102342. * @param name Element's name, child elements will append suffixes for their own names.
  102343. * @param urlsOrVideo defines the url(s) or the video element to use
  102344. * @param options An object containing optional or exposed sub element properties
  102345. */
  102346. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  102347. resolution?: number;
  102348. clickToPlay?: boolean;
  102349. autoPlay?: boolean;
  102350. loop?: boolean;
  102351. size?: number;
  102352. poster?: string;
  102353. useDirectMapping?: boolean;
  102354. }, scene: Scene);
  102355. private _changeVideoMode;
  102356. /**
  102357. * Releases resources associated with this node.
  102358. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102359. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102360. */
  102361. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102362. }
  102363. }
  102364. declare module BABYLON {
  102365. /**
  102366. * This class can be used to get instrumentation data from a Babylon engine
  102367. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  102368. */
  102369. export class EngineInstrumentation implements IDisposable {
  102370. /**
  102371. * Define the instrumented engine.
  102372. */
  102373. engine: Engine;
  102374. private _captureGPUFrameTime;
  102375. private _gpuFrameTimeToken;
  102376. private _gpuFrameTime;
  102377. private _captureShaderCompilationTime;
  102378. private _shaderCompilationTime;
  102379. private _onBeginFrameObserver;
  102380. private _onEndFrameObserver;
  102381. private _onBeforeShaderCompilationObserver;
  102382. private _onAfterShaderCompilationObserver;
  102383. /**
  102384. * Gets the perf counter used for GPU frame time
  102385. */
  102386. readonly gpuFrameTimeCounter: PerfCounter;
  102387. /**
  102388. * Gets the GPU frame time capture status
  102389. */
  102390. /**
  102391. * Enable or disable the GPU frame time capture
  102392. */
  102393. captureGPUFrameTime: boolean;
  102394. /**
  102395. * Gets the perf counter used for shader compilation time
  102396. */
  102397. readonly shaderCompilationTimeCounter: PerfCounter;
  102398. /**
  102399. * Gets the shader compilation time capture status
  102400. */
  102401. /**
  102402. * Enable or disable the shader compilation time capture
  102403. */
  102404. captureShaderCompilationTime: boolean;
  102405. /**
  102406. * Instantiates a new engine instrumentation.
  102407. * This class can be used to get instrumentation data from a Babylon engine
  102408. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  102409. * @param engine Defines the engine to instrument
  102410. */
  102411. constructor(
  102412. /**
  102413. * Define the instrumented engine.
  102414. */
  102415. engine: Engine);
  102416. /**
  102417. * Dispose and release associated resources.
  102418. */
  102419. dispose(): void;
  102420. }
  102421. }
  102422. declare module BABYLON {
  102423. /**
  102424. * This class can be used to get instrumentation data from a Babylon engine
  102425. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  102426. */
  102427. export class SceneInstrumentation implements IDisposable {
  102428. /**
  102429. * Defines the scene to instrument
  102430. */
  102431. scene: Scene;
  102432. private _captureActiveMeshesEvaluationTime;
  102433. private _activeMeshesEvaluationTime;
  102434. private _captureRenderTargetsRenderTime;
  102435. private _renderTargetsRenderTime;
  102436. private _captureFrameTime;
  102437. private _frameTime;
  102438. private _captureRenderTime;
  102439. private _renderTime;
  102440. private _captureInterFrameTime;
  102441. private _interFrameTime;
  102442. private _captureParticlesRenderTime;
  102443. private _particlesRenderTime;
  102444. private _captureSpritesRenderTime;
  102445. private _spritesRenderTime;
  102446. private _capturePhysicsTime;
  102447. private _physicsTime;
  102448. private _captureAnimationsTime;
  102449. private _animationsTime;
  102450. private _captureCameraRenderTime;
  102451. private _cameraRenderTime;
  102452. private _onBeforeActiveMeshesEvaluationObserver;
  102453. private _onAfterActiveMeshesEvaluationObserver;
  102454. private _onBeforeRenderTargetsRenderObserver;
  102455. private _onAfterRenderTargetsRenderObserver;
  102456. private _onAfterRenderObserver;
  102457. private _onBeforeDrawPhaseObserver;
  102458. private _onAfterDrawPhaseObserver;
  102459. private _onBeforeAnimationsObserver;
  102460. private _onBeforeParticlesRenderingObserver;
  102461. private _onAfterParticlesRenderingObserver;
  102462. private _onBeforeSpritesRenderingObserver;
  102463. private _onAfterSpritesRenderingObserver;
  102464. private _onBeforePhysicsObserver;
  102465. private _onAfterPhysicsObserver;
  102466. private _onAfterAnimationsObserver;
  102467. private _onBeforeCameraRenderObserver;
  102468. private _onAfterCameraRenderObserver;
  102469. /**
  102470. * Gets the perf counter used for active meshes evaluation time
  102471. */
  102472. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  102473. /**
  102474. * Gets the active meshes evaluation time capture status
  102475. */
  102476. /**
  102477. * Enable or disable the active meshes evaluation time capture
  102478. */
  102479. captureActiveMeshesEvaluationTime: boolean;
  102480. /**
  102481. * Gets the perf counter used for render targets render time
  102482. */
  102483. readonly renderTargetsRenderTimeCounter: PerfCounter;
  102484. /**
  102485. * Gets the render targets render time capture status
  102486. */
  102487. /**
  102488. * Enable or disable the render targets render time capture
  102489. */
  102490. captureRenderTargetsRenderTime: boolean;
  102491. /**
  102492. * Gets the perf counter used for particles render time
  102493. */
  102494. readonly particlesRenderTimeCounter: PerfCounter;
  102495. /**
  102496. * Gets the particles render time capture status
  102497. */
  102498. /**
  102499. * Enable or disable the particles render time capture
  102500. */
  102501. captureParticlesRenderTime: boolean;
  102502. /**
  102503. * Gets the perf counter used for sprites render time
  102504. */
  102505. readonly spritesRenderTimeCounter: PerfCounter;
  102506. /**
  102507. * Gets the sprites render time capture status
  102508. */
  102509. /**
  102510. * Enable or disable the sprites render time capture
  102511. */
  102512. captureSpritesRenderTime: boolean;
  102513. /**
  102514. * Gets the perf counter used for physics time
  102515. */
  102516. readonly physicsTimeCounter: PerfCounter;
  102517. /**
  102518. * Gets the physics time capture status
  102519. */
  102520. /**
  102521. * Enable or disable the physics time capture
  102522. */
  102523. capturePhysicsTime: boolean;
  102524. /**
  102525. * Gets the perf counter used for animations time
  102526. */
  102527. readonly animationsTimeCounter: PerfCounter;
  102528. /**
  102529. * Gets the animations time capture status
  102530. */
  102531. /**
  102532. * Enable or disable the animations time capture
  102533. */
  102534. captureAnimationsTime: boolean;
  102535. /**
  102536. * Gets the perf counter used for frame time capture
  102537. */
  102538. readonly frameTimeCounter: PerfCounter;
  102539. /**
  102540. * Gets the frame time capture status
  102541. */
  102542. /**
  102543. * Enable or disable the frame time capture
  102544. */
  102545. captureFrameTime: boolean;
  102546. /**
  102547. * Gets the perf counter used for inter-frames time capture
  102548. */
  102549. readonly interFrameTimeCounter: PerfCounter;
  102550. /**
  102551. * Gets the inter-frames time capture status
  102552. */
  102553. /**
  102554. * Enable or disable the inter-frames time capture
  102555. */
  102556. captureInterFrameTime: boolean;
  102557. /**
  102558. * Gets the perf counter used for render time capture
  102559. */
  102560. readonly renderTimeCounter: PerfCounter;
  102561. /**
  102562. * Gets the render time capture status
  102563. */
  102564. /**
  102565. * Enable or disable the render time capture
  102566. */
  102567. captureRenderTime: boolean;
  102568. /**
  102569. * Gets the perf counter used for camera render time capture
  102570. */
  102571. readonly cameraRenderTimeCounter: PerfCounter;
  102572. /**
  102573. * Gets the camera render time capture status
  102574. */
  102575. /**
  102576. * Enable or disable the camera render time capture
  102577. */
  102578. captureCameraRenderTime: boolean;
  102579. /**
  102580. * Gets the perf counter used for draw calls
  102581. */
  102582. readonly drawCallsCounter: PerfCounter;
  102583. /**
  102584. * Gets the perf counter used for texture collisions
  102585. */
  102586. readonly textureCollisionsCounter: PerfCounter;
  102587. /**
  102588. * Instantiates a new scene instrumentation.
  102589. * This class can be used to get instrumentation data from a Babylon engine
  102590. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  102591. * @param scene Defines the scene to instrument
  102592. */
  102593. constructor(
  102594. /**
  102595. * Defines the scene to instrument
  102596. */
  102597. scene: Scene);
  102598. /**
  102599. * Dispose and release associated resources.
  102600. */
  102601. dispose(): void;
  102602. }
  102603. }
  102604. declare module BABYLON {
  102605. /** @hidden */
  102606. export var glowMapGenerationPixelShader: {
  102607. name: string;
  102608. shader: string;
  102609. };
  102610. }
  102611. declare module BABYLON {
  102612. /** @hidden */
  102613. export var glowMapGenerationVertexShader: {
  102614. name: string;
  102615. shader: string;
  102616. };
  102617. }
  102618. declare module BABYLON {
  102619. /**
  102620. * Effect layer options. This helps customizing the behaviour
  102621. * of the effect layer.
  102622. */
  102623. export interface IEffectLayerOptions {
  102624. /**
  102625. * Multiplication factor apply to the canvas size to compute the render target size
  102626. * used to generated the objects (the smaller the faster).
  102627. */
  102628. mainTextureRatio: number;
  102629. /**
  102630. * Enforces a fixed size texture to ensure effect stability across devices.
  102631. */
  102632. mainTextureFixedSize?: number;
  102633. /**
  102634. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  102635. */
  102636. alphaBlendingMode: number;
  102637. /**
  102638. * The camera attached to the layer.
  102639. */
  102640. camera: Nullable<Camera>;
  102641. /**
  102642. * The rendering group to draw the layer in.
  102643. */
  102644. renderingGroupId: number;
  102645. }
  102646. /**
  102647. * The effect layer Helps adding post process effect blended with the main pass.
  102648. *
  102649. * This can be for instance use to generate glow or higlight effects on the scene.
  102650. *
  102651. * The effect layer class can not be used directly and is intented to inherited from to be
  102652. * customized per effects.
  102653. */
  102654. export abstract class EffectLayer {
  102655. private _vertexBuffers;
  102656. private _indexBuffer;
  102657. private _cachedDefines;
  102658. private _effectLayerMapGenerationEffect;
  102659. private _effectLayerOptions;
  102660. private _mergeEffect;
  102661. protected _scene: Scene;
  102662. protected _engine: Engine;
  102663. protected _maxSize: number;
  102664. protected _mainTextureDesiredSize: ISize;
  102665. protected _mainTexture: RenderTargetTexture;
  102666. protected _shouldRender: boolean;
  102667. protected _postProcesses: PostProcess[];
  102668. protected _textures: BaseTexture[];
  102669. protected _emissiveTextureAndColor: {
  102670. texture: Nullable<BaseTexture>;
  102671. color: Color4;
  102672. };
  102673. /**
  102674. * The name of the layer
  102675. */
  102676. name: string;
  102677. /**
  102678. * The clear color of the texture used to generate the glow map.
  102679. */
  102680. neutralColor: Color4;
  102681. /**
  102682. * Specifies wether the highlight layer is enabled or not.
  102683. */
  102684. isEnabled: boolean;
  102685. /**
  102686. * Gets the camera attached to the layer.
  102687. */
  102688. readonly camera: Nullable<Camera>;
  102689. /**
  102690. * Gets the rendering group id the layer should render in.
  102691. */
  102692. readonly renderingGroupId: number;
  102693. /**
  102694. * An event triggered when the effect layer has been disposed.
  102695. */
  102696. onDisposeObservable: Observable<EffectLayer>;
  102697. /**
  102698. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  102699. */
  102700. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  102701. /**
  102702. * An event triggered when the generated texture is being merged in the scene.
  102703. */
  102704. onBeforeComposeObservable: Observable<EffectLayer>;
  102705. /**
  102706. * An event triggered when the generated texture has been merged in the scene.
  102707. */
  102708. onAfterComposeObservable: Observable<EffectLayer>;
  102709. /**
  102710. * An event triggered when the efffect layer changes its size.
  102711. */
  102712. onSizeChangedObservable: Observable<EffectLayer>;
  102713. /** @hidden */
  102714. static _SceneComponentInitialization: (scene: Scene) => void;
  102715. /**
  102716. * Instantiates a new effect Layer and references it in the scene.
  102717. * @param name The name of the layer
  102718. * @param scene The scene to use the layer in
  102719. */
  102720. constructor(
  102721. /** The Friendly of the effect in the scene */
  102722. name: string, scene: Scene);
  102723. /**
  102724. * Get the effect name of the layer.
  102725. * @return The effect name
  102726. */
  102727. abstract getEffectName(): string;
  102728. /**
  102729. * Checks for the readiness of the element composing the layer.
  102730. * @param subMesh the mesh to check for
  102731. * @param useInstances specify wether or not to use instances to render the mesh
  102732. * @return true if ready otherwise, false
  102733. */
  102734. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  102735. /**
  102736. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  102737. * @returns true if the effect requires stencil during the main canvas render pass.
  102738. */
  102739. abstract needStencil(): boolean;
  102740. /**
  102741. * Create the merge effect. This is the shader use to blit the information back
  102742. * to the main canvas at the end of the scene rendering.
  102743. * @returns The effect containing the shader used to merge the effect on the main canvas
  102744. */
  102745. protected abstract _createMergeEffect(): Effect;
  102746. /**
  102747. * Creates the render target textures and post processes used in the effect layer.
  102748. */
  102749. protected abstract _createTextureAndPostProcesses(): void;
  102750. /**
  102751. * Implementation specific of rendering the generating effect on the main canvas.
  102752. * @param effect The effect used to render through
  102753. */
  102754. protected abstract _internalRender(effect: Effect): void;
  102755. /**
  102756. * Sets the required values for both the emissive texture and and the main color.
  102757. */
  102758. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  102759. /**
  102760. * Free any resources and references associated to a mesh.
  102761. * Internal use
  102762. * @param mesh The mesh to free.
  102763. */
  102764. abstract _disposeMesh(mesh: Mesh): void;
  102765. /**
  102766. * Serializes this layer (Glow or Highlight for example)
  102767. * @returns a serialized layer object
  102768. */
  102769. abstract serialize?(): any;
  102770. /**
  102771. * Initializes the effect layer with the required options.
  102772. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  102773. */
  102774. protected _init(options: Partial<IEffectLayerOptions>): void;
  102775. /**
  102776. * Generates the index buffer of the full screen quad blending to the main canvas.
  102777. */
  102778. private _generateIndexBuffer;
  102779. /**
  102780. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  102781. */
  102782. private _genrateVertexBuffer;
  102783. /**
  102784. * Sets the main texture desired size which is the closest power of two
  102785. * of the engine canvas size.
  102786. */
  102787. private _setMainTextureSize;
  102788. /**
  102789. * Creates the main texture for the effect layer.
  102790. */
  102791. protected _createMainTexture(): void;
  102792. /**
  102793. * Adds specific effects defines.
  102794. * @param defines The defines to add specifics to.
  102795. */
  102796. protected _addCustomEffectDefines(defines: string[]): void;
  102797. /**
  102798. * Checks for the readiness of the element composing the layer.
  102799. * @param subMesh the mesh to check for
  102800. * @param useInstances specify wether or not to use instances to render the mesh
  102801. * @param emissiveTexture the associated emissive texture used to generate the glow
  102802. * @return true if ready otherwise, false
  102803. */
  102804. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  102805. /**
  102806. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  102807. */
  102808. render(): void;
  102809. /**
  102810. * Determine if a given mesh will be used in the current effect.
  102811. * @param mesh mesh to test
  102812. * @returns true if the mesh will be used
  102813. */
  102814. hasMesh(mesh: AbstractMesh): boolean;
  102815. /**
  102816. * Returns true if the layer contains information to display, otherwise false.
  102817. * @returns true if the glow layer should be rendered
  102818. */
  102819. shouldRender(): boolean;
  102820. /**
  102821. * Returns true if the mesh should render, otherwise false.
  102822. * @param mesh The mesh to render
  102823. * @returns true if it should render otherwise false
  102824. */
  102825. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  102826. /**
  102827. * Returns true if the mesh can be rendered, otherwise false.
  102828. * @param mesh The mesh to render
  102829. * @param material The material used on the mesh
  102830. * @returns true if it can be rendered otherwise false
  102831. */
  102832. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  102833. /**
  102834. * Returns true if the mesh should render, otherwise false.
  102835. * @param mesh The mesh to render
  102836. * @returns true if it should render otherwise false
  102837. */
  102838. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  102839. /**
  102840. * Renders the submesh passed in parameter to the generation map.
  102841. */
  102842. protected _renderSubMesh(subMesh: SubMesh): void;
  102843. /**
  102844. * Rebuild the required buffers.
  102845. * @hidden Internal use only.
  102846. */
  102847. _rebuild(): void;
  102848. /**
  102849. * Dispose only the render target textures and post process.
  102850. */
  102851. private _disposeTextureAndPostProcesses;
  102852. /**
  102853. * Dispose the highlight layer and free resources.
  102854. */
  102855. dispose(): void;
  102856. /**
  102857. * Gets the class name of the effect layer
  102858. * @returns the string with the class name of the effect layer
  102859. */
  102860. getClassName(): string;
  102861. /**
  102862. * Creates an effect layer from parsed effect layer data
  102863. * @param parsedEffectLayer defines effect layer data
  102864. * @param scene defines the current scene
  102865. * @param rootUrl defines the root URL containing the effect layer information
  102866. * @returns a parsed effect Layer
  102867. */
  102868. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  102869. }
  102870. }
  102871. declare module BABYLON {
  102872. interface AbstractScene {
  102873. /**
  102874. * The list of effect layers (highlights/glow) added to the scene
  102875. * @see http://doc.babylonjs.com/how_to/highlight_layer
  102876. * @see http://doc.babylonjs.com/how_to/glow_layer
  102877. */
  102878. effectLayers: Array<EffectLayer>;
  102879. /**
  102880. * Removes the given effect layer from this scene.
  102881. * @param toRemove defines the effect layer to remove
  102882. * @returns the index of the removed effect layer
  102883. */
  102884. removeEffectLayer(toRemove: EffectLayer): number;
  102885. /**
  102886. * Adds the given effect layer to this scene
  102887. * @param newEffectLayer defines the effect layer to add
  102888. */
  102889. addEffectLayer(newEffectLayer: EffectLayer): void;
  102890. }
  102891. /**
  102892. * Defines the layer scene component responsible to manage any effect layers
  102893. * in a given scene.
  102894. */
  102895. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  102896. /**
  102897. * The component name helpfull to identify the component in the list of scene components.
  102898. */
  102899. readonly name: string;
  102900. /**
  102901. * The scene the component belongs to.
  102902. */
  102903. scene: Scene;
  102904. private _engine;
  102905. private _renderEffects;
  102906. private _needStencil;
  102907. private _previousStencilState;
  102908. /**
  102909. * Creates a new instance of the component for the given scene
  102910. * @param scene Defines the scene to register the component in
  102911. */
  102912. constructor(scene: Scene);
  102913. /**
  102914. * Registers the component in a given scene
  102915. */
  102916. register(): void;
  102917. /**
  102918. * Rebuilds the elements related to this component in case of
  102919. * context lost for instance.
  102920. */
  102921. rebuild(): void;
  102922. /**
  102923. * Serializes the component data to the specified json object
  102924. * @param serializationObject The object to serialize to
  102925. */
  102926. serialize(serializationObject: any): void;
  102927. /**
  102928. * Adds all the element from the container to the scene
  102929. * @param container the container holding the elements
  102930. */
  102931. addFromContainer(container: AbstractScene): void;
  102932. /**
  102933. * Removes all the elements in the container from the scene
  102934. * @param container contains the elements to remove
  102935. */
  102936. removeFromContainer(container: AbstractScene): void;
  102937. /**
  102938. * Disposes the component and the associated ressources.
  102939. */
  102940. dispose(): void;
  102941. private _isReadyForMesh;
  102942. private _renderMainTexture;
  102943. private _setStencil;
  102944. private _setStencilBack;
  102945. private _draw;
  102946. private _drawCamera;
  102947. private _drawRenderingGroup;
  102948. }
  102949. }
  102950. declare module BABYLON {
  102951. /** @hidden */
  102952. export var glowMapMergePixelShader: {
  102953. name: string;
  102954. shader: string;
  102955. };
  102956. }
  102957. declare module BABYLON {
  102958. /** @hidden */
  102959. export var glowMapMergeVertexShader: {
  102960. name: string;
  102961. shader: string;
  102962. };
  102963. }
  102964. declare module BABYLON {
  102965. interface AbstractScene {
  102966. /**
  102967. * Return a the first highlight layer of the scene with a given name.
  102968. * @param name The name of the highlight layer to look for.
  102969. * @return The highlight layer if found otherwise null.
  102970. */
  102971. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  102972. }
  102973. /**
  102974. * Glow layer options. This helps customizing the behaviour
  102975. * of the glow layer.
  102976. */
  102977. export interface IGlowLayerOptions {
  102978. /**
  102979. * Multiplication factor apply to the canvas size to compute the render target size
  102980. * used to generated the glowing objects (the smaller the faster).
  102981. */
  102982. mainTextureRatio: number;
  102983. /**
  102984. * Enforces a fixed size texture to ensure resize independant blur.
  102985. */
  102986. mainTextureFixedSize?: number;
  102987. /**
  102988. * How big is the kernel of the blur texture.
  102989. */
  102990. blurKernelSize: number;
  102991. /**
  102992. * The camera attached to the layer.
  102993. */
  102994. camera: Nullable<Camera>;
  102995. /**
  102996. * Enable MSAA by chosing the number of samples.
  102997. */
  102998. mainTextureSamples?: number;
  102999. /**
  103000. * The rendering group to draw the layer in.
  103001. */
  103002. renderingGroupId: number;
  103003. }
  103004. /**
  103005. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  103006. *
  103007. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  103008. * glowy meshes to your scene.
  103009. *
  103010. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  103011. */
  103012. export class GlowLayer extends EffectLayer {
  103013. /**
  103014. * Effect Name of the layer.
  103015. */
  103016. static readonly EffectName: string;
  103017. /**
  103018. * The default blur kernel size used for the glow.
  103019. */
  103020. static DefaultBlurKernelSize: number;
  103021. /**
  103022. * The default texture size ratio used for the glow.
  103023. */
  103024. static DefaultTextureRatio: number;
  103025. /**
  103026. * Sets the kernel size of the blur.
  103027. */
  103028. /**
  103029. * Gets the kernel size of the blur.
  103030. */
  103031. blurKernelSize: number;
  103032. /**
  103033. * Sets the glow intensity.
  103034. */
  103035. /**
  103036. * Gets the glow intensity.
  103037. */
  103038. intensity: number;
  103039. private _options;
  103040. private _intensity;
  103041. private _horizontalBlurPostprocess1;
  103042. private _verticalBlurPostprocess1;
  103043. private _horizontalBlurPostprocess2;
  103044. private _verticalBlurPostprocess2;
  103045. private _blurTexture1;
  103046. private _blurTexture2;
  103047. private _postProcesses1;
  103048. private _postProcesses2;
  103049. private _includedOnlyMeshes;
  103050. private _excludedMeshes;
  103051. /**
  103052. * Callback used to let the user override the color selection on a per mesh basis
  103053. */
  103054. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  103055. /**
  103056. * Callback used to let the user override the texture selection on a per mesh basis
  103057. */
  103058. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  103059. /**
  103060. * Instantiates a new glow Layer and references it to the scene.
  103061. * @param name The name of the layer
  103062. * @param scene The scene to use the layer in
  103063. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  103064. */
  103065. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  103066. /**
  103067. * Get the effect name of the layer.
  103068. * @return The effect name
  103069. */
  103070. getEffectName(): string;
  103071. /**
  103072. * Create the merge effect. This is the shader use to blit the information back
  103073. * to the main canvas at the end of the scene rendering.
  103074. */
  103075. protected _createMergeEffect(): Effect;
  103076. /**
  103077. * Creates the render target textures and post processes used in the glow layer.
  103078. */
  103079. protected _createTextureAndPostProcesses(): void;
  103080. /**
  103081. * Checks for the readiness of the element composing the layer.
  103082. * @param subMesh the mesh to check for
  103083. * @param useInstances specify wether or not to use instances to render the mesh
  103084. * @param emissiveTexture the associated emissive texture used to generate the glow
  103085. * @return true if ready otherwise, false
  103086. */
  103087. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103088. /**
  103089. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  103090. */
  103091. needStencil(): boolean;
  103092. /**
  103093. * Returns true if the mesh can be rendered, otherwise false.
  103094. * @param mesh The mesh to render
  103095. * @param material The material used on the mesh
  103096. * @returns true if it can be rendered otherwise false
  103097. */
  103098. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  103099. /**
  103100. * Implementation specific of rendering the generating effect on the main canvas.
  103101. * @param effect The effect used to render through
  103102. */
  103103. protected _internalRender(effect: Effect): void;
  103104. /**
  103105. * Sets the required values for both the emissive texture and and the main color.
  103106. */
  103107. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  103108. /**
  103109. * Returns true if the mesh should render, otherwise false.
  103110. * @param mesh The mesh to render
  103111. * @returns true if it should render otherwise false
  103112. */
  103113. protected _shouldRenderMesh(mesh: Mesh): boolean;
  103114. /**
  103115. * Adds specific effects defines.
  103116. * @param defines The defines to add specifics to.
  103117. */
  103118. protected _addCustomEffectDefines(defines: string[]): void;
  103119. /**
  103120. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  103121. * @param mesh The mesh to exclude from the glow layer
  103122. */
  103123. addExcludedMesh(mesh: Mesh): void;
  103124. /**
  103125. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  103126. * @param mesh The mesh to remove
  103127. */
  103128. removeExcludedMesh(mesh: Mesh): void;
  103129. /**
  103130. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  103131. * @param mesh The mesh to include in the glow layer
  103132. */
  103133. addIncludedOnlyMesh(mesh: Mesh): void;
  103134. /**
  103135. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  103136. * @param mesh The mesh to remove
  103137. */
  103138. removeIncludedOnlyMesh(mesh: Mesh): void;
  103139. /**
  103140. * Determine if a given mesh will be used in the glow layer
  103141. * @param mesh The mesh to test
  103142. * @returns true if the mesh will be highlighted by the current glow layer
  103143. */
  103144. hasMesh(mesh: AbstractMesh): boolean;
  103145. /**
  103146. * Free any resources and references associated to a mesh.
  103147. * Internal use
  103148. * @param mesh The mesh to free.
  103149. * @hidden
  103150. */
  103151. _disposeMesh(mesh: Mesh): void;
  103152. /**
  103153. * Gets the class name of the effect layer
  103154. * @returns the string with the class name of the effect layer
  103155. */
  103156. getClassName(): string;
  103157. /**
  103158. * Serializes this glow layer
  103159. * @returns a serialized glow layer object
  103160. */
  103161. serialize(): any;
  103162. /**
  103163. * Creates a Glow Layer from parsed glow layer data
  103164. * @param parsedGlowLayer defines glow layer data
  103165. * @param scene defines the current scene
  103166. * @param rootUrl defines the root URL containing the glow layer information
  103167. * @returns a parsed Glow Layer
  103168. */
  103169. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  103170. }
  103171. }
  103172. declare module BABYLON {
  103173. /** @hidden */
  103174. export var glowBlurPostProcessPixelShader: {
  103175. name: string;
  103176. shader: string;
  103177. };
  103178. }
  103179. declare module BABYLON {
  103180. interface AbstractScene {
  103181. /**
  103182. * Return a the first highlight layer of the scene with a given name.
  103183. * @param name The name of the highlight layer to look for.
  103184. * @return The highlight layer if found otherwise null.
  103185. */
  103186. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  103187. }
  103188. /**
  103189. * Highlight layer options. This helps customizing the behaviour
  103190. * of the highlight layer.
  103191. */
  103192. export interface IHighlightLayerOptions {
  103193. /**
  103194. * Multiplication factor apply to the canvas size to compute the render target size
  103195. * used to generated the glowing objects (the smaller the faster).
  103196. */
  103197. mainTextureRatio: number;
  103198. /**
  103199. * Enforces a fixed size texture to ensure resize independant blur.
  103200. */
  103201. mainTextureFixedSize?: number;
  103202. /**
  103203. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  103204. * of the picture to blur (the smaller the faster).
  103205. */
  103206. blurTextureSizeRatio: number;
  103207. /**
  103208. * How big in texel of the blur texture is the vertical blur.
  103209. */
  103210. blurVerticalSize: number;
  103211. /**
  103212. * How big in texel of the blur texture is the horizontal blur.
  103213. */
  103214. blurHorizontalSize: number;
  103215. /**
  103216. * Alpha blending mode used to apply the blur. Default is combine.
  103217. */
  103218. alphaBlendingMode: number;
  103219. /**
  103220. * The camera attached to the layer.
  103221. */
  103222. camera: Nullable<Camera>;
  103223. /**
  103224. * Should we display highlight as a solid stroke?
  103225. */
  103226. isStroke?: boolean;
  103227. /**
  103228. * The rendering group to draw the layer in.
  103229. */
  103230. renderingGroupId: number;
  103231. }
  103232. /**
  103233. * The highlight layer Helps adding a glow effect around a mesh.
  103234. *
  103235. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  103236. * glowy meshes to your scene.
  103237. *
  103238. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  103239. */
  103240. export class HighlightLayer extends EffectLayer {
  103241. name: string;
  103242. /**
  103243. * Effect Name of the highlight layer.
  103244. */
  103245. static readonly EffectName: string;
  103246. /**
  103247. * The neutral color used during the preparation of the glow effect.
  103248. * This is black by default as the blend operation is a blend operation.
  103249. */
  103250. static NeutralColor: Color4;
  103251. /**
  103252. * Stencil value used for glowing meshes.
  103253. */
  103254. static GlowingMeshStencilReference: number;
  103255. /**
  103256. * Stencil value used for the other meshes in the scene.
  103257. */
  103258. static NormalMeshStencilReference: number;
  103259. /**
  103260. * Specifies whether or not the inner glow is ACTIVE in the layer.
  103261. */
  103262. innerGlow: boolean;
  103263. /**
  103264. * Specifies whether or not the outer glow is ACTIVE in the layer.
  103265. */
  103266. outerGlow: boolean;
  103267. /**
  103268. * Specifies the horizontal size of the blur.
  103269. */
  103270. /**
  103271. * Gets the horizontal size of the blur.
  103272. */
  103273. blurHorizontalSize: number;
  103274. /**
  103275. * Specifies the vertical size of the blur.
  103276. */
  103277. /**
  103278. * Gets the vertical size of the blur.
  103279. */
  103280. blurVerticalSize: number;
  103281. /**
  103282. * An event triggered when the highlight layer is being blurred.
  103283. */
  103284. onBeforeBlurObservable: Observable<HighlightLayer>;
  103285. /**
  103286. * An event triggered when the highlight layer has been blurred.
  103287. */
  103288. onAfterBlurObservable: Observable<HighlightLayer>;
  103289. private _instanceGlowingMeshStencilReference;
  103290. private _options;
  103291. private _downSamplePostprocess;
  103292. private _horizontalBlurPostprocess;
  103293. private _verticalBlurPostprocess;
  103294. private _blurTexture;
  103295. private _meshes;
  103296. private _excludedMeshes;
  103297. /**
  103298. * Instantiates a new highlight Layer and references it to the scene..
  103299. * @param name The name of the layer
  103300. * @param scene The scene to use the layer in
  103301. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  103302. */
  103303. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  103304. /**
  103305. * Get the effect name of the layer.
  103306. * @return The effect name
  103307. */
  103308. getEffectName(): string;
  103309. /**
  103310. * Create the merge effect. This is the shader use to blit the information back
  103311. * to the main canvas at the end of the scene rendering.
  103312. */
  103313. protected _createMergeEffect(): Effect;
  103314. /**
  103315. * Creates the render target textures and post processes used in the highlight layer.
  103316. */
  103317. protected _createTextureAndPostProcesses(): void;
  103318. /**
  103319. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  103320. */
  103321. needStencil(): boolean;
  103322. /**
  103323. * Checks for the readiness of the element composing the layer.
  103324. * @param subMesh the mesh to check for
  103325. * @param useInstances specify wether or not to use instances to render the mesh
  103326. * @param emissiveTexture the associated emissive texture used to generate the glow
  103327. * @return true if ready otherwise, false
  103328. */
  103329. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103330. /**
  103331. * Implementation specific of rendering the generating effect on the main canvas.
  103332. * @param effect The effect used to render through
  103333. */
  103334. protected _internalRender(effect: Effect): void;
  103335. /**
  103336. * Returns true if the layer contains information to display, otherwise false.
  103337. */
  103338. shouldRender(): boolean;
  103339. /**
  103340. * Returns true if the mesh should render, otherwise false.
  103341. * @param mesh The mesh to render
  103342. * @returns true if it should render otherwise false
  103343. */
  103344. protected _shouldRenderMesh(mesh: Mesh): boolean;
  103345. /**
  103346. * Sets the required values for both the emissive texture and and the main color.
  103347. */
  103348. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  103349. /**
  103350. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  103351. * @param mesh The mesh to exclude from the highlight layer
  103352. */
  103353. addExcludedMesh(mesh: Mesh): void;
  103354. /**
  103355. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  103356. * @param mesh The mesh to highlight
  103357. */
  103358. removeExcludedMesh(mesh: Mesh): void;
  103359. /**
  103360. * Determine if a given mesh will be highlighted by the current HighlightLayer
  103361. * @param mesh mesh to test
  103362. * @returns true if the mesh will be highlighted by the current HighlightLayer
  103363. */
  103364. hasMesh(mesh: AbstractMesh): boolean;
  103365. /**
  103366. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  103367. * @param mesh The mesh to highlight
  103368. * @param color The color of the highlight
  103369. * @param glowEmissiveOnly Extract the glow from the emissive texture
  103370. */
  103371. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  103372. /**
  103373. * Remove a mesh from the highlight layer in order to make it stop glowing.
  103374. * @param mesh The mesh to highlight
  103375. */
  103376. removeMesh(mesh: Mesh): void;
  103377. /**
  103378. * Force the stencil to the normal expected value for none glowing parts
  103379. */
  103380. private _defaultStencilReference;
  103381. /**
  103382. * Free any resources and references associated to a mesh.
  103383. * Internal use
  103384. * @param mesh The mesh to free.
  103385. * @hidden
  103386. */
  103387. _disposeMesh(mesh: Mesh): void;
  103388. /**
  103389. * Dispose the highlight layer and free resources.
  103390. */
  103391. dispose(): void;
  103392. /**
  103393. * Gets the class name of the effect layer
  103394. * @returns the string with the class name of the effect layer
  103395. */
  103396. getClassName(): string;
  103397. /**
  103398. * Serializes this Highlight layer
  103399. * @returns a serialized Highlight layer object
  103400. */
  103401. serialize(): any;
  103402. /**
  103403. * Creates a Highlight layer from parsed Highlight layer data
  103404. * @param parsedHightlightLayer defines the Highlight layer data
  103405. * @param scene defines the current scene
  103406. * @param rootUrl defines the root URL containing the Highlight layer information
  103407. * @returns a parsed Highlight layer
  103408. */
  103409. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  103410. }
  103411. }
  103412. declare module BABYLON {
  103413. /** @hidden */
  103414. export var lensFlarePixelShader: {
  103415. name: string;
  103416. shader: string;
  103417. };
  103418. }
  103419. declare module BABYLON {
  103420. /** @hidden */
  103421. export var lensFlareVertexShader: {
  103422. name: string;
  103423. shader: string;
  103424. };
  103425. }
  103426. declare module BABYLON {
  103427. /**
  103428. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  103429. * It is usually composed of several `lensFlare`.
  103430. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103431. */
  103432. export class LensFlareSystem {
  103433. /**
  103434. * Define the name of the lens flare system
  103435. */
  103436. name: string;
  103437. /**
  103438. * List of lens flares used in this system.
  103439. */
  103440. lensFlares: LensFlare[];
  103441. /**
  103442. * Define a limit from the border the lens flare can be visible.
  103443. */
  103444. borderLimit: number;
  103445. /**
  103446. * Define a viewport border we do not want to see the lens flare in.
  103447. */
  103448. viewportBorder: number;
  103449. /**
  103450. * Define a predicate which could limit the list of meshes able to occlude the effect.
  103451. */
  103452. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  103453. /**
  103454. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  103455. */
  103456. layerMask: number;
  103457. /**
  103458. * Define the id of the lens flare system in the scene.
  103459. * (equal to name by default)
  103460. */
  103461. id: string;
  103462. private _scene;
  103463. private _emitter;
  103464. private _vertexBuffers;
  103465. private _indexBuffer;
  103466. private _effect;
  103467. private _positionX;
  103468. private _positionY;
  103469. private _isEnabled;
  103470. /** @hidden */
  103471. static _SceneComponentInitialization: (scene: Scene) => void;
  103472. /**
  103473. * Instantiates a lens flare system.
  103474. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  103475. * It is usually composed of several `lensFlare`.
  103476. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103477. * @param name Define the name of the lens flare system in the scene
  103478. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  103479. * @param scene Define the scene the lens flare system belongs to
  103480. */
  103481. constructor(
  103482. /**
  103483. * Define the name of the lens flare system
  103484. */
  103485. name: string, emitter: any, scene: Scene);
  103486. /**
  103487. * Define if the lens flare system is enabled.
  103488. */
  103489. isEnabled: boolean;
  103490. /**
  103491. * Get the scene the effects belongs to.
  103492. * @returns the scene holding the lens flare system
  103493. */
  103494. getScene(): Scene;
  103495. /**
  103496. * Get the emitter of the lens flare system.
  103497. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  103498. * @returns the emitter of the lens flare system
  103499. */
  103500. getEmitter(): any;
  103501. /**
  103502. * Set the emitter of the lens flare system.
  103503. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  103504. * @param newEmitter Define the new emitter of the system
  103505. */
  103506. setEmitter(newEmitter: any): void;
  103507. /**
  103508. * Get the lens flare system emitter position.
  103509. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  103510. * @returns the position
  103511. */
  103512. getEmitterPosition(): Vector3;
  103513. /**
  103514. * @hidden
  103515. */
  103516. computeEffectivePosition(globalViewport: Viewport): boolean;
  103517. /** @hidden */
  103518. _isVisible(): boolean;
  103519. /**
  103520. * @hidden
  103521. */
  103522. render(): boolean;
  103523. /**
  103524. * Dispose and release the lens flare with its associated resources.
  103525. */
  103526. dispose(): void;
  103527. /**
  103528. * Parse a lens flare system from a JSON repressentation
  103529. * @param parsedLensFlareSystem Define the JSON to parse
  103530. * @param scene Define the scene the parsed system should be instantiated in
  103531. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  103532. * @returns the parsed system
  103533. */
  103534. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  103535. /**
  103536. * Serialize the current Lens Flare System into a JSON representation.
  103537. * @returns the serialized JSON
  103538. */
  103539. serialize(): any;
  103540. }
  103541. }
  103542. declare module BABYLON {
  103543. /**
  103544. * This represents one of the lens effect in a `lensFlareSystem`.
  103545. * It controls one of the indiviual texture used in the effect.
  103546. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103547. */
  103548. export class LensFlare {
  103549. /**
  103550. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  103551. */
  103552. size: number;
  103553. /**
  103554. * 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.
  103555. */
  103556. position: number;
  103557. /**
  103558. * Define the lens color.
  103559. */
  103560. color: Color3;
  103561. /**
  103562. * Define the lens texture.
  103563. */
  103564. texture: Nullable<Texture>;
  103565. /**
  103566. * Define the alpha mode to render this particular lens.
  103567. */
  103568. alphaMode: number;
  103569. private _system;
  103570. /**
  103571. * Creates a new Lens Flare.
  103572. * This represents one of the lens effect in a `lensFlareSystem`.
  103573. * It controls one of the indiviual texture used in the effect.
  103574. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103575. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  103576. * @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.
  103577. * @param color Define the lens color
  103578. * @param imgUrl Define the lens texture url
  103579. * @param system Define the `lensFlareSystem` this flare is part of
  103580. * @returns The newly created Lens Flare
  103581. */
  103582. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  103583. /**
  103584. * Instantiates a new Lens Flare.
  103585. * This represents one of the lens effect in a `lensFlareSystem`.
  103586. * It controls one of the indiviual texture used in the effect.
  103587. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103588. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  103589. * @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.
  103590. * @param color Define the lens color
  103591. * @param imgUrl Define the lens texture url
  103592. * @param system Define the `lensFlareSystem` this flare is part of
  103593. */
  103594. constructor(
  103595. /**
  103596. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  103597. */
  103598. size: number,
  103599. /**
  103600. * 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.
  103601. */
  103602. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  103603. /**
  103604. * Dispose and release the lens flare with its associated resources.
  103605. */
  103606. dispose(): void;
  103607. }
  103608. }
  103609. declare module BABYLON {
  103610. interface AbstractScene {
  103611. /**
  103612. * The list of lens flare system added to the scene
  103613. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103614. */
  103615. lensFlareSystems: Array<LensFlareSystem>;
  103616. /**
  103617. * Removes the given lens flare system from this scene.
  103618. * @param toRemove The lens flare system to remove
  103619. * @returns The index of the removed lens flare system
  103620. */
  103621. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  103622. /**
  103623. * Adds the given lens flare system to this scene
  103624. * @param newLensFlareSystem The lens flare system to add
  103625. */
  103626. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  103627. /**
  103628. * Gets a lens flare system using its name
  103629. * @param name defines the name to look for
  103630. * @returns the lens flare system or null if not found
  103631. */
  103632. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  103633. /**
  103634. * Gets a lens flare system using its id
  103635. * @param id defines the id to look for
  103636. * @returns the lens flare system or null if not found
  103637. */
  103638. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  103639. }
  103640. /**
  103641. * Defines the lens flare scene component responsible to manage any lens flares
  103642. * in a given scene.
  103643. */
  103644. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  103645. /**
  103646. * The component name helpfull to identify the component in the list of scene components.
  103647. */
  103648. readonly name: string;
  103649. /**
  103650. * The scene the component belongs to.
  103651. */
  103652. scene: Scene;
  103653. /**
  103654. * Creates a new instance of the component for the given scene
  103655. * @param scene Defines the scene to register the component in
  103656. */
  103657. constructor(scene: Scene);
  103658. /**
  103659. * Registers the component in a given scene
  103660. */
  103661. register(): void;
  103662. /**
  103663. * Rebuilds the elements related to this component in case of
  103664. * context lost for instance.
  103665. */
  103666. rebuild(): void;
  103667. /**
  103668. * Adds all the element from the container to the scene
  103669. * @param container the container holding the elements
  103670. */
  103671. addFromContainer(container: AbstractScene): void;
  103672. /**
  103673. * Removes all the elements in the container from the scene
  103674. * @param container contains the elements to remove
  103675. */
  103676. removeFromContainer(container: AbstractScene): void;
  103677. /**
  103678. * Serializes the component data to the specified json object
  103679. * @param serializationObject The object to serialize to
  103680. */
  103681. serialize(serializationObject: any): void;
  103682. /**
  103683. * Disposes the component and the associated ressources.
  103684. */
  103685. dispose(): void;
  103686. private _draw;
  103687. }
  103688. }
  103689. declare module BABYLON {
  103690. /**
  103691. * Defines the shadow generator component responsible to manage any shadow generators
  103692. * in a given scene.
  103693. */
  103694. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  103695. /**
  103696. * The component name helpfull to identify the component in the list of scene components.
  103697. */
  103698. readonly name: string;
  103699. /**
  103700. * The scene the component belongs to.
  103701. */
  103702. scene: Scene;
  103703. /**
  103704. * Creates a new instance of the component for the given scene
  103705. * @param scene Defines the scene to register the component in
  103706. */
  103707. constructor(scene: Scene);
  103708. /**
  103709. * Registers the component in a given scene
  103710. */
  103711. register(): void;
  103712. /**
  103713. * Rebuilds the elements related to this component in case of
  103714. * context lost for instance.
  103715. */
  103716. rebuild(): void;
  103717. /**
  103718. * Serializes the component data to the specified json object
  103719. * @param serializationObject The object to serialize to
  103720. */
  103721. serialize(serializationObject: any): void;
  103722. /**
  103723. * Adds all the element from the container to the scene
  103724. * @param container the container holding the elements
  103725. */
  103726. addFromContainer(container: AbstractScene): void;
  103727. /**
  103728. * Removes all the elements in the container from the scene
  103729. * @param container contains the elements to remove
  103730. */
  103731. removeFromContainer(container: AbstractScene): void;
  103732. /**
  103733. * Rebuilds the elements related to this component in case of
  103734. * context lost for instance.
  103735. */
  103736. dispose(): void;
  103737. private _gatherRenderTargets;
  103738. }
  103739. }
  103740. declare module BABYLON {
  103741. /**
  103742. * A directional light is defined by a direction (what a surprise!).
  103743. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  103744. * 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.
  103745. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103746. */
  103747. export class DirectionalLight extends ShadowLight {
  103748. private _shadowFrustumSize;
  103749. /**
  103750. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  103751. */
  103752. /**
  103753. * Specifies a fix frustum size for the shadow generation.
  103754. */
  103755. shadowFrustumSize: number;
  103756. private _shadowOrthoScale;
  103757. /**
  103758. * Gets the shadow projection scale against the optimal computed one.
  103759. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  103760. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  103761. */
  103762. /**
  103763. * Sets the shadow projection scale against the optimal computed one.
  103764. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  103765. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  103766. */
  103767. shadowOrthoScale: number;
  103768. /**
  103769. * Automatically compute the projection matrix to best fit (including all the casters)
  103770. * on each frame.
  103771. */
  103772. autoUpdateExtends: boolean;
  103773. private _orthoLeft;
  103774. private _orthoRight;
  103775. private _orthoTop;
  103776. private _orthoBottom;
  103777. /**
  103778. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  103779. * The directional light is emitted from everywhere in the given direction.
  103780. * It can cast shadows.
  103781. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103782. * @param name The friendly name of the light
  103783. * @param direction The direction of the light
  103784. * @param scene The scene the light belongs to
  103785. */
  103786. constructor(name: string, direction: Vector3, scene: Scene);
  103787. /**
  103788. * Returns the string "DirectionalLight".
  103789. * @return The class name
  103790. */
  103791. getClassName(): string;
  103792. /**
  103793. * Returns the integer 1.
  103794. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103795. */
  103796. getTypeID(): number;
  103797. /**
  103798. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  103799. * Returns the DirectionalLight Shadow projection matrix.
  103800. */
  103801. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103802. /**
  103803. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  103804. * Returns the DirectionalLight Shadow projection matrix.
  103805. */
  103806. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  103807. /**
  103808. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  103809. * Returns the DirectionalLight Shadow projection matrix.
  103810. */
  103811. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103812. protected _buildUniformLayout(): void;
  103813. /**
  103814. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  103815. * @param effect The effect to update
  103816. * @param lightIndex The index of the light in the effect to update
  103817. * @returns The directional light
  103818. */
  103819. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  103820. /**
  103821. * Gets the minZ used for shadow according to both the scene and the light.
  103822. *
  103823. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  103824. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  103825. * @param activeCamera The camera we are returning the min for
  103826. * @returns the depth min z
  103827. */
  103828. getDepthMinZ(activeCamera: Camera): number;
  103829. /**
  103830. * Gets the maxZ used for shadow according to both the scene and the light.
  103831. *
  103832. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  103833. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  103834. * @param activeCamera The camera we are returning the max for
  103835. * @returns the depth max z
  103836. */
  103837. getDepthMaxZ(activeCamera: Camera): number;
  103838. /**
  103839. * Prepares the list of defines specific to the light type.
  103840. * @param defines the list of defines
  103841. * @param lightIndex defines the index of the light for the effect
  103842. */
  103843. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103844. }
  103845. }
  103846. declare module BABYLON {
  103847. /**
  103848. * A point light is a light defined by an unique point in world space.
  103849. * The light is emitted in every direction from this point.
  103850. * A good example of a point light is a standard light bulb.
  103851. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103852. */
  103853. export class PointLight extends ShadowLight {
  103854. private _shadowAngle;
  103855. /**
  103856. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103857. * This specifies what angle the shadow will use to be created.
  103858. *
  103859. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  103860. */
  103861. /**
  103862. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103863. * This specifies what angle the shadow will use to be created.
  103864. *
  103865. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  103866. */
  103867. shadowAngle: number;
  103868. /**
  103869. * Gets the direction if it has been set.
  103870. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103871. */
  103872. /**
  103873. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103874. */
  103875. direction: Vector3;
  103876. /**
  103877. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  103878. * A PointLight emits the light in every direction.
  103879. * It can cast shadows.
  103880. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  103881. * ```javascript
  103882. * var pointLight = new PointLight("pl", camera.position, scene);
  103883. * ```
  103884. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103885. * @param name The light friendly name
  103886. * @param position The position of the point light in the scene
  103887. * @param scene The scene the lights belongs to
  103888. */
  103889. constructor(name: string, position: Vector3, scene: Scene);
  103890. /**
  103891. * Returns the string "PointLight"
  103892. * @returns the class name
  103893. */
  103894. getClassName(): string;
  103895. /**
  103896. * Returns the integer 0.
  103897. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103898. */
  103899. getTypeID(): number;
  103900. /**
  103901. * Specifies wether or not the shadowmap should be a cube texture.
  103902. * @returns true if the shadowmap needs to be a cube texture.
  103903. */
  103904. needCube(): boolean;
  103905. /**
  103906. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  103907. * @param faceIndex The index of the face we are computed the direction to generate shadow
  103908. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  103909. */
  103910. getShadowDirection(faceIndex?: number): Vector3;
  103911. /**
  103912. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  103913. * - fov = PI / 2
  103914. * - aspect ratio : 1.0
  103915. * - z-near and far equal to the active camera minZ and maxZ.
  103916. * Returns the PointLight.
  103917. */
  103918. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103919. protected _buildUniformLayout(): void;
  103920. /**
  103921. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  103922. * @param effect The effect to update
  103923. * @param lightIndex The index of the light in the effect to update
  103924. * @returns The point light
  103925. */
  103926. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  103927. /**
  103928. * Prepares the list of defines specific to the light type.
  103929. * @param defines the list of defines
  103930. * @param lightIndex defines the index of the light for the effect
  103931. */
  103932. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103933. }
  103934. }
  103935. declare module BABYLON {
  103936. /**
  103937. * A spot light is defined by a position, a direction, an angle, and an exponent.
  103938. * These values define a cone of light starting from the position, emitting toward the direction.
  103939. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  103940. * and the exponent defines the speed of the decay of the light with distance (reach).
  103941. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103942. */
  103943. export class SpotLight extends ShadowLight {
  103944. private _angle;
  103945. private _innerAngle;
  103946. private _cosHalfAngle;
  103947. private _lightAngleScale;
  103948. private _lightAngleOffset;
  103949. /**
  103950. * Gets the cone angle of the spot light in Radians.
  103951. */
  103952. /**
  103953. * Sets the cone angle of the spot light in Radians.
  103954. */
  103955. angle: number;
  103956. /**
  103957. * Only used in gltf falloff mode, this defines the angle where
  103958. * the directional falloff will start before cutting at angle which could be seen
  103959. * as outer angle.
  103960. */
  103961. /**
  103962. * Only used in gltf falloff mode, this defines the angle where
  103963. * the directional falloff will start before cutting at angle which could be seen
  103964. * as outer angle.
  103965. */
  103966. innerAngle: number;
  103967. private _shadowAngleScale;
  103968. /**
  103969. * Allows scaling the angle of the light for shadow generation only.
  103970. */
  103971. /**
  103972. * Allows scaling the angle of the light for shadow generation only.
  103973. */
  103974. shadowAngleScale: number;
  103975. /**
  103976. * The light decay speed with the distance from the emission spot.
  103977. */
  103978. exponent: number;
  103979. private _projectionTextureMatrix;
  103980. /**
  103981. * Allows reading the projecton texture
  103982. */
  103983. readonly projectionTextureMatrix: Matrix;
  103984. protected _projectionTextureLightNear: number;
  103985. /**
  103986. * Gets the near clip of the Spotlight for texture projection.
  103987. */
  103988. /**
  103989. * Sets the near clip of the Spotlight for texture projection.
  103990. */
  103991. projectionTextureLightNear: number;
  103992. protected _projectionTextureLightFar: number;
  103993. /**
  103994. * Gets the far clip of the Spotlight for texture projection.
  103995. */
  103996. /**
  103997. * Sets the far clip of the Spotlight for texture projection.
  103998. */
  103999. projectionTextureLightFar: number;
  104000. protected _projectionTextureUpDirection: Vector3;
  104001. /**
  104002. * Gets the Up vector of the Spotlight for texture projection.
  104003. */
  104004. /**
  104005. * Sets the Up vector of the Spotlight for texture projection.
  104006. */
  104007. projectionTextureUpDirection: Vector3;
  104008. private _projectionTexture;
  104009. /**
  104010. * Gets the projection texture of the light.
  104011. */
  104012. /**
  104013. * Sets the projection texture of the light.
  104014. */
  104015. projectionTexture: Nullable<BaseTexture>;
  104016. private _projectionTextureViewLightDirty;
  104017. private _projectionTextureProjectionLightDirty;
  104018. private _projectionTextureDirty;
  104019. private _projectionTextureViewTargetVector;
  104020. private _projectionTextureViewLightMatrix;
  104021. private _projectionTextureProjectionLightMatrix;
  104022. private _projectionTextureScalingMatrix;
  104023. /**
  104024. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  104025. * It can cast shadows.
  104026. * Documentation : https://doc.babylonjs.com/babylon101/lights
  104027. * @param name The light friendly name
  104028. * @param position The position of the spot light in the scene
  104029. * @param direction The direction of the light in the scene
  104030. * @param angle The cone angle of the light in Radians
  104031. * @param exponent The light decay speed with the distance from the emission spot
  104032. * @param scene The scene the lights belongs to
  104033. */
  104034. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  104035. /**
  104036. * Returns the string "SpotLight".
  104037. * @returns the class name
  104038. */
  104039. getClassName(): string;
  104040. /**
  104041. * Returns the integer 2.
  104042. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  104043. */
  104044. getTypeID(): number;
  104045. /**
  104046. * Overrides the direction setter to recompute the projection texture view light Matrix.
  104047. */
  104048. protected _setDirection(value: Vector3): void;
  104049. /**
  104050. * Overrides the position setter to recompute the projection texture view light Matrix.
  104051. */
  104052. protected _setPosition(value: Vector3): void;
  104053. /**
  104054. * 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.
  104055. * Returns the SpotLight.
  104056. */
  104057. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104058. protected _computeProjectionTextureViewLightMatrix(): void;
  104059. protected _computeProjectionTextureProjectionLightMatrix(): void;
  104060. /**
  104061. * Main function for light texture projection matrix computing.
  104062. */
  104063. protected _computeProjectionTextureMatrix(): void;
  104064. protected _buildUniformLayout(): void;
  104065. private _computeAngleValues;
  104066. /**
  104067. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  104068. * @param effect The effect to update
  104069. * @param lightIndex The index of the light in the effect to update
  104070. * @returns The spot light
  104071. */
  104072. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  104073. /**
  104074. * Disposes the light and the associated resources.
  104075. */
  104076. dispose(): void;
  104077. /**
  104078. * Prepares the list of defines specific to the light type.
  104079. * @param defines the list of defines
  104080. * @param lightIndex defines the index of the light for the effect
  104081. */
  104082. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  104083. }
  104084. }
  104085. declare module BABYLON {
  104086. /**
  104087. * Header information of HDR texture files.
  104088. */
  104089. export interface HDRInfo {
  104090. /**
  104091. * The height of the texture in pixels.
  104092. */
  104093. height: number;
  104094. /**
  104095. * The width of the texture in pixels.
  104096. */
  104097. width: number;
  104098. /**
  104099. * The index of the beginning of the data in the binary file.
  104100. */
  104101. dataPosition: number;
  104102. }
  104103. /**
  104104. * This groups tools to convert HDR texture to native colors array.
  104105. */
  104106. export class HDRTools {
  104107. private static Ldexp;
  104108. private static Rgbe2float;
  104109. private static readStringLine;
  104110. /**
  104111. * Reads header information from an RGBE texture stored in a native array.
  104112. * More information on this format are available here:
  104113. * https://en.wikipedia.org/wiki/RGBE_image_format
  104114. *
  104115. * @param uint8array The binary file stored in native array.
  104116. * @return The header information.
  104117. */
  104118. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  104119. /**
  104120. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  104121. * This RGBE texture needs to store the information as a panorama.
  104122. *
  104123. * More information on this format are available here:
  104124. * https://en.wikipedia.org/wiki/RGBE_image_format
  104125. *
  104126. * @param buffer The binary file stored in an array buffer.
  104127. * @param size The expected size of the extracted cubemap.
  104128. * @return The Cube Map information.
  104129. */
  104130. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  104131. /**
  104132. * Returns the pixels data extracted from an RGBE texture.
  104133. * This pixels will be stored left to right up to down in the R G B order in one array.
  104134. *
  104135. * More information on this format are available here:
  104136. * https://en.wikipedia.org/wiki/RGBE_image_format
  104137. *
  104138. * @param uint8array The binary file stored in an array buffer.
  104139. * @param hdrInfo The header information of the file.
  104140. * @return The pixels data in RGB right to left up to down order.
  104141. */
  104142. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  104143. private static RGBE_ReadPixels_RLE;
  104144. }
  104145. }
  104146. declare module BABYLON {
  104147. /**
  104148. * This represents a texture coming from an HDR input.
  104149. *
  104150. * The only supported format is currently panorama picture stored in RGBE format.
  104151. * Example of such files can be found on HDRLib: http://hdrlib.com/
  104152. */
  104153. export class HDRCubeTexture extends BaseTexture {
  104154. private static _facesMapping;
  104155. private _generateHarmonics;
  104156. private _noMipmap;
  104157. private _textureMatrix;
  104158. private _size;
  104159. private _onLoad;
  104160. private _onError;
  104161. /**
  104162. * The texture URL.
  104163. */
  104164. url: string;
  104165. /**
  104166. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  104167. */
  104168. coordinatesMode: number;
  104169. protected _isBlocking: boolean;
  104170. /**
  104171. * Sets wether or not the texture is blocking during loading.
  104172. */
  104173. /**
  104174. * Gets wether or not the texture is blocking during loading.
  104175. */
  104176. isBlocking: boolean;
  104177. protected _rotationY: number;
  104178. /**
  104179. * Sets texture matrix rotation angle around Y axis in radians.
  104180. */
  104181. /**
  104182. * Gets texture matrix rotation angle around Y axis radians.
  104183. */
  104184. rotationY: number;
  104185. /**
  104186. * Gets or sets the center of the bounding box associated with the cube texture
  104187. * It must define where the camera used to render the texture was set
  104188. */
  104189. boundingBoxPosition: Vector3;
  104190. private _boundingBoxSize;
  104191. /**
  104192. * Gets or sets the size of the bounding box associated with the cube texture
  104193. * When defined, the cubemap will switch to local mode
  104194. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  104195. * @example https://www.babylonjs-playground.com/#RNASML
  104196. */
  104197. boundingBoxSize: Vector3;
  104198. /**
  104199. * Instantiates an HDRTexture from the following parameters.
  104200. *
  104201. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  104202. * @param scene The scene the texture will be used in
  104203. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  104204. * @param noMipmap Forces to not generate the mipmap if true
  104205. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  104206. * @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)
  104207. * @param reserved Reserved flag for internal use.
  104208. */
  104209. 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>);
  104210. /**
  104211. * Get the current class name of the texture useful for serialization or dynamic coding.
  104212. * @returns "HDRCubeTexture"
  104213. */
  104214. getClassName(): string;
  104215. /**
  104216. * Occurs when the file is raw .hdr file.
  104217. */
  104218. private loadTexture;
  104219. clone(): HDRCubeTexture;
  104220. delayLoad(): void;
  104221. /**
  104222. * Get the texture reflection matrix used to rotate/transform the reflection.
  104223. * @returns the reflection matrix
  104224. */
  104225. getReflectionTextureMatrix(): Matrix;
  104226. /**
  104227. * Set the texture reflection matrix used to rotate/transform the reflection.
  104228. * @param value Define the reflection matrix to set
  104229. */
  104230. setReflectionTextureMatrix(value: Matrix): void;
  104231. /**
  104232. * Parses a JSON representation of an HDR Texture in order to create the texture
  104233. * @param parsedTexture Define the JSON representation
  104234. * @param scene Define the scene the texture should be created in
  104235. * @param rootUrl Define the root url in case we need to load relative dependencies
  104236. * @returns the newly created texture after parsing
  104237. */
  104238. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  104239. serialize(): any;
  104240. }
  104241. }
  104242. declare module BABYLON {
  104243. /**
  104244. * Class used to control physics engine
  104245. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  104246. */
  104247. export class PhysicsEngine implements IPhysicsEngine {
  104248. private _physicsPlugin;
  104249. /**
  104250. * Global value used to control the smallest number supported by the simulation
  104251. */
  104252. static Epsilon: number;
  104253. private _impostors;
  104254. private _joints;
  104255. /**
  104256. * Gets the gravity vector used by the simulation
  104257. */
  104258. gravity: Vector3;
  104259. /**
  104260. * Factory used to create the default physics plugin.
  104261. * @returns The default physics plugin
  104262. */
  104263. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  104264. /**
  104265. * Creates a new Physics Engine
  104266. * @param gravity defines the gravity vector used by the simulation
  104267. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  104268. */
  104269. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  104270. /**
  104271. * Sets the gravity vector used by the simulation
  104272. * @param gravity defines the gravity vector to use
  104273. */
  104274. setGravity(gravity: Vector3): void;
  104275. /**
  104276. * Set the time step of the physics engine.
  104277. * Default is 1/60.
  104278. * To slow it down, enter 1/600 for example.
  104279. * To speed it up, 1/30
  104280. * @param newTimeStep defines the new timestep to apply to this world.
  104281. */
  104282. setTimeStep(newTimeStep?: number): void;
  104283. /**
  104284. * Get the time step of the physics engine.
  104285. * @returns the current time step
  104286. */
  104287. getTimeStep(): number;
  104288. /**
  104289. * Release all resources
  104290. */
  104291. dispose(): void;
  104292. /**
  104293. * Gets the name of the current physics plugin
  104294. * @returns the name of the plugin
  104295. */
  104296. getPhysicsPluginName(): string;
  104297. /**
  104298. * Adding a new impostor for the impostor tracking.
  104299. * This will be done by the impostor itself.
  104300. * @param impostor the impostor to add
  104301. */
  104302. addImpostor(impostor: PhysicsImpostor): void;
  104303. /**
  104304. * Remove an impostor from the engine.
  104305. * This impostor and its mesh will not longer be updated by the physics engine.
  104306. * @param impostor the impostor to remove
  104307. */
  104308. removeImpostor(impostor: PhysicsImpostor): void;
  104309. /**
  104310. * Add a joint to the physics engine
  104311. * @param mainImpostor defines the main impostor to which the joint is added.
  104312. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  104313. * @param joint defines the joint that will connect both impostors.
  104314. */
  104315. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104316. /**
  104317. * Removes a joint from the simulation
  104318. * @param mainImpostor defines the impostor used with the joint
  104319. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  104320. * @param joint defines the joint to remove
  104321. */
  104322. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104323. /**
  104324. * Called by the scene. No need to call it.
  104325. * @param delta defines the timespam between frames
  104326. */
  104327. _step(delta: number): void;
  104328. /**
  104329. * Gets the current plugin used to run the simulation
  104330. * @returns current plugin
  104331. */
  104332. getPhysicsPlugin(): IPhysicsEnginePlugin;
  104333. /**
  104334. * Gets the list of physic impostors
  104335. * @returns an array of PhysicsImpostor
  104336. */
  104337. getImpostors(): Array<PhysicsImpostor>;
  104338. /**
  104339. * Gets the impostor for a physics enabled object
  104340. * @param object defines the object impersonated by the impostor
  104341. * @returns the PhysicsImpostor or null if not found
  104342. */
  104343. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104344. /**
  104345. * Gets the impostor for a physics body object
  104346. * @param body defines physics body used by the impostor
  104347. * @returns the PhysicsImpostor or null if not found
  104348. */
  104349. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  104350. }
  104351. }
  104352. declare module BABYLON {
  104353. /** @hidden */
  104354. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  104355. private _useDeltaForWorldStep;
  104356. world: any;
  104357. name: string;
  104358. private _physicsMaterials;
  104359. private _fixedTimeStep;
  104360. BJSCANNON: any;
  104361. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  104362. setGravity(gravity: Vector3): void;
  104363. setTimeStep(timeStep: number): void;
  104364. getTimeStep(): number;
  104365. executeStep(delta: number): void;
  104366. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104367. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104368. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104369. private _processChildMeshes;
  104370. removePhysicsBody(impostor: PhysicsImpostor): void;
  104371. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  104372. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  104373. private _addMaterial;
  104374. private _checkWithEpsilon;
  104375. private _createShape;
  104376. private _createHeightmap;
  104377. private _minus90X;
  104378. private _plus90X;
  104379. private _tmpPosition;
  104380. private _tmpDeltaPosition;
  104381. private _tmpUnityRotation;
  104382. private _updatePhysicsBodyTransformation;
  104383. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104384. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104385. isSupported(): boolean;
  104386. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104387. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104388. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104389. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104390. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104391. getBodyMass(impostor: PhysicsImpostor): number;
  104392. getBodyFriction(impostor: PhysicsImpostor): number;
  104393. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104394. getBodyRestitution(impostor: PhysicsImpostor): number;
  104395. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104396. sleepBody(impostor: PhysicsImpostor): void;
  104397. wakeUpBody(impostor: PhysicsImpostor): void;
  104398. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  104399. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  104400. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  104401. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104402. getRadius(impostor: PhysicsImpostor): number;
  104403. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104404. dispose(): void;
  104405. private _extendNamespace;
  104406. }
  104407. }
  104408. declare module BABYLON {
  104409. /** @hidden */
  104410. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  104411. world: any;
  104412. name: string;
  104413. BJSOIMO: any;
  104414. constructor(iterations?: number, oimoInjection?: any);
  104415. setGravity(gravity: Vector3): void;
  104416. setTimeStep(timeStep: number): void;
  104417. getTimeStep(): number;
  104418. private _tmpImpostorsArray;
  104419. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  104420. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104421. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104422. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104423. private _tmpPositionVector;
  104424. removePhysicsBody(impostor: PhysicsImpostor): void;
  104425. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  104426. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  104427. isSupported(): boolean;
  104428. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104429. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104430. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104431. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104432. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104433. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104434. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104435. getBodyMass(impostor: PhysicsImpostor): number;
  104436. getBodyFriction(impostor: PhysicsImpostor): number;
  104437. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104438. getBodyRestitution(impostor: PhysicsImpostor): number;
  104439. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104440. sleepBody(impostor: PhysicsImpostor): void;
  104441. wakeUpBody(impostor: PhysicsImpostor): void;
  104442. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  104443. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  104444. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104445. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104446. getRadius(impostor: PhysicsImpostor): number;
  104447. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104448. dispose(): void;
  104449. }
  104450. }
  104451. declare module BABYLON {
  104452. interface AbstractScene {
  104453. /**
  104454. * The list of reflection probes added to the scene
  104455. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  104456. */
  104457. reflectionProbes: Array<ReflectionProbe>;
  104458. /**
  104459. * Removes the given reflection probe from this scene.
  104460. * @param toRemove The reflection probe to remove
  104461. * @returns The index of the removed reflection probe
  104462. */
  104463. removeReflectionProbe(toRemove: ReflectionProbe): number;
  104464. /**
  104465. * Adds the given reflection probe to this scene.
  104466. * @param newReflectionProbe The reflection probe to add
  104467. */
  104468. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  104469. }
  104470. /**
  104471. * Class used to generate realtime reflection / refraction cube textures
  104472. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  104473. */
  104474. export class ReflectionProbe {
  104475. /** defines the name of the probe */
  104476. name: string;
  104477. private _scene;
  104478. private _renderTargetTexture;
  104479. private _projectionMatrix;
  104480. private _viewMatrix;
  104481. private _target;
  104482. private _add;
  104483. private _attachedMesh;
  104484. private _invertYAxis;
  104485. /** Gets or sets probe position (center of the cube map) */
  104486. position: Vector3;
  104487. /**
  104488. * Creates a new reflection probe
  104489. * @param name defines the name of the probe
  104490. * @param size defines the texture resolution (for each face)
  104491. * @param scene defines the hosting scene
  104492. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  104493. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  104494. */
  104495. constructor(
  104496. /** defines the name of the probe */
  104497. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  104498. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  104499. samples: number;
  104500. /** Gets or sets the refresh rate to use (on every frame by default) */
  104501. refreshRate: number;
  104502. /**
  104503. * Gets the hosting scene
  104504. * @returns a Scene
  104505. */
  104506. getScene(): Scene;
  104507. /** Gets the internal CubeTexture used to render to */
  104508. readonly cubeTexture: RenderTargetTexture;
  104509. /** Gets the list of meshes to render */
  104510. readonly renderList: Nullable<AbstractMesh[]>;
  104511. /**
  104512. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  104513. * @param mesh defines the mesh to attach to
  104514. */
  104515. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  104516. /**
  104517. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  104518. * @param renderingGroupId The rendering group id corresponding to its index
  104519. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  104520. */
  104521. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  104522. /**
  104523. * Clean all associated resources
  104524. */
  104525. dispose(): void;
  104526. /**
  104527. * Converts the reflection probe information to a readable string for debug purpose.
  104528. * @param fullDetails Supports for multiple levels of logging within scene loading
  104529. * @returns the human readable reflection probe info
  104530. */
  104531. toString(fullDetails?: boolean): string;
  104532. /**
  104533. * Get the class name of the relfection probe.
  104534. * @returns "ReflectionProbe"
  104535. */
  104536. getClassName(): string;
  104537. /**
  104538. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  104539. * @returns The JSON representation of the texture
  104540. */
  104541. serialize(): any;
  104542. /**
  104543. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  104544. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  104545. * @param scene Define the scene the parsed reflection probe should be instantiated in
  104546. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  104547. * @returns The parsed reflection probe if successful
  104548. */
  104549. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  104550. }
  104551. }
  104552. declare module BABYLON {
  104553. /** @hidden */
  104554. export var _BabylonLoaderRegistered: boolean;
  104555. }
  104556. declare module BABYLON {
  104557. /**
  104558. * The Physically based simple base material of BJS.
  104559. *
  104560. * This enables better naming and convention enforcements on top of the pbrMaterial.
  104561. * It is used as the base class for both the specGloss and metalRough conventions.
  104562. */
  104563. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  104564. /**
  104565. * Number of Simultaneous lights allowed on the material.
  104566. */
  104567. maxSimultaneousLights: number;
  104568. /**
  104569. * If sets to true, disables all the lights affecting the material.
  104570. */
  104571. disableLighting: boolean;
  104572. /**
  104573. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  104574. */
  104575. environmentTexture: BaseTexture;
  104576. /**
  104577. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104578. */
  104579. invertNormalMapX: boolean;
  104580. /**
  104581. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104582. */
  104583. invertNormalMapY: boolean;
  104584. /**
  104585. * Normal map used in the model.
  104586. */
  104587. normalTexture: BaseTexture;
  104588. /**
  104589. * Emissivie color used to self-illuminate the model.
  104590. */
  104591. emissiveColor: Color3;
  104592. /**
  104593. * Emissivie texture used to self-illuminate the model.
  104594. */
  104595. emissiveTexture: BaseTexture;
  104596. /**
  104597. * Occlusion Channel Strenght.
  104598. */
  104599. occlusionStrength: number;
  104600. /**
  104601. * Occlusion Texture of the material (adding extra occlusion effects).
  104602. */
  104603. occlusionTexture: BaseTexture;
  104604. /**
  104605. * Defines the alpha limits in alpha test mode.
  104606. */
  104607. alphaCutOff: number;
  104608. /**
  104609. * Gets the current double sided mode.
  104610. */
  104611. /**
  104612. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104613. */
  104614. doubleSided: boolean;
  104615. /**
  104616. * Stores the pre-calculated light information of a mesh in a texture.
  104617. */
  104618. lightmapTexture: BaseTexture;
  104619. /**
  104620. * If true, the light map contains occlusion information instead of lighting info.
  104621. */
  104622. useLightmapAsShadowmap: boolean;
  104623. /**
  104624. * Instantiates a new PBRMaterial instance.
  104625. *
  104626. * @param name The material name
  104627. * @param scene The scene the material will be use in.
  104628. */
  104629. constructor(name: string, scene: Scene);
  104630. getClassName(): string;
  104631. }
  104632. }
  104633. declare module BABYLON {
  104634. /**
  104635. * The PBR material of BJS following the metal roughness convention.
  104636. *
  104637. * This fits to the PBR convention in the GLTF definition:
  104638. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  104639. */
  104640. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  104641. /**
  104642. * The base color has two different interpretations depending on the value of metalness.
  104643. * When the material is a metal, the base color is the specific measured reflectance value
  104644. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  104645. * of the material.
  104646. */
  104647. baseColor: Color3;
  104648. /**
  104649. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  104650. * well as opacity information in the alpha channel.
  104651. */
  104652. baseTexture: BaseTexture;
  104653. /**
  104654. * Specifies the metallic scalar value of the material.
  104655. * Can also be used to scale the metalness values of the metallic texture.
  104656. */
  104657. metallic: number;
  104658. /**
  104659. * Specifies the roughness scalar value of the material.
  104660. * Can also be used to scale the roughness values of the metallic texture.
  104661. */
  104662. roughness: number;
  104663. /**
  104664. * Texture containing both the metallic value in the B channel and the
  104665. * roughness value in the G channel to keep better precision.
  104666. */
  104667. metallicRoughnessTexture: BaseTexture;
  104668. /**
  104669. * Instantiates a new PBRMetalRoughnessMaterial instance.
  104670. *
  104671. * @param name The material name
  104672. * @param scene The scene the material will be use in.
  104673. */
  104674. constructor(name: string, scene: Scene);
  104675. /**
  104676. * Return the currrent class name of the material.
  104677. */
  104678. getClassName(): string;
  104679. /**
  104680. * Makes a duplicate of the current material.
  104681. * @param name - name to use for the new material.
  104682. */
  104683. clone(name: string): PBRMetallicRoughnessMaterial;
  104684. /**
  104685. * Serialize the material to a parsable JSON object.
  104686. */
  104687. serialize(): any;
  104688. /**
  104689. * Parses a JSON object correponding to the serialize function.
  104690. */
  104691. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  104692. }
  104693. }
  104694. declare module BABYLON {
  104695. /**
  104696. * The PBR material of BJS following the specular glossiness convention.
  104697. *
  104698. * This fits to the PBR convention in the GLTF definition:
  104699. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  104700. */
  104701. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  104702. /**
  104703. * Specifies the diffuse color of the material.
  104704. */
  104705. diffuseColor: Color3;
  104706. /**
  104707. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  104708. * channel.
  104709. */
  104710. diffuseTexture: BaseTexture;
  104711. /**
  104712. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  104713. */
  104714. specularColor: Color3;
  104715. /**
  104716. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  104717. */
  104718. glossiness: number;
  104719. /**
  104720. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  104721. */
  104722. specularGlossinessTexture: BaseTexture;
  104723. /**
  104724. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  104725. *
  104726. * @param name The material name
  104727. * @param scene The scene the material will be use in.
  104728. */
  104729. constructor(name: string, scene: Scene);
  104730. /**
  104731. * Return the currrent class name of the material.
  104732. */
  104733. getClassName(): string;
  104734. /**
  104735. * Makes a duplicate of the current material.
  104736. * @param name - name to use for the new material.
  104737. */
  104738. clone(name: string): PBRSpecularGlossinessMaterial;
  104739. /**
  104740. * Serialize the material to a parsable JSON object.
  104741. */
  104742. serialize(): any;
  104743. /**
  104744. * Parses a JSON object correponding to the serialize function.
  104745. */
  104746. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  104747. }
  104748. }
  104749. declare module BABYLON {
  104750. /**
  104751. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  104752. * It can help converting any input color in a desired output one. This can then be used to create effects
  104753. * from sepia, black and white to sixties or futuristic rendering...
  104754. *
  104755. * The only supported format is currently 3dl.
  104756. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  104757. */
  104758. export class ColorGradingTexture extends BaseTexture {
  104759. /**
  104760. * The current texture matrix. (will always be identity in color grading texture)
  104761. */
  104762. private _textureMatrix;
  104763. /**
  104764. * The texture URL.
  104765. */
  104766. url: string;
  104767. /**
  104768. * Empty line regex stored for GC.
  104769. */
  104770. private static _noneEmptyLineRegex;
  104771. private _engine;
  104772. /**
  104773. * Instantiates a ColorGradingTexture from the following parameters.
  104774. *
  104775. * @param url The location of the color gradind data (currently only supporting 3dl)
  104776. * @param scene The scene the texture will be used in
  104777. */
  104778. constructor(url: string, scene: Scene);
  104779. /**
  104780. * Returns the texture matrix used in most of the material.
  104781. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  104782. */
  104783. getTextureMatrix(): Matrix;
  104784. /**
  104785. * Occurs when the file being loaded is a .3dl LUT file.
  104786. */
  104787. private load3dlTexture;
  104788. /**
  104789. * Starts the loading process of the texture.
  104790. */
  104791. private loadTexture;
  104792. /**
  104793. * Clones the color gradind texture.
  104794. */
  104795. clone(): ColorGradingTexture;
  104796. /**
  104797. * Called during delayed load for textures.
  104798. */
  104799. delayLoad(): void;
  104800. /**
  104801. * Parses a color grading texture serialized by Babylon.
  104802. * @param parsedTexture The texture information being parsedTexture
  104803. * @param scene The scene to load the texture in
  104804. * @param rootUrl The root url of the data assets to load
  104805. * @return A color gradind texture
  104806. */
  104807. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  104808. /**
  104809. * Serializes the LUT texture to json format.
  104810. */
  104811. serialize(): any;
  104812. }
  104813. }
  104814. declare module BABYLON {
  104815. /**
  104816. * Based on jsTGALoader - Javascript loader for TGA file
  104817. * By Vincent Thibault
  104818. * @see http://blog.robrowser.com/javascript-tga-loader.html
  104819. */
  104820. export class TGATools {
  104821. private static _TYPE_INDEXED;
  104822. private static _TYPE_RGB;
  104823. private static _TYPE_GREY;
  104824. private static _TYPE_RLE_INDEXED;
  104825. private static _TYPE_RLE_RGB;
  104826. private static _TYPE_RLE_GREY;
  104827. private static _ORIGIN_MASK;
  104828. private static _ORIGIN_SHIFT;
  104829. private static _ORIGIN_BL;
  104830. private static _ORIGIN_BR;
  104831. private static _ORIGIN_UL;
  104832. private static _ORIGIN_UR;
  104833. /**
  104834. * Gets the header of a TGA file
  104835. * @param data defines the TGA data
  104836. * @returns the header
  104837. */
  104838. static GetTGAHeader(data: Uint8Array): any;
  104839. /**
  104840. * Uploads TGA content to a Babylon Texture
  104841. * @hidden
  104842. */
  104843. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  104844. /** @hidden */
  104845. 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;
  104846. /** @hidden */
  104847. 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;
  104848. /** @hidden */
  104849. 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;
  104850. /** @hidden */
  104851. 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;
  104852. /** @hidden */
  104853. 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;
  104854. /** @hidden */
  104855. 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;
  104856. }
  104857. }
  104858. declare module BABYLON {
  104859. /**
  104860. * Implementation of the TGA Texture Loader.
  104861. * @hidden
  104862. */
  104863. export class _TGATextureLoader implements IInternalTextureLoader {
  104864. /**
  104865. * Defines wether the loader supports cascade loading the different faces.
  104866. */
  104867. readonly supportCascades: boolean;
  104868. /**
  104869. * This returns if the loader support the current file information.
  104870. * @param extension defines the file extension of the file being loaded
  104871. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104872. * @param fallback defines the fallback internal texture if any
  104873. * @param isBase64 defines whether the texture is encoded as a base64
  104874. * @param isBuffer defines whether the texture data are stored as a buffer
  104875. * @returns true if the loader can load the specified file
  104876. */
  104877. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104878. /**
  104879. * Transform the url before loading if required.
  104880. * @param rootUrl the url of the texture
  104881. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104882. * @returns the transformed texture
  104883. */
  104884. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104885. /**
  104886. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104887. * @param rootUrl the url of the texture
  104888. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104889. * @returns the fallback texture
  104890. */
  104891. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104892. /**
  104893. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104894. * @param data contains the texture data
  104895. * @param texture defines the BabylonJS internal texture
  104896. * @param createPolynomials will be true if polynomials have been requested
  104897. * @param onLoad defines the callback to trigger once the texture is ready
  104898. * @param onError defines the callback to trigger in case of error
  104899. */
  104900. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104901. /**
  104902. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104903. * @param data contains the texture data
  104904. * @param texture defines the BabylonJS internal texture
  104905. * @param callback defines the method to call once ready to upload
  104906. */
  104907. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104908. }
  104909. }
  104910. declare module BABYLON {
  104911. /**
  104912. * 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.
  104913. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  104914. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  104915. */
  104916. export class CustomProceduralTexture extends ProceduralTexture {
  104917. private _animate;
  104918. private _time;
  104919. private _config;
  104920. private _texturePath;
  104921. /**
  104922. * Instantiates a new Custom Procedural Texture.
  104923. * 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.
  104924. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  104925. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  104926. * @param name Define the name of the texture
  104927. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  104928. * @param size Define the size of the texture to create
  104929. * @param scene Define the scene the texture belongs to
  104930. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  104931. * @param generateMipMaps Define if the texture should creates mip maps or not
  104932. */
  104933. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  104934. private _loadJson;
  104935. /**
  104936. * Is the texture ready to be used ? (rendered at least once)
  104937. * @returns true if ready, otherwise, false.
  104938. */
  104939. isReady(): boolean;
  104940. /**
  104941. * Render the texture to its associated render target.
  104942. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  104943. */
  104944. render(useCameraPostProcess?: boolean): void;
  104945. /**
  104946. * Update the list of dependant textures samplers in the shader.
  104947. */
  104948. updateTextures(): void;
  104949. /**
  104950. * Update the uniform values of the procedural texture in the shader.
  104951. */
  104952. updateShaderUniforms(): void;
  104953. /**
  104954. * Define if the texture animates or not.
  104955. */
  104956. animate: boolean;
  104957. }
  104958. }
  104959. declare module BABYLON {
  104960. /** @hidden */
  104961. export var noisePixelShader: {
  104962. name: string;
  104963. shader: string;
  104964. };
  104965. }
  104966. declare module BABYLON {
  104967. /**
  104968. * Class used to generate noise procedural textures
  104969. */
  104970. export class NoiseProceduralTexture extends ProceduralTexture {
  104971. private _time;
  104972. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  104973. brightness: number;
  104974. /** Defines the number of octaves to process */
  104975. octaves: number;
  104976. /** Defines the level of persistence (0.8 by default) */
  104977. persistence: number;
  104978. /** Gets or sets animation speed factor (default is 1) */
  104979. animationSpeedFactor: number;
  104980. /**
  104981. * Creates a new NoiseProceduralTexture
  104982. * @param name defines the name fo the texture
  104983. * @param size defines the size of the texture (default is 256)
  104984. * @param scene defines the hosting scene
  104985. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  104986. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  104987. */
  104988. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  104989. private _updateShaderUniforms;
  104990. protected _getDefines(): string;
  104991. /** Generate the current state of the procedural texture */
  104992. render(useCameraPostProcess?: boolean): void;
  104993. /**
  104994. * Serializes this noise procedural texture
  104995. * @returns a serialized noise procedural texture object
  104996. */
  104997. serialize(): any;
  104998. /**
  104999. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  105000. * @param parsedTexture defines parsed texture data
  105001. * @param scene defines the current scene
  105002. * @param rootUrl defines the root URL containing noise procedural texture information
  105003. * @returns a parsed NoiseProceduralTexture
  105004. */
  105005. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  105006. }
  105007. }
  105008. declare module BABYLON {
  105009. /**
  105010. * Raw cube texture where the raw buffers are passed in
  105011. */
  105012. export class RawCubeTexture extends CubeTexture {
  105013. /**
  105014. * Creates a cube texture where the raw buffers are passed in.
  105015. * @param scene defines the scene the texture is attached to
  105016. * @param data defines the array of data to use to create each face
  105017. * @param size defines the size of the textures
  105018. * @param format defines the format of the data
  105019. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105020. * @param generateMipMaps defines if the engine should generate the mip levels
  105021. * @param invertY defines if data must be stored with Y axis inverted
  105022. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105023. * @param compression defines the compression used (null by default)
  105024. */
  105025. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  105026. /**
  105027. * Updates the raw cube texture.
  105028. * @param data defines the data to store
  105029. * @param format defines the data format
  105030. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105031. * @param invertY defines if data must be stored with Y axis inverted
  105032. * @param compression defines the compression used (null by default)
  105033. * @param level defines which level of the texture to update
  105034. */
  105035. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  105036. /**
  105037. * Updates a raw cube texture with RGBD encoded data.
  105038. * @param data defines the array of data [mipmap][face] to use to create each face
  105039. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  105040. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  105041. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  105042. * @returns a promsie that resolves when the operation is complete
  105043. */
  105044. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  105045. /**
  105046. * Clones the raw cube texture.
  105047. * @return a new cube texture
  105048. */
  105049. clone(): CubeTexture;
  105050. /** @hidden */
  105051. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  105052. }
  105053. }
  105054. declare module BABYLON {
  105055. /**
  105056. * Class used to store 3D textures containing user data
  105057. */
  105058. export class RawTexture3D extends Texture {
  105059. /** Gets or sets the texture format to use */
  105060. format: number;
  105061. private _engine;
  105062. /**
  105063. * Create a new RawTexture3D
  105064. * @param data defines the data of the texture
  105065. * @param width defines the width of the texture
  105066. * @param height defines the height of the texture
  105067. * @param depth defines the depth of the texture
  105068. * @param format defines the texture format to use
  105069. * @param scene defines the hosting scene
  105070. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  105071. * @param invertY defines if texture must be stored with Y axis inverted
  105072. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  105073. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  105074. */
  105075. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  105076. /** Gets or sets the texture format to use */
  105077. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  105078. /**
  105079. * Update the texture with new data
  105080. * @param data defines the data to store in the texture
  105081. */
  105082. update(data: ArrayBufferView): void;
  105083. }
  105084. }
  105085. declare module BABYLON {
  105086. /**
  105087. * Creates a refraction texture used by refraction channel of the standard material.
  105088. * It is like a mirror but to see through a material.
  105089. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105090. */
  105091. export class RefractionTexture extends RenderTargetTexture {
  105092. /**
  105093. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  105094. * 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.
  105095. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105096. */
  105097. refractionPlane: Plane;
  105098. /**
  105099. * Define how deep under the surface we should see.
  105100. */
  105101. depth: number;
  105102. /**
  105103. * Creates a refraction texture used by refraction channel of the standard material.
  105104. * It is like a mirror but to see through a material.
  105105. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105106. * @param name Define the texture name
  105107. * @param size Define the size of the underlying texture
  105108. * @param scene Define the scene the refraction belongs to
  105109. * @param generateMipMaps Define if we need to generate mips level for the refraction
  105110. */
  105111. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  105112. /**
  105113. * Clone the refraction texture.
  105114. * @returns the cloned texture
  105115. */
  105116. clone(): RefractionTexture;
  105117. /**
  105118. * Serialize the texture to a JSON representation you could use in Parse later on
  105119. * @returns the serialized JSON representation
  105120. */
  105121. serialize(): any;
  105122. }
  105123. }
  105124. declare module BABYLON {
  105125. /**
  105126. * Configuration for Draco compression
  105127. */
  105128. export interface IDracoCompressionConfiguration {
  105129. /**
  105130. * Configuration for the decoder.
  105131. */
  105132. decoder?: {
  105133. /**
  105134. * The url to the WebAssembly module.
  105135. */
  105136. wasmUrl?: string;
  105137. /**
  105138. * The url to the WebAssembly binary.
  105139. */
  105140. wasmBinaryUrl?: string;
  105141. /**
  105142. * The url to the fallback JavaScript module.
  105143. */
  105144. fallbackUrl?: string;
  105145. };
  105146. }
  105147. /**
  105148. * Draco compression (https://google.github.io/draco/)
  105149. *
  105150. * This class wraps the Draco module.
  105151. *
  105152. * **Encoder**
  105153. *
  105154. * The encoder is not currently implemented.
  105155. *
  105156. * **Decoder**
  105157. *
  105158. * 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.
  105159. *
  105160. * To update the configuration, use the following code:
  105161. * ```javascript
  105162. * DracoCompression.Configuration = {
  105163. * decoder: {
  105164. * wasmUrl: "<url to the WebAssembly library>",
  105165. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  105166. * fallbackUrl: "<url to the fallback JavaScript library>",
  105167. * }
  105168. * };
  105169. * ```
  105170. *
  105171. * 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.
  105172. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  105173. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  105174. *
  105175. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  105176. * ```javascript
  105177. * var dracoCompression = new DracoCompression();
  105178. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  105179. * [VertexBuffer.PositionKind]: 0
  105180. * });
  105181. * ```
  105182. *
  105183. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  105184. */
  105185. export class DracoCompression implements IDisposable {
  105186. private static _DecoderModulePromise;
  105187. /**
  105188. * The configuration. Defaults to the following urls:
  105189. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  105190. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  105191. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  105192. */
  105193. static Configuration: IDracoCompressionConfiguration;
  105194. /**
  105195. * Returns true if the decoder is available.
  105196. */
  105197. static readonly DecoderAvailable: boolean;
  105198. /**
  105199. * Constructor
  105200. */
  105201. constructor();
  105202. /**
  105203. * Stop all async operations and release resources.
  105204. */
  105205. dispose(): void;
  105206. /**
  105207. * Decode Draco compressed mesh data to vertex data.
  105208. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  105209. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  105210. * @returns A promise that resolves with the decoded vertex data
  105211. */
  105212. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  105213. [kind: string]: number;
  105214. }): Promise<VertexData>;
  105215. private static _GetDecoderModule;
  105216. private static _LoadScriptAsync;
  105217. private static _LoadFileAsync;
  105218. }
  105219. }
  105220. declare module BABYLON {
  105221. /**
  105222. * Class for building Constructive Solid Geometry
  105223. */
  105224. export class CSG {
  105225. private polygons;
  105226. /**
  105227. * The world matrix
  105228. */
  105229. matrix: Matrix;
  105230. /**
  105231. * Stores the position
  105232. */
  105233. position: Vector3;
  105234. /**
  105235. * Stores the rotation
  105236. */
  105237. rotation: Vector3;
  105238. /**
  105239. * Stores the rotation quaternion
  105240. */
  105241. rotationQuaternion: Nullable<Quaternion>;
  105242. /**
  105243. * Stores the scaling vector
  105244. */
  105245. scaling: Vector3;
  105246. /**
  105247. * Convert the Mesh to CSG
  105248. * @param mesh The Mesh to convert to CSG
  105249. * @returns A new CSG from the Mesh
  105250. */
  105251. static FromMesh(mesh: Mesh): CSG;
  105252. /**
  105253. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  105254. * @param polygons Polygons used to construct a CSG solid
  105255. */
  105256. private static FromPolygons;
  105257. /**
  105258. * Clones, or makes a deep copy, of the CSG
  105259. * @returns A new CSG
  105260. */
  105261. clone(): CSG;
  105262. /**
  105263. * Unions this CSG with another CSG
  105264. * @param csg The CSG to union against this CSG
  105265. * @returns The unioned CSG
  105266. */
  105267. union(csg: CSG): CSG;
  105268. /**
  105269. * Unions this CSG with another CSG in place
  105270. * @param csg The CSG to union against this CSG
  105271. */
  105272. unionInPlace(csg: CSG): void;
  105273. /**
  105274. * Subtracts this CSG with another CSG
  105275. * @param csg The CSG to subtract against this CSG
  105276. * @returns A new CSG
  105277. */
  105278. subtract(csg: CSG): CSG;
  105279. /**
  105280. * Subtracts this CSG with another CSG in place
  105281. * @param csg The CSG to subtact against this CSG
  105282. */
  105283. subtractInPlace(csg: CSG): void;
  105284. /**
  105285. * Intersect this CSG with another CSG
  105286. * @param csg The CSG to intersect against this CSG
  105287. * @returns A new CSG
  105288. */
  105289. intersect(csg: CSG): CSG;
  105290. /**
  105291. * Intersects this CSG with another CSG in place
  105292. * @param csg The CSG to intersect against this CSG
  105293. */
  105294. intersectInPlace(csg: CSG): void;
  105295. /**
  105296. * Return a new CSG solid with solid and empty space switched. This solid is
  105297. * not modified.
  105298. * @returns A new CSG solid with solid and empty space switched
  105299. */
  105300. inverse(): CSG;
  105301. /**
  105302. * Inverses the CSG in place
  105303. */
  105304. inverseInPlace(): void;
  105305. /**
  105306. * This is used to keep meshes transformations so they can be restored
  105307. * when we build back a Babylon Mesh
  105308. * NB : All CSG operations are performed in world coordinates
  105309. * @param csg The CSG to copy the transform attributes from
  105310. * @returns This CSG
  105311. */
  105312. copyTransformAttributes(csg: CSG): CSG;
  105313. /**
  105314. * Build Raw mesh from CSG
  105315. * Coordinates here are in world space
  105316. * @param name The name of the mesh geometry
  105317. * @param scene The Scene
  105318. * @param keepSubMeshes Specifies if the submeshes should be kept
  105319. * @returns A new Mesh
  105320. */
  105321. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  105322. /**
  105323. * Build Mesh from CSG taking material and transforms into account
  105324. * @param name The name of the Mesh
  105325. * @param material The material of the Mesh
  105326. * @param scene The Scene
  105327. * @param keepSubMeshes Specifies if submeshes should be kept
  105328. * @returns The new Mesh
  105329. */
  105330. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  105331. }
  105332. }
  105333. declare module BABYLON {
  105334. /**
  105335. * Class used to create a trail following a mesh
  105336. */
  105337. export class TrailMesh extends Mesh {
  105338. private _generator;
  105339. private _autoStart;
  105340. private _running;
  105341. private _diameter;
  105342. private _length;
  105343. private _sectionPolygonPointsCount;
  105344. private _sectionVectors;
  105345. private _sectionNormalVectors;
  105346. private _beforeRenderObserver;
  105347. /**
  105348. * @constructor
  105349. * @param name The value used by scene.getMeshByName() to do a lookup.
  105350. * @param generator The mesh to generate a trail.
  105351. * @param scene The scene to add this mesh to.
  105352. * @param diameter Diameter of trailing mesh. Default is 1.
  105353. * @param length Length of trailing mesh. Default is 60.
  105354. * @param autoStart Automatically start trailing mesh. Default true.
  105355. */
  105356. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  105357. /**
  105358. * "TrailMesh"
  105359. * @returns "TrailMesh"
  105360. */
  105361. getClassName(): string;
  105362. private _createMesh;
  105363. /**
  105364. * Start trailing mesh.
  105365. */
  105366. start(): void;
  105367. /**
  105368. * Stop trailing mesh.
  105369. */
  105370. stop(): void;
  105371. /**
  105372. * Update trailing mesh geometry.
  105373. */
  105374. update(): void;
  105375. /**
  105376. * Returns a new TrailMesh object.
  105377. * @param name is a string, the name given to the new mesh
  105378. * @param newGenerator use new generator object for cloned trail mesh
  105379. * @returns a new mesh
  105380. */
  105381. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  105382. /**
  105383. * Serializes this trail mesh
  105384. * @param serializationObject object to write serialization to
  105385. */
  105386. serialize(serializationObject: any): void;
  105387. /**
  105388. * Parses a serialized trail mesh
  105389. * @param parsedMesh the serialized mesh
  105390. * @param scene the scene to create the trail mesh in
  105391. * @returns the created trail mesh
  105392. */
  105393. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  105394. }
  105395. }
  105396. declare module BABYLON {
  105397. /**
  105398. * Class containing static functions to help procedurally build meshes
  105399. */
  105400. export class RibbonBuilder {
  105401. /**
  105402. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105403. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  105404. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  105405. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  105406. * * 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
  105407. * * 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
  105408. * * 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
  105409. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105410. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105411. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105412. * * 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
  105413. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  105414. * * 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
  105415. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  105416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105417. * @param name defines the name of the mesh
  105418. * @param options defines the options used to create the mesh
  105419. * @param scene defines the hosting scene
  105420. * @returns the ribbon mesh
  105421. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  105422. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105423. */
  105424. static CreateRibbon(name: string, options: {
  105425. pathArray: Vector3[][];
  105426. closeArray?: boolean;
  105427. closePath?: boolean;
  105428. offset?: number;
  105429. updatable?: boolean;
  105430. sideOrientation?: number;
  105431. frontUVs?: Vector4;
  105432. backUVs?: Vector4;
  105433. instance?: Mesh;
  105434. invertUV?: boolean;
  105435. uvs?: Vector2[];
  105436. colors?: Color4[];
  105437. }, scene?: Nullable<Scene>): Mesh;
  105438. }
  105439. }
  105440. declare module BABYLON {
  105441. /**
  105442. * Class containing static functions to help procedurally build meshes
  105443. */
  105444. export class TorusKnotBuilder {
  105445. /**
  105446. * Creates a torus knot mesh
  105447. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  105448. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  105449. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  105450. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  105451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105452. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105454. * @param name defines the name of the mesh
  105455. * @param options defines the options used to create the mesh
  105456. * @param scene defines the hosting scene
  105457. * @returns the torus knot mesh
  105458. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  105459. */
  105460. static CreateTorusKnot(name: string, options: {
  105461. radius?: number;
  105462. tube?: number;
  105463. radialSegments?: number;
  105464. tubularSegments?: number;
  105465. p?: number;
  105466. q?: number;
  105467. updatable?: boolean;
  105468. sideOrientation?: number;
  105469. frontUVs?: Vector4;
  105470. backUVs?: Vector4;
  105471. }, scene: any): Mesh;
  105472. }
  105473. }
  105474. declare module BABYLON {
  105475. /**
  105476. * Polygon
  105477. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105478. */
  105479. export class Polygon {
  105480. /**
  105481. * Creates a rectangle
  105482. * @param xmin bottom X coord
  105483. * @param ymin bottom Y coord
  105484. * @param xmax top X coord
  105485. * @param ymax top Y coord
  105486. * @returns points that make the resulting rectation
  105487. */
  105488. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  105489. /**
  105490. * Creates a circle
  105491. * @param radius radius of circle
  105492. * @param cx scale in x
  105493. * @param cy scale in y
  105494. * @param numberOfSides number of sides that make up the circle
  105495. * @returns points that make the resulting circle
  105496. */
  105497. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  105498. /**
  105499. * Creates a polygon from input string
  105500. * @param input Input polygon data
  105501. * @returns the parsed points
  105502. */
  105503. static Parse(input: string): Vector2[];
  105504. /**
  105505. * Starts building a polygon from x and y coordinates
  105506. * @param x x coordinate
  105507. * @param y y coordinate
  105508. * @returns the started path2
  105509. */
  105510. static StartingAt(x: number, y: number): Path2;
  105511. }
  105512. /**
  105513. * Builds a polygon
  105514. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  105515. */
  105516. export class PolygonMeshBuilder {
  105517. private _points;
  105518. private _outlinepoints;
  105519. private _holes;
  105520. private _name;
  105521. private _scene;
  105522. private _epoints;
  105523. private _eholes;
  105524. private _addToepoint;
  105525. /**
  105526. * Babylon reference to the earcut plugin.
  105527. */
  105528. bjsEarcut: any;
  105529. /**
  105530. * Creates a PolygonMeshBuilder
  105531. * @param name name of the builder
  105532. * @param contours Path of the polygon
  105533. * @param scene scene to add to
  105534. * @param earcutInjection can be used to inject your own earcut reference
  105535. */
  105536. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  105537. /**
  105538. * Adds a whole within the polygon
  105539. * @param hole Array of points defining the hole
  105540. * @returns this
  105541. */
  105542. addHole(hole: Vector2[]): PolygonMeshBuilder;
  105543. /**
  105544. * Creates the polygon
  105545. * @param updatable If the mesh should be updatable
  105546. * @param depth The depth of the mesh created
  105547. * @returns the created mesh
  105548. */
  105549. build(updatable?: boolean, depth?: number): Mesh;
  105550. /**
  105551. * Adds a side to the polygon
  105552. * @param positions points that make the polygon
  105553. * @param normals normals of the polygon
  105554. * @param uvs uvs of the polygon
  105555. * @param indices indices of the polygon
  105556. * @param bounds bounds of the polygon
  105557. * @param points points of the polygon
  105558. * @param depth depth of the polygon
  105559. * @param flip flip of the polygon
  105560. */
  105561. private addSide;
  105562. }
  105563. }
  105564. declare module BABYLON {
  105565. /**
  105566. * Class containing static functions to help procedurally build meshes
  105567. */
  105568. export class PolygonBuilder {
  105569. /**
  105570. * Creates a polygon mesh
  105571. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  105572. * * 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
  105573. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105575. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  105576. * * Remember you can only change the shape positions, not their number when updating a polygon
  105577. * @param name defines the name of the mesh
  105578. * @param options defines the options used to create the mesh
  105579. * @param scene defines the hosting scene
  105580. * @param earcutInjection can be used to inject your own earcut reference
  105581. * @returns the polygon mesh
  105582. */
  105583. static CreatePolygon(name: string, options: {
  105584. shape: Vector3[];
  105585. holes?: Vector3[][];
  105586. depth?: number;
  105587. faceUV?: Vector4[];
  105588. faceColors?: Color4[];
  105589. updatable?: boolean;
  105590. sideOrientation?: number;
  105591. frontUVs?: Vector4;
  105592. backUVs?: Vector4;
  105593. }, scene: Scene, earcutInjection?: any): Mesh;
  105594. /**
  105595. * Creates an extruded polygon mesh, with depth in the Y direction.
  105596. * * 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)
  105597. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105598. * @param name defines the name of the mesh
  105599. * @param options defines the options used to create the mesh
  105600. * @param scene defines the hosting scene
  105601. * @param earcutInjection can be used to inject your own earcut reference
  105602. * @returns the polygon mesh
  105603. */
  105604. static ExtrudePolygon(name: string, options: {
  105605. shape: Vector3[];
  105606. holes?: Vector3[][];
  105607. depth?: number;
  105608. faceUV?: Vector4[];
  105609. faceColors?: Color4[];
  105610. updatable?: boolean;
  105611. sideOrientation?: number;
  105612. frontUVs?: Vector4;
  105613. backUVs?: Vector4;
  105614. }, scene: Scene, earcutInjection?: any): Mesh;
  105615. }
  105616. }
  105617. declare module BABYLON {
  105618. /**
  105619. * Class containing static functions to help procedurally build meshes
  105620. */
  105621. export class ShapeBuilder {
  105622. /**
  105623. * 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.
  105624. * * 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.
  105625. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105626. * * 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.
  105627. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  105628. * * 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
  105629. * * 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
  105630. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  105631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105632. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105633. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  105634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105635. * @param name defines the name of the mesh
  105636. * @param options defines the options used to create the mesh
  105637. * @param scene defines the hosting scene
  105638. * @returns the extruded shape mesh
  105639. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105640. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105641. */
  105642. static ExtrudeShape(name: string, options: {
  105643. shape: Vector3[];
  105644. path: Vector3[];
  105645. scale?: number;
  105646. rotation?: number;
  105647. cap?: number;
  105648. updatable?: boolean;
  105649. sideOrientation?: number;
  105650. frontUVs?: Vector4;
  105651. backUVs?: Vector4;
  105652. instance?: Mesh;
  105653. invertUV?: boolean;
  105654. }, scene?: Nullable<Scene>): Mesh;
  105655. /**
  105656. * Creates an custom extruded shape mesh.
  105657. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  105658. * * 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.
  105659. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105660. * * 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
  105661. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  105662. * * 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
  105663. * * It must returns a float value that will be the scale value applied to the shape on each path point
  105664. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105665. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  105666. * * 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
  105667. * * 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
  105668. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  105669. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105670. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105671. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105673. * @param name defines the name of the mesh
  105674. * @param options defines the options used to create the mesh
  105675. * @param scene defines the hosting scene
  105676. * @returns the custom extruded shape mesh
  105677. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  105678. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105679. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105680. */
  105681. static ExtrudeShapeCustom(name: string, options: {
  105682. shape: Vector3[];
  105683. path: Vector3[];
  105684. scaleFunction?: any;
  105685. rotationFunction?: any;
  105686. ribbonCloseArray?: boolean;
  105687. ribbonClosePath?: boolean;
  105688. cap?: number;
  105689. updatable?: boolean;
  105690. sideOrientation?: number;
  105691. frontUVs?: Vector4;
  105692. backUVs?: Vector4;
  105693. instance?: Mesh;
  105694. invertUV?: boolean;
  105695. }, scene: Scene): Mesh;
  105696. private static _ExtrudeShapeGeneric;
  105697. }
  105698. }
  105699. declare module BABYLON {
  105700. /**
  105701. * Class containing static functions to help procedurally build meshes
  105702. */
  105703. export class LatheBuilder {
  105704. /**
  105705. * Creates lathe mesh.
  105706. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  105707. * * 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
  105708. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  105709. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  105710. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  105711. * * 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
  105712. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  105713. * * 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
  105714. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105715. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105716. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105718. * @param name defines the name of the mesh
  105719. * @param options defines the options used to create the mesh
  105720. * @param scene defines the hosting scene
  105721. * @returns the lathe mesh
  105722. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  105723. */
  105724. static CreateLathe(name: string, options: {
  105725. shape: Vector3[];
  105726. radius?: number;
  105727. tessellation?: number;
  105728. clip?: number;
  105729. arc?: number;
  105730. closed?: boolean;
  105731. updatable?: boolean;
  105732. sideOrientation?: number;
  105733. frontUVs?: Vector4;
  105734. backUVs?: Vector4;
  105735. cap?: number;
  105736. invertUV?: boolean;
  105737. }, scene: Scene): Mesh;
  105738. }
  105739. }
  105740. declare module BABYLON {
  105741. /**
  105742. * Class containing static functions to help procedurally build meshes
  105743. */
  105744. export class TubeBuilder {
  105745. /**
  105746. * Creates a tube mesh.
  105747. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105748. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  105749. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  105750. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  105751. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  105752. * * 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)
  105753. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  105754. * * 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
  105755. * * 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
  105756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105757. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105758. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105760. * @param name defines the name of the mesh
  105761. * @param options defines the options used to create the mesh
  105762. * @param scene defines the hosting scene
  105763. * @returns the tube mesh
  105764. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105765. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  105766. */
  105767. static CreateTube(name: string, options: {
  105768. path: Vector3[];
  105769. radius?: number;
  105770. tessellation?: number;
  105771. radiusFunction?: {
  105772. (i: number, distance: number): number;
  105773. };
  105774. cap?: number;
  105775. arc?: number;
  105776. updatable?: boolean;
  105777. sideOrientation?: number;
  105778. frontUVs?: Vector4;
  105779. backUVs?: Vector4;
  105780. instance?: Mesh;
  105781. invertUV?: boolean;
  105782. }, scene: Scene): Mesh;
  105783. }
  105784. }
  105785. declare module BABYLON {
  105786. /**
  105787. * Class containing static functions to help procedurally build meshes
  105788. */
  105789. export class IcoSphereBuilder {
  105790. /**
  105791. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105792. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105793. * * 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`)
  105794. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105795. * * 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
  105796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105797. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105799. * @param name defines the name of the mesh
  105800. * @param options defines the options used to create the mesh
  105801. * @param scene defines the hosting scene
  105802. * @returns the icosahedron mesh
  105803. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105804. */
  105805. static CreateIcoSphere(name: string, options: {
  105806. radius?: number;
  105807. radiusX?: number;
  105808. radiusY?: number;
  105809. radiusZ?: number;
  105810. flat?: boolean;
  105811. subdivisions?: number;
  105812. sideOrientation?: number;
  105813. frontUVs?: Vector4;
  105814. backUVs?: Vector4;
  105815. updatable?: boolean;
  105816. }, scene: Scene): Mesh;
  105817. }
  105818. }
  105819. declare module BABYLON {
  105820. /**
  105821. * Class containing static functions to help procedurally build meshes
  105822. */
  105823. export class DecalBuilder {
  105824. /**
  105825. * Creates a decal mesh.
  105826. * 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
  105827. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  105828. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  105829. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  105830. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  105831. * @param name defines the name of the mesh
  105832. * @param sourceMesh defines the mesh where the decal must be applied
  105833. * @param options defines the options used to create the mesh
  105834. * @param scene defines the hosting scene
  105835. * @returns the decal mesh
  105836. * @see https://doc.babylonjs.com/how_to/decals
  105837. */
  105838. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  105839. position?: Vector3;
  105840. normal?: Vector3;
  105841. size?: Vector3;
  105842. angle?: number;
  105843. }): Mesh;
  105844. }
  105845. }
  105846. declare module BABYLON {
  105847. /**
  105848. * Class containing static functions to help procedurally build meshes
  105849. */
  105850. export class MeshBuilder {
  105851. /**
  105852. * Creates a box mesh
  105853. * * The parameter `size` sets the size (float) of each box side (default 1)
  105854. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  105855. * * 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)
  105856. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105857. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105858. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105860. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  105861. * @param name defines the name of the mesh
  105862. * @param options defines the options used to create the mesh
  105863. * @param scene defines the hosting scene
  105864. * @returns the box mesh
  105865. */
  105866. static CreateBox(name: string, options: {
  105867. size?: number;
  105868. width?: number;
  105869. height?: number;
  105870. depth?: number;
  105871. faceUV?: Vector4[];
  105872. faceColors?: Color4[];
  105873. sideOrientation?: number;
  105874. frontUVs?: Vector4;
  105875. backUVs?: Vector4;
  105876. updatable?: boolean;
  105877. }, scene?: Nullable<Scene>): Mesh;
  105878. /**
  105879. * Creates a sphere mesh
  105880. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  105881. * * 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`)
  105882. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  105883. * * 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
  105884. * * 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)
  105885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105886. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105888. * @param name defines the name of the mesh
  105889. * @param options defines the options used to create the mesh
  105890. * @param scene defines the hosting scene
  105891. * @returns the sphere mesh
  105892. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  105893. */
  105894. static CreateSphere(name: string, options: {
  105895. segments?: number;
  105896. diameter?: number;
  105897. diameterX?: number;
  105898. diameterY?: number;
  105899. diameterZ?: number;
  105900. arc?: number;
  105901. slice?: number;
  105902. sideOrientation?: number;
  105903. frontUVs?: Vector4;
  105904. backUVs?: Vector4;
  105905. updatable?: boolean;
  105906. }, scene: any): Mesh;
  105907. /**
  105908. * Creates a plane polygonal mesh. By default, this is a disc
  105909. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  105910. * * 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
  105911. * * 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
  105912. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105913. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105915. * @param name defines the name of the mesh
  105916. * @param options defines the options used to create the mesh
  105917. * @param scene defines the hosting scene
  105918. * @returns the plane polygonal mesh
  105919. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  105920. */
  105921. static CreateDisc(name: string, options: {
  105922. radius?: number;
  105923. tessellation?: number;
  105924. arc?: number;
  105925. updatable?: boolean;
  105926. sideOrientation?: number;
  105927. frontUVs?: Vector4;
  105928. backUVs?: Vector4;
  105929. }, scene?: Nullable<Scene>): Mesh;
  105930. /**
  105931. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105932. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105933. * * 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`)
  105934. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105935. * * 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
  105936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105937. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105939. * @param name defines the name of the mesh
  105940. * @param options defines the options used to create the mesh
  105941. * @param scene defines the hosting scene
  105942. * @returns the icosahedron mesh
  105943. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105944. */
  105945. static CreateIcoSphere(name: string, options: {
  105946. radius?: number;
  105947. radiusX?: number;
  105948. radiusY?: number;
  105949. radiusZ?: number;
  105950. flat?: boolean;
  105951. subdivisions?: number;
  105952. sideOrientation?: number;
  105953. frontUVs?: Vector4;
  105954. backUVs?: Vector4;
  105955. updatable?: boolean;
  105956. }, scene: Scene): Mesh;
  105957. /**
  105958. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105959. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  105960. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  105961. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  105962. * * 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
  105963. * * 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
  105964. * * 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
  105965. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105966. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105967. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105968. * * 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
  105969. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  105970. * * 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
  105971. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  105972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105973. * @param name defines the name of the mesh
  105974. * @param options defines the options used to create the mesh
  105975. * @param scene defines the hosting scene
  105976. * @returns the ribbon mesh
  105977. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  105978. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105979. */
  105980. static CreateRibbon(name: string, options: {
  105981. pathArray: Vector3[][];
  105982. closeArray?: boolean;
  105983. closePath?: boolean;
  105984. offset?: number;
  105985. updatable?: boolean;
  105986. sideOrientation?: number;
  105987. frontUVs?: Vector4;
  105988. backUVs?: Vector4;
  105989. instance?: Mesh;
  105990. invertUV?: boolean;
  105991. uvs?: Vector2[];
  105992. colors?: Color4[];
  105993. }, scene?: Nullable<Scene>): Mesh;
  105994. /**
  105995. * Creates a cylinder or a cone mesh
  105996. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  105997. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  105998. * * 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.
  105999. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  106000. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  106001. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  106002. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  106003. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  106004. * * 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).
  106005. * * 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
  106006. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  106007. * * 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
  106008. * * 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.
  106009. * * If `enclose` is false, a ring surface is one element.
  106010. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  106011. * * 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
  106012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106013. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106015. * @param name defines the name of the mesh
  106016. * @param options defines the options used to create the mesh
  106017. * @param scene defines the hosting scene
  106018. * @returns the cylinder mesh
  106019. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  106020. */
  106021. static CreateCylinder(name: string, options: {
  106022. height?: number;
  106023. diameterTop?: number;
  106024. diameterBottom?: number;
  106025. diameter?: number;
  106026. tessellation?: number;
  106027. subdivisions?: number;
  106028. arc?: number;
  106029. faceColors?: Color4[];
  106030. faceUV?: Vector4[];
  106031. updatable?: boolean;
  106032. hasRings?: boolean;
  106033. enclose?: boolean;
  106034. sideOrientation?: number;
  106035. frontUVs?: Vector4;
  106036. backUVs?: Vector4;
  106037. }, scene: any): Mesh;
  106038. /**
  106039. * Creates a torus mesh
  106040. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  106041. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  106042. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  106043. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106044. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106046. * @param name defines the name of the mesh
  106047. * @param options defines the options used to create the mesh
  106048. * @param scene defines the hosting scene
  106049. * @returns the torus mesh
  106050. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  106051. */
  106052. static CreateTorus(name: string, options: {
  106053. diameter?: number;
  106054. thickness?: number;
  106055. tessellation?: number;
  106056. updatable?: boolean;
  106057. sideOrientation?: number;
  106058. frontUVs?: Vector4;
  106059. backUVs?: Vector4;
  106060. }, scene: any): Mesh;
  106061. /**
  106062. * Creates a torus knot mesh
  106063. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  106064. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  106065. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  106066. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  106067. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106068. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106070. * @param name defines the name of the mesh
  106071. * @param options defines the options used to create the mesh
  106072. * @param scene defines the hosting scene
  106073. * @returns the torus knot mesh
  106074. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  106075. */
  106076. static CreateTorusKnot(name: string, options: {
  106077. radius?: number;
  106078. tube?: number;
  106079. radialSegments?: number;
  106080. tubularSegments?: number;
  106081. p?: number;
  106082. q?: number;
  106083. updatable?: boolean;
  106084. sideOrientation?: number;
  106085. frontUVs?: Vector4;
  106086. backUVs?: Vector4;
  106087. }, scene: any): Mesh;
  106088. /**
  106089. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  106090. * * 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
  106091. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  106092. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  106093. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  106094. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  106095. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  106096. * * 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
  106097. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  106098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106099. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  106100. * @param name defines the name of the new line system
  106101. * @param options defines the options used to create the line system
  106102. * @param scene defines the hosting scene
  106103. * @returns a new line system mesh
  106104. */
  106105. static CreateLineSystem(name: string, options: {
  106106. lines: Vector3[][];
  106107. updatable?: boolean;
  106108. instance?: Nullable<LinesMesh>;
  106109. colors?: Nullable<Color4[][]>;
  106110. useVertexAlpha?: boolean;
  106111. }, scene: Nullable<Scene>): LinesMesh;
  106112. /**
  106113. * Creates a line mesh
  106114. * 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
  106115. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106116. * * The parameter `points` is an array successive Vector3
  106117. * * 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
  106118. * * The optional parameter `colors` is an array of successive Color4, one per line point
  106119. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  106120. * * When updating an instance, remember that only point positions can change, not the number of points
  106121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106122. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  106123. * @param name defines the name of the new line system
  106124. * @param options defines the options used to create the line system
  106125. * @param scene defines the hosting scene
  106126. * @returns a new line mesh
  106127. */
  106128. static CreateLines(name: string, options: {
  106129. points: Vector3[];
  106130. updatable?: boolean;
  106131. instance?: Nullable<LinesMesh>;
  106132. colors?: Color4[];
  106133. useVertexAlpha?: boolean;
  106134. }, scene?: Nullable<Scene>): LinesMesh;
  106135. /**
  106136. * Creates a dashed line mesh
  106137. * * 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
  106138. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106139. * * The parameter `points` is an array successive Vector3
  106140. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  106141. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  106142. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  106143. * * 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
  106144. * * When updating an instance, remember that only point positions can change, not the number of points
  106145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106146. * @param name defines the name of the mesh
  106147. * @param options defines the options used to create the mesh
  106148. * @param scene defines the hosting scene
  106149. * @returns the dashed line mesh
  106150. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  106151. */
  106152. static CreateDashedLines(name: string, options: {
  106153. points: Vector3[];
  106154. dashSize?: number;
  106155. gapSize?: number;
  106156. dashNb?: number;
  106157. updatable?: boolean;
  106158. instance?: LinesMesh;
  106159. }, scene?: Nullable<Scene>): LinesMesh;
  106160. /**
  106161. * 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.
  106162. * * 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.
  106163. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106164. * * 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.
  106165. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  106166. * * 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
  106167. * * 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
  106168. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  106169. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106170. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106171. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  106172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106173. * @param name defines the name of the mesh
  106174. * @param options defines the options used to create the mesh
  106175. * @param scene defines the hosting scene
  106176. * @returns the extruded shape mesh
  106177. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106178. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106179. */
  106180. static ExtrudeShape(name: string, options: {
  106181. shape: Vector3[];
  106182. path: Vector3[];
  106183. scale?: number;
  106184. rotation?: number;
  106185. cap?: number;
  106186. updatable?: boolean;
  106187. sideOrientation?: number;
  106188. frontUVs?: Vector4;
  106189. backUVs?: Vector4;
  106190. instance?: Mesh;
  106191. invertUV?: boolean;
  106192. }, scene?: Nullable<Scene>): Mesh;
  106193. /**
  106194. * Creates an custom extruded shape mesh.
  106195. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  106196. * * 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.
  106197. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106198. * * 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
  106199. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  106200. * * 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
  106201. * * It must returns a float value that will be the scale value applied to the shape on each path point
  106202. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  106203. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  106204. * * 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
  106205. * * 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
  106206. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  106207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106209. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106211. * @param name defines the name of the mesh
  106212. * @param options defines the options used to create the mesh
  106213. * @param scene defines the hosting scene
  106214. * @returns the custom extruded shape mesh
  106215. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  106216. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106217. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106218. */
  106219. static ExtrudeShapeCustom(name: string, options: {
  106220. shape: Vector3[];
  106221. path: Vector3[];
  106222. scaleFunction?: any;
  106223. rotationFunction?: any;
  106224. ribbonCloseArray?: boolean;
  106225. ribbonClosePath?: boolean;
  106226. cap?: number;
  106227. updatable?: boolean;
  106228. sideOrientation?: number;
  106229. frontUVs?: Vector4;
  106230. backUVs?: Vector4;
  106231. instance?: Mesh;
  106232. invertUV?: boolean;
  106233. }, scene: Scene): Mesh;
  106234. /**
  106235. * Creates lathe mesh.
  106236. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  106237. * * 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
  106238. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  106239. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  106240. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  106241. * * 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
  106242. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  106243. * * 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
  106244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106245. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106246. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106248. * @param name defines the name of the mesh
  106249. * @param options defines the options used to create the mesh
  106250. * @param scene defines the hosting scene
  106251. * @returns the lathe mesh
  106252. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  106253. */
  106254. static CreateLathe(name: string, options: {
  106255. shape: Vector3[];
  106256. radius?: number;
  106257. tessellation?: number;
  106258. clip?: number;
  106259. arc?: number;
  106260. closed?: boolean;
  106261. updatable?: boolean;
  106262. sideOrientation?: number;
  106263. frontUVs?: Vector4;
  106264. backUVs?: Vector4;
  106265. cap?: number;
  106266. invertUV?: boolean;
  106267. }, scene: Scene): Mesh;
  106268. /**
  106269. * Creates a plane mesh
  106270. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  106271. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  106272. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  106273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106276. * @param name defines the name of the mesh
  106277. * @param options defines the options used to create the mesh
  106278. * @param scene defines the hosting scene
  106279. * @returns the plane mesh
  106280. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  106281. */
  106282. static CreatePlane(name: string, options: {
  106283. size?: number;
  106284. width?: number;
  106285. height?: number;
  106286. sideOrientation?: number;
  106287. frontUVs?: Vector4;
  106288. backUVs?: Vector4;
  106289. updatable?: boolean;
  106290. sourcePlane?: Plane;
  106291. }, scene: Scene): Mesh;
  106292. /**
  106293. * Creates a ground mesh
  106294. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  106295. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  106296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106297. * @param name defines the name of the mesh
  106298. * @param options defines the options used to create the mesh
  106299. * @param scene defines the hosting scene
  106300. * @returns the ground mesh
  106301. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  106302. */
  106303. static CreateGround(name: string, options: {
  106304. width?: number;
  106305. height?: number;
  106306. subdivisions?: number;
  106307. subdivisionsX?: number;
  106308. subdivisionsY?: number;
  106309. updatable?: boolean;
  106310. }, scene: any): Mesh;
  106311. /**
  106312. * Creates a tiled ground mesh
  106313. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  106314. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  106315. * * 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
  106316. * * 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
  106317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106318. * @param name defines the name of the mesh
  106319. * @param options defines the options used to create the mesh
  106320. * @param scene defines the hosting scene
  106321. * @returns the tiled ground mesh
  106322. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  106323. */
  106324. static CreateTiledGround(name: string, options: {
  106325. xmin: number;
  106326. zmin: number;
  106327. xmax: number;
  106328. zmax: number;
  106329. subdivisions?: {
  106330. w: number;
  106331. h: number;
  106332. };
  106333. precision?: {
  106334. w: number;
  106335. h: number;
  106336. };
  106337. updatable?: boolean;
  106338. }, scene: Scene): Mesh;
  106339. /**
  106340. * Creates a ground mesh from a height map
  106341. * * The parameter `url` sets the URL of the height map image resource.
  106342. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  106343. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  106344. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  106345. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  106346. * * 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.
  106347. * * 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).
  106348. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106350. * @param name defines the name of the mesh
  106351. * @param url defines the url to the height map
  106352. * @param options defines the options used to create the mesh
  106353. * @param scene defines the hosting scene
  106354. * @returns the ground mesh
  106355. * @see https://doc.babylonjs.com/babylon101/height_map
  106356. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  106357. */
  106358. static CreateGroundFromHeightMap(name: string, url: string, options: {
  106359. width?: number;
  106360. height?: number;
  106361. subdivisions?: number;
  106362. minHeight?: number;
  106363. maxHeight?: number;
  106364. colorFilter?: Color3;
  106365. alphaFilter?: number;
  106366. updatable?: boolean;
  106367. onReady?: (mesh: GroundMesh) => void;
  106368. }, scene: Scene): GroundMesh;
  106369. /**
  106370. * Creates a polygon mesh
  106371. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  106372. * * 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
  106373. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  106376. * * Remember you can only change the shape positions, not their number when updating a polygon
  106377. * @param name defines the name of the mesh
  106378. * @param options defines the options used to create the mesh
  106379. * @param scene defines the hosting scene
  106380. * @param earcutInjection can be used to inject your own earcut reference
  106381. * @returns the polygon mesh
  106382. */
  106383. static CreatePolygon(name: string, options: {
  106384. shape: Vector3[];
  106385. holes?: Vector3[][];
  106386. depth?: number;
  106387. faceUV?: Vector4[];
  106388. faceColors?: Color4[];
  106389. updatable?: boolean;
  106390. sideOrientation?: number;
  106391. frontUVs?: Vector4;
  106392. backUVs?: Vector4;
  106393. }, scene: Scene, earcutInjection?: any): Mesh;
  106394. /**
  106395. * Creates an extruded polygon mesh, with depth in the Y direction.
  106396. * * 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)
  106397. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106398. * @param name defines the name of the mesh
  106399. * @param options defines the options used to create the mesh
  106400. * @param scene defines the hosting scene
  106401. * @param earcutInjection can be used to inject your own earcut reference
  106402. * @returns the polygon mesh
  106403. */
  106404. static ExtrudePolygon(name: string, options: {
  106405. shape: Vector3[];
  106406. holes?: Vector3[][];
  106407. depth?: number;
  106408. faceUV?: Vector4[];
  106409. faceColors?: Color4[];
  106410. updatable?: boolean;
  106411. sideOrientation?: number;
  106412. frontUVs?: Vector4;
  106413. backUVs?: Vector4;
  106414. }, scene: Scene, earcutInjection?: any): Mesh;
  106415. /**
  106416. * Creates a tube mesh.
  106417. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106418. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  106419. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  106420. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  106421. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  106422. * * 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)
  106423. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  106424. * * 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
  106425. * * 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
  106426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106427. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106428. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106430. * @param name defines the name of the mesh
  106431. * @param options defines the options used to create the mesh
  106432. * @param scene defines the hosting scene
  106433. * @returns the tube mesh
  106434. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106435. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  106436. */
  106437. static CreateTube(name: string, options: {
  106438. path: Vector3[];
  106439. radius?: number;
  106440. tessellation?: number;
  106441. radiusFunction?: {
  106442. (i: number, distance: number): number;
  106443. };
  106444. cap?: number;
  106445. arc?: number;
  106446. updatable?: boolean;
  106447. sideOrientation?: number;
  106448. frontUVs?: Vector4;
  106449. backUVs?: Vector4;
  106450. instance?: Mesh;
  106451. invertUV?: boolean;
  106452. }, scene: Scene): Mesh;
  106453. /**
  106454. * Creates a polyhedron mesh
  106455. * * 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
  106456. * * The parameter `size` (positive float, default 1) sets the polygon size
  106457. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106458. * * 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`
  106459. * * 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
  106460. * * 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)`)
  106461. * * 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
  106462. * * 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
  106463. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106464. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106466. * @param name defines the name of the mesh
  106467. * @param options defines the options used to create the mesh
  106468. * @param scene defines the hosting scene
  106469. * @returns the polyhedron mesh
  106470. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  106471. */
  106472. static CreatePolyhedron(name: string, options: {
  106473. type?: number;
  106474. size?: number;
  106475. sizeX?: number;
  106476. sizeY?: number;
  106477. sizeZ?: number;
  106478. custom?: any;
  106479. faceUV?: Vector4[];
  106480. faceColors?: Color4[];
  106481. flat?: boolean;
  106482. updatable?: boolean;
  106483. sideOrientation?: number;
  106484. frontUVs?: Vector4;
  106485. backUVs?: Vector4;
  106486. }, scene: Scene): Mesh;
  106487. /**
  106488. * Creates a decal mesh.
  106489. * 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
  106490. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  106491. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  106492. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  106493. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  106494. * @param name defines the name of the mesh
  106495. * @param sourceMesh defines the mesh where the decal must be applied
  106496. * @param options defines the options used to create the mesh
  106497. * @param scene defines the hosting scene
  106498. * @returns the decal mesh
  106499. * @see https://doc.babylonjs.com/how_to/decals
  106500. */
  106501. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  106502. position?: Vector3;
  106503. normal?: Vector3;
  106504. size?: Vector3;
  106505. angle?: number;
  106506. }): Mesh;
  106507. }
  106508. }
  106509. declare module BABYLON {
  106510. /**
  106511. * A simplifier interface for future simplification implementations
  106512. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106513. */
  106514. export interface ISimplifier {
  106515. /**
  106516. * Simplification of a given mesh according to the given settings.
  106517. * Since this requires computation, it is assumed that the function runs async.
  106518. * @param settings The settings of the simplification, including quality and distance
  106519. * @param successCallback A callback that will be called after the mesh was simplified.
  106520. * @param errorCallback in case of an error, this callback will be called. optional.
  106521. */
  106522. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  106523. }
  106524. /**
  106525. * Expected simplification settings.
  106526. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  106527. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106528. */
  106529. export interface ISimplificationSettings {
  106530. /**
  106531. * Gets or sets the expected quality
  106532. */
  106533. quality: number;
  106534. /**
  106535. * Gets or sets the distance when this optimized version should be used
  106536. */
  106537. distance: number;
  106538. /**
  106539. * Gets an already optimized mesh
  106540. */
  106541. optimizeMesh?: boolean;
  106542. }
  106543. /**
  106544. * Class used to specify simplification options
  106545. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106546. */
  106547. export class SimplificationSettings implements ISimplificationSettings {
  106548. /** expected quality */
  106549. quality: number;
  106550. /** distance when this optimized version should be used */
  106551. distance: number;
  106552. /** already optimized mesh */
  106553. optimizeMesh?: boolean | undefined;
  106554. /**
  106555. * Creates a SimplificationSettings
  106556. * @param quality expected quality
  106557. * @param distance distance when this optimized version should be used
  106558. * @param optimizeMesh already optimized mesh
  106559. */
  106560. constructor(
  106561. /** expected quality */
  106562. quality: number,
  106563. /** distance when this optimized version should be used */
  106564. distance: number,
  106565. /** already optimized mesh */
  106566. optimizeMesh?: boolean | undefined);
  106567. }
  106568. /**
  106569. * Interface used to define a simplification task
  106570. */
  106571. export interface ISimplificationTask {
  106572. /**
  106573. * Array of settings
  106574. */
  106575. settings: Array<ISimplificationSettings>;
  106576. /**
  106577. * Simplification type
  106578. */
  106579. simplificationType: SimplificationType;
  106580. /**
  106581. * Mesh to simplify
  106582. */
  106583. mesh: Mesh;
  106584. /**
  106585. * Callback called on success
  106586. */
  106587. successCallback?: () => void;
  106588. /**
  106589. * Defines if parallel processing can be used
  106590. */
  106591. parallelProcessing: boolean;
  106592. }
  106593. /**
  106594. * Queue used to order the simplification tasks
  106595. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106596. */
  106597. export class SimplificationQueue {
  106598. private _simplificationArray;
  106599. /**
  106600. * Gets a boolean indicating that the process is still running
  106601. */
  106602. running: boolean;
  106603. /**
  106604. * Creates a new queue
  106605. */
  106606. constructor();
  106607. /**
  106608. * Adds a new simplification task
  106609. * @param task defines a task to add
  106610. */
  106611. addTask(task: ISimplificationTask): void;
  106612. /**
  106613. * Execute next task
  106614. */
  106615. executeNext(): void;
  106616. /**
  106617. * Execute a simplification task
  106618. * @param task defines the task to run
  106619. */
  106620. runSimplification(task: ISimplificationTask): void;
  106621. private getSimplifier;
  106622. }
  106623. /**
  106624. * The implemented types of simplification
  106625. * At the moment only Quadratic Error Decimation is implemented
  106626. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106627. */
  106628. export enum SimplificationType {
  106629. /** Quadratic error decimation */
  106630. QUADRATIC = 0
  106631. }
  106632. }
  106633. declare module BABYLON {
  106634. interface Scene {
  106635. /** @hidden (Backing field) */
  106636. _simplificationQueue: SimplificationQueue;
  106637. /**
  106638. * Gets or sets the simplification queue attached to the scene
  106639. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106640. */
  106641. simplificationQueue: SimplificationQueue;
  106642. }
  106643. interface Mesh {
  106644. /**
  106645. * Simplify the mesh according to the given array of settings.
  106646. * Function will return immediately and will simplify async
  106647. * @param settings a collection of simplification settings
  106648. * @param parallelProcessing should all levels calculate parallel or one after the other
  106649. * @param simplificationType the type of simplification to run
  106650. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  106651. * @returns the current mesh
  106652. */
  106653. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  106654. }
  106655. /**
  106656. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  106657. * created in a scene
  106658. */
  106659. export class SimplicationQueueSceneComponent implements ISceneComponent {
  106660. /**
  106661. * The component name helpfull to identify the component in the list of scene components.
  106662. */
  106663. readonly name: string;
  106664. /**
  106665. * The scene the component belongs to.
  106666. */
  106667. scene: Scene;
  106668. /**
  106669. * Creates a new instance of the component for the given scene
  106670. * @param scene Defines the scene to register the component in
  106671. */
  106672. constructor(scene: Scene);
  106673. /**
  106674. * Registers the component in a given scene
  106675. */
  106676. register(): void;
  106677. /**
  106678. * Rebuilds the elements related to this component in case of
  106679. * context lost for instance.
  106680. */
  106681. rebuild(): void;
  106682. /**
  106683. * Disposes the component and the associated ressources
  106684. */
  106685. dispose(): void;
  106686. private _beforeCameraUpdate;
  106687. }
  106688. }
  106689. declare module BABYLON {
  106690. /**
  106691. * Class used to enable access to IndexedDB
  106692. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  106693. */
  106694. export class Database implements IOfflineProvider {
  106695. private _callbackManifestChecked;
  106696. private _currentSceneUrl;
  106697. private _db;
  106698. private _enableSceneOffline;
  106699. private _enableTexturesOffline;
  106700. private _manifestVersionFound;
  106701. private _mustUpdateRessources;
  106702. private _hasReachedQuota;
  106703. private _isSupported;
  106704. private _idbFactory;
  106705. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  106706. private static IsUASupportingBlobStorage;
  106707. /**
  106708. * Gets a boolean indicating if Database storate is enabled (off by default)
  106709. */
  106710. static IDBStorageEnabled: boolean;
  106711. /**
  106712. * Gets a boolean indicating if scene must be saved in the database
  106713. */
  106714. readonly enableSceneOffline: boolean;
  106715. /**
  106716. * Gets a boolean indicating if textures must be saved in the database
  106717. */
  106718. readonly enableTexturesOffline: boolean;
  106719. /**
  106720. * Creates a new Database
  106721. * @param urlToScene defines the url to load the scene
  106722. * @param callbackManifestChecked defines the callback to use when manifest is checked
  106723. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  106724. */
  106725. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  106726. private static _ParseURL;
  106727. private static _ReturnFullUrlLocation;
  106728. private _checkManifestFile;
  106729. /**
  106730. * Open the database and make it available
  106731. * @param successCallback defines the callback to call on success
  106732. * @param errorCallback defines the callback to call on error
  106733. */
  106734. open(successCallback: () => void, errorCallback: () => void): void;
  106735. /**
  106736. * Loads an image from the database
  106737. * @param url defines the url to load from
  106738. * @param image defines the target DOM image
  106739. */
  106740. loadImage(url: string, image: HTMLImageElement): void;
  106741. private _loadImageFromDBAsync;
  106742. private _saveImageIntoDBAsync;
  106743. private _checkVersionFromDB;
  106744. private _loadVersionFromDBAsync;
  106745. private _saveVersionIntoDBAsync;
  106746. /**
  106747. * Loads a file from database
  106748. * @param url defines the URL to load from
  106749. * @param sceneLoaded defines a callback to call on success
  106750. * @param progressCallBack defines a callback to call when progress changed
  106751. * @param errorCallback defines a callback to call on error
  106752. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  106753. */
  106754. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  106755. private _loadFileAsync;
  106756. private _saveFileAsync;
  106757. /**
  106758. * Validates if xhr data is correct
  106759. * @param xhr defines the request to validate
  106760. * @param dataType defines the expected data type
  106761. * @returns true if data is correct
  106762. */
  106763. private static _ValidateXHRData;
  106764. }
  106765. }
  106766. declare module BABYLON {
  106767. /** @hidden */
  106768. export var gpuUpdateParticlesPixelShader: {
  106769. name: string;
  106770. shader: string;
  106771. };
  106772. }
  106773. declare module BABYLON {
  106774. /** @hidden */
  106775. export var gpuUpdateParticlesVertexShader: {
  106776. name: string;
  106777. shader: string;
  106778. };
  106779. }
  106780. declare module BABYLON {
  106781. /** @hidden */
  106782. export var clipPlaneFragmentDeclaration2: {
  106783. name: string;
  106784. shader: string;
  106785. };
  106786. }
  106787. declare module BABYLON {
  106788. /** @hidden */
  106789. export var gpuRenderParticlesPixelShader: {
  106790. name: string;
  106791. shader: string;
  106792. };
  106793. }
  106794. declare module BABYLON {
  106795. /** @hidden */
  106796. export var clipPlaneVertexDeclaration2: {
  106797. name: string;
  106798. shader: string;
  106799. };
  106800. }
  106801. declare module BABYLON {
  106802. /** @hidden */
  106803. export var gpuRenderParticlesVertexShader: {
  106804. name: string;
  106805. shader: string;
  106806. };
  106807. }
  106808. declare module BABYLON {
  106809. /**
  106810. * This represents a GPU particle system in Babylon
  106811. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  106812. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  106813. */
  106814. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  106815. /**
  106816. * The layer mask we are rendering the particles through.
  106817. */
  106818. layerMask: number;
  106819. private _capacity;
  106820. private _activeCount;
  106821. private _currentActiveCount;
  106822. private _accumulatedCount;
  106823. private _renderEffect;
  106824. private _updateEffect;
  106825. private _buffer0;
  106826. private _buffer1;
  106827. private _spriteBuffer;
  106828. private _updateVAO;
  106829. private _renderVAO;
  106830. private _targetIndex;
  106831. private _sourceBuffer;
  106832. private _targetBuffer;
  106833. private _engine;
  106834. private _currentRenderId;
  106835. private _started;
  106836. private _stopped;
  106837. private _timeDelta;
  106838. private _randomTexture;
  106839. private _randomTexture2;
  106840. private _attributesStrideSize;
  106841. private _updateEffectOptions;
  106842. private _randomTextureSize;
  106843. private _actualFrame;
  106844. private readonly _rawTextureWidth;
  106845. /**
  106846. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  106847. */
  106848. static readonly IsSupported: boolean;
  106849. /**
  106850. * An event triggered when the system is disposed.
  106851. */
  106852. onDisposeObservable: Observable<GPUParticleSystem>;
  106853. /**
  106854. * Gets the maximum number of particles active at the same time.
  106855. * @returns The max number of active particles.
  106856. */
  106857. getCapacity(): number;
  106858. /**
  106859. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  106860. * to override the particles.
  106861. */
  106862. forceDepthWrite: boolean;
  106863. /**
  106864. * Gets or set the number of active particles
  106865. */
  106866. activeParticleCount: number;
  106867. private _preWarmDone;
  106868. /**
  106869. * Is this system ready to be used/rendered
  106870. * @return true if the system is ready
  106871. */
  106872. isReady(): boolean;
  106873. /**
  106874. * Gets if the system has been started. (Note: this will still be true after stop is called)
  106875. * @returns True if it has been started, otherwise false.
  106876. */
  106877. isStarted(): boolean;
  106878. /**
  106879. * Starts the particle system and begins to emit
  106880. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  106881. */
  106882. start(delay?: number): void;
  106883. /**
  106884. * Stops the particle system.
  106885. */
  106886. stop(): void;
  106887. /**
  106888. * Remove all active particles
  106889. */
  106890. reset(): void;
  106891. /**
  106892. * Returns the string "GPUParticleSystem"
  106893. * @returns a string containing the class name
  106894. */
  106895. getClassName(): string;
  106896. private _colorGradientsTexture;
  106897. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  106898. /**
  106899. * Adds a new color gradient
  106900. * @param gradient defines the gradient to use (between 0 and 1)
  106901. * @param color1 defines the color to affect to the specified gradient
  106902. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  106903. * @returns the current particle system
  106904. */
  106905. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  106906. /**
  106907. * Remove a specific color gradient
  106908. * @param gradient defines the gradient to remove
  106909. * @returns the current particle system
  106910. */
  106911. removeColorGradient(gradient: number): GPUParticleSystem;
  106912. private _angularSpeedGradientsTexture;
  106913. private _sizeGradientsTexture;
  106914. private _velocityGradientsTexture;
  106915. private _limitVelocityGradientsTexture;
  106916. private _dragGradientsTexture;
  106917. private _addFactorGradient;
  106918. /**
  106919. * Adds a new size gradient
  106920. * @param gradient defines the gradient to use (between 0 and 1)
  106921. * @param factor defines the size factor to affect to the specified gradient
  106922. * @returns the current particle system
  106923. */
  106924. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  106925. /**
  106926. * Remove a specific size gradient
  106927. * @param gradient defines the gradient to remove
  106928. * @returns the current particle system
  106929. */
  106930. removeSizeGradient(gradient: number): GPUParticleSystem;
  106931. /**
  106932. * Adds a new angular speed gradient
  106933. * @param gradient defines the gradient to use (between 0 and 1)
  106934. * @param factor defines the angular speed to affect to the specified gradient
  106935. * @returns the current particle system
  106936. */
  106937. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  106938. /**
  106939. * Remove a specific angular speed gradient
  106940. * @param gradient defines the gradient to remove
  106941. * @returns the current particle system
  106942. */
  106943. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  106944. /**
  106945. * Adds a new velocity gradient
  106946. * @param gradient defines the gradient to use (between 0 and 1)
  106947. * @param factor defines the velocity to affect to the specified gradient
  106948. * @returns the current particle system
  106949. */
  106950. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  106951. /**
  106952. * Remove a specific velocity gradient
  106953. * @param gradient defines the gradient to remove
  106954. * @returns the current particle system
  106955. */
  106956. removeVelocityGradient(gradient: number): GPUParticleSystem;
  106957. /**
  106958. * Adds a new limit velocity gradient
  106959. * @param gradient defines the gradient to use (between 0 and 1)
  106960. * @param factor defines the limit velocity value to affect to the specified gradient
  106961. * @returns the current particle system
  106962. */
  106963. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  106964. /**
  106965. * Remove a specific limit velocity gradient
  106966. * @param gradient defines the gradient to remove
  106967. * @returns the current particle system
  106968. */
  106969. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  106970. /**
  106971. * Adds a new drag gradient
  106972. * @param gradient defines the gradient to use (between 0 and 1)
  106973. * @param factor defines the drag value to affect to the specified gradient
  106974. * @returns the current particle system
  106975. */
  106976. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  106977. /**
  106978. * Remove a specific drag gradient
  106979. * @param gradient defines the gradient to remove
  106980. * @returns the current particle system
  106981. */
  106982. removeDragGradient(gradient: number): GPUParticleSystem;
  106983. /**
  106984. * Not supported by GPUParticleSystem
  106985. * @param gradient defines the gradient to use (between 0 and 1)
  106986. * @param factor defines the emit rate value to affect to the specified gradient
  106987. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106988. * @returns the current particle system
  106989. */
  106990. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  106991. /**
  106992. * Not supported by GPUParticleSystem
  106993. * @param gradient defines the gradient to remove
  106994. * @returns the current particle system
  106995. */
  106996. removeEmitRateGradient(gradient: number): IParticleSystem;
  106997. /**
  106998. * Not supported by GPUParticleSystem
  106999. * @param gradient defines the gradient to use (between 0 and 1)
  107000. * @param factor defines the start size value to affect to the specified gradient
  107001. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107002. * @returns the current particle system
  107003. */
  107004. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107005. /**
  107006. * Not supported by GPUParticleSystem
  107007. * @param gradient defines the gradient to remove
  107008. * @returns the current particle system
  107009. */
  107010. removeStartSizeGradient(gradient: number): IParticleSystem;
  107011. /**
  107012. * Not supported by GPUParticleSystem
  107013. * @param gradient defines the gradient to use (between 0 and 1)
  107014. * @param min defines the color remap minimal range
  107015. * @param max defines the color remap maximal range
  107016. * @returns the current particle system
  107017. */
  107018. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  107019. /**
  107020. * Not supported by GPUParticleSystem
  107021. * @param gradient defines the gradient to remove
  107022. * @returns the current particle system
  107023. */
  107024. removeColorRemapGradient(): IParticleSystem;
  107025. /**
  107026. * Not supported by GPUParticleSystem
  107027. * @param gradient defines the gradient to use (between 0 and 1)
  107028. * @param min defines the alpha remap minimal range
  107029. * @param max defines the alpha remap maximal range
  107030. * @returns the current particle system
  107031. */
  107032. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  107033. /**
  107034. * Not supported by GPUParticleSystem
  107035. * @param gradient defines the gradient to remove
  107036. * @returns the current particle system
  107037. */
  107038. removeAlphaRemapGradient(): IParticleSystem;
  107039. /**
  107040. * Not supported by GPUParticleSystem
  107041. * @param gradient defines the gradient to use (between 0 and 1)
  107042. * @param color defines the color to affect to the specified gradient
  107043. * @returns the current particle system
  107044. */
  107045. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  107046. /**
  107047. * Not supported by GPUParticleSystem
  107048. * @param gradient defines the gradient to remove
  107049. * @returns the current particle system
  107050. */
  107051. removeRampGradient(): IParticleSystem;
  107052. /**
  107053. * Not supported by GPUParticleSystem
  107054. * @returns the list of ramp gradients
  107055. */
  107056. getRampGradients(): Nullable<Array<Color3Gradient>>;
  107057. /**
  107058. * Not supported by GPUParticleSystem
  107059. * Gets or sets a boolean indicating that ramp gradients must be used
  107060. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  107061. */
  107062. useRampGradients: boolean;
  107063. /**
  107064. * Not supported by GPUParticleSystem
  107065. * @param gradient defines the gradient to use (between 0 and 1)
  107066. * @param factor defines the life time factor to affect to the specified gradient
  107067. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107068. * @returns the current particle system
  107069. */
  107070. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107071. /**
  107072. * Not supported by GPUParticleSystem
  107073. * @param gradient defines the gradient to remove
  107074. * @returns the current particle system
  107075. */
  107076. removeLifeTimeGradient(gradient: number): IParticleSystem;
  107077. /**
  107078. * Instantiates a GPU particle system.
  107079. * 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.
  107080. * @param name The name of the particle system
  107081. * @param options The options used to create the system
  107082. * @param scene The scene the particle system belongs to
  107083. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  107084. */
  107085. constructor(name: string, options: Partial<{
  107086. capacity: number;
  107087. randomTextureSize: number;
  107088. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  107089. protected _reset(): void;
  107090. private _createUpdateVAO;
  107091. private _createRenderVAO;
  107092. private _initialize;
  107093. /** @hidden */
  107094. _recreateUpdateEffect(): void;
  107095. /** @hidden */
  107096. _recreateRenderEffect(): void;
  107097. /**
  107098. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  107099. * @param preWarm defines if we are in the pre-warmimg phase
  107100. */
  107101. animate(preWarm?: boolean): void;
  107102. private _createFactorGradientTexture;
  107103. private _createSizeGradientTexture;
  107104. private _createAngularSpeedGradientTexture;
  107105. private _createVelocityGradientTexture;
  107106. private _createLimitVelocityGradientTexture;
  107107. private _createDragGradientTexture;
  107108. private _createColorGradientTexture;
  107109. /**
  107110. * Renders the particle system in its current state
  107111. * @param preWarm defines if the system should only update the particles but not render them
  107112. * @returns the current number of particles
  107113. */
  107114. render(preWarm?: boolean): number;
  107115. /**
  107116. * Rebuilds the particle system
  107117. */
  107118. rebuild(): void;
  107119. private _releaseBuffers;
  107120. private _releaseVAOs;
  107121. /**
  107122. * Disposes the particle system and free the associated resources
  107123. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  107124. */
  107125. dispose(disposeTexture?: boolean): void;
  107126. /**
  107127. * Clones the particle system.
  107128. * @param name The name of the cloned object
  107129. * @param newEmitter The new emitter to use
  107130. * @returns the cloned particle system
  107131. */
  107132. clone(name: string, newEmitter: any): GPUParticleSystem;
  107133. /**
  107134. * Serializes the particle system to a JSON object.
  107135. * @returns the JSON object
  107136. */
  107137. serialize(): any;
  107138. /**
  107139. * Parses a JSON object to create a GPU particle system.
  107140. * @param parsedParticleSystem The JSON object to parse
  107141. * @param scene The scene to create the particle system in
  107142. * @param rootUrl The root url to use to load external dependencies like texture
  107143. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  107144. * @returns the parsed GPU particle system
  107145. */
  107146. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  107147. }
  107148. }
  107149. declare module BABYLON {
  107150. /**
  107151. * Represents a set of particle systems working together to create a specific effect
  107152. */
  107153. export class ParticleSystemSet implements IDisposable {
  107154. private _emitterCreationOptions;
  107155. private _emitterNode;
  107156. /**
  107157. * Gets the particle system list
  107158. */
  107159. systems: IParticleSystem[];
  107160. /**
  107161. * Gets the emitter node used with this set
  107162. */
  107163. readonly emitterNode: Nullable<TransformNode>;
  107164. /**
  107165. * Creates a new emitter mesh as a sphere
  107166. * @param options defines the options used to create the sphere
  107167. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  107168. * @param scene defines the hosting scene
  107169. */
  107170. setEmitterAsSphere(options: {
  107171. diameter: number;
  107172. segments: number;
  107173. color: Color3;
  107174. }, renderingGroupId: number, scene: Scene): void;
  107175. /**
  107176. * Starts all particle systems of the set
  107177. * @param emitter defines an optional mesh to use as emitter for the particle systems
  107178. */
  107179. start(emitter?: AbstractMesh): void;
  107180. /**
  107181. * Release all associated resources
  107182. */
  107183. dispose(): void;
  107184. /**
  107185. * Serialize the set into a JSON compatible object
  107186. * @returns a JSON compatible representation of the set
  107187. */
  107188. serialize(): any;
  107189. /**
  107190. * Parse a new ParticleSystemSet from a serialized source
  107191. * @param data defines a JSON compatible representation of the set
  107192. * @param scene defines the hosting scene
  107193. * @param gpu defines if we want GPU particles or CPU particles
  107194. * @returns a new ParticleSystemSet
  107195. */
  107196. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  107197. }
  107198. }
  107199. declare module BABYLON {
  107200. /**
  107201. * This class is made for on one-liner static method to help creating particle system set.
  107202. */
  107203. export class ParticleHelper {
  107204. /**
  107205. * Gets or sets base Assets URL
  107206. */
  107207. static BaseAssetsUrl: string;
  107208. /**
  107209. * Create a default particle system that you can tweak
  107210. * @param emitter defines the emitter to use
  107211. * @param capacity defines the system capacity (default is 500 particles)
  107212. * @param scene defines the hosting scene
  107213. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  107214. * @returns the new Particle system
  107215. */
  107216. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  107217. /**
  107218. * This is the main static method (one-liner) of this helper to create different particle systems
  107219. * @param type This string represents the type to the particle system to create
  107220. * @param scene The scene where the particle system should live
  107221. * @param gpu If the system will use gpu
  107222. * @returns the ParticleSystemSet created
  107223. */
  107224. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  107225. /**
  107226. * Static function used to export a particle system to a ParticleSystemSet variable.
  107227. * Please note that the emitter shape is not exported
  107228. * @param systems defines the particle systems to export
  107229. * @returns the created particle system set
  107230. */
  107231. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  107232. }
  107233. }
  107234. declare module BABYLON {
  107235. interface Engine {
  107236. /**
  107237. * Create an effect to use with particle systems.
  107238. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  107239. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  107240. * @param uniformsNames defines a list of attribute names
  107241. * @param samplers defines an array of string used to represent textures
  107242. * @param defines defines the string containing the defines to use to compile the shaders
  107243. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  107244. * @param onCompiled defines a function to call when the effect creation is successful
  107245. * @param onError defines a function to call when the effect creation has failed
  107246. * @returns the new Effect
  107247. */
  107248. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  107249. }
  107250. interface Mesh {
  107251. /**
  107252. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  107253. * @returns an array of IParticleSystem
  107254. */
  107255. getEmittedParticleSystems(): IParticleSystem[];
  107256. /**
  107257. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  107258. * @returns an array of IParticleSystem
  107259. */
  107260. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  107261. }
  107262. /**
  107263. * @hidden
  107264. */
  107265. export var _IDoNeedToBeInTheBuild: number;
  107266. }
  107267. declare module BABYLON {
  107268. interface Scene {
  107269. /** @hidden (Backing field) */
  107270. _physicsEngine: Nullable<IPhysicsEngine>;
  107271. /**
  107272. * Gets the current physics engine
  107273. * @returns a IPhysicsEngine or null if none attached
  107274. */
  107275. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  107276. /**
  107277. * Enables physics to the current scene
  107278. * @param gravity defines the scene's gravity for the physics engine
  107279. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  107280. * @return a boolean indicating if the physics engine was initialized
  107281. */
  107282. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  107283. /**
  107284. * Disables and disposes the physics engine associated with the scene
  107285. */
  107286. disablePhysicsEngine(): void;
  107287. /**
  107288. * Gets a boolean indicating if there is an active physics engine
  107289. * @returns a boolean indicating if there is an active physics engine
  107290. */
  107291. isPhysicsEnabled(): boolean;
  107292. /**
  107293. * Deletes a physics compound impostor
  107294. * @param compound defines the compound to delete
  107295. */
  107296. deleteCompoundImpostor(compound: any): void;
  107297. /**
  107298. * An event triggered when physic simulation is about to be run
  107299. */
  107300. onBeforePhysicsObservable: Observable<Scene>;
  107301. /**
  107302. * An event triggered when physic simulation has been done
  107303. */
  107304. onAfterPhysicsObservable: Observable<Scene>;
  107305. }
  107306. interface AbstractMesh {
  107307. /** @hidden */
  107308. _physicsImpostor: Nullable<PhysicsImpostor>;
  107309. /**
  107310. * Gets or sets impostor used for physic simulation
  107311. * @see http://doc.babylonjs.com/features/physics_engine
  107312. */
  107313. physicsImpostor: Nullable<PhysicsImpostor>;
  107314. /**
  107315. * Gets the current physics impostor
  107316. * @see http://doc.babylonjs.com/features/physics_engine
  107317. * @returns a physics impostor or null
  107318. */
  107319. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  107320. /** Apply a physic impulse to the mesh
  107321. * @param force defines the force to apply
  107322. * @param contactPoint defines where to apply the force
  107323. * @returns the current mesh
  107324. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  107325. */
  107326. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  107327. /**
  107328. * Creates a physic joint between two meshes
  107329. * @param otherMesh defines the other mesh to use
  107330. * @param pivot1 defines the pivot to use on this mesh
  107331. * @param pivot2 defines the pivot to use on the other mesh
  107332. * @param options defines additional options (can be plugin dependent)
  107333. * @returns the current mesh
  107334. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  107335. */
  107336. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  107337. /** @hidden */
  107338. _disposePhysicsObserver: Nullable<Observer<Node>>;
  107339. }
  107340. /**
  107341. * Defines the physics engine scene component responsible to manage a physics engine
  107342. */
  107343. export class PhysicsEngineSceneComponent implements ISceneComponent {
  107344. /**
  107345. * The component name helpful to identify the component in the list of scene components.
  107346. */
  107347. readonly name: string;
  107348. /**
  107349. * The scene the component belongs to.
  107350. */
  107351. scene: Scene;
  107352. /**
  107353. * Creates a new instance of the component for the given scene
  107354. * @param scene Defines the scene to register the component in
  107355. */
  107356. constructor(scene: Scene);
  107357. /**
  107358. * Registers the component in a given scene
  107359. */
  107360. register(): void;
  107361. /**
  107362. * Rebuilds the elements related to this component in case of
  107363. * context lost for instance.
  107364. */
  107365. rebuild(): void;
  107366. /**
  107367. * Disposes the component and the associated ressources
  107368. */
  107369. dispose(): void;
  107370. }
  107371. }
  107372. declare module BABYLON {
  107373. /**
  107374. * A helper for physics simulations
  107375. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107376. */
  107377. export class PhysicsHelper {
  107378. private _scene;
  107379. private _physicsEngine;
  107380. /**
  107381. * Initializes the Physics helper
  107382. * @param scene Babylon.js scene
  107383. */
  107384. constructor(scene: Scene);
  107385. /**
  107386. * Applies a radial explosion impulse
  107387. * @param origin the origin of the explosion
  107388. * @param radius the explosion radius
  107389. * @param strength the explosion strength
  107390. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107391. * @returns A physics radial explosion event, or null
  107392. */
  107393. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  107394. /**
  107395. * Applies a radial explosion force
  107396. * @param origin the origin of the explosion
  107397. * @param radius the explosion radius
  107398. * @param strength the explosion strength
  107399. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107400. * @returns A physics radial explosion event, or null
  107401. */
  107402. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  107403. /**
  107404. * Creates a gravitational field
  107405. * @param origin the origin of the explosion
  107406. * @param radius the explosion radius
  107407. * @param strength the explosion strength
  107408. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107409. * @returns A physics gravitational field event, or null
  107410. */
  107411. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  107412. /**
  107413. * Creates a physics updraft event
  107414. * @param origin the origin of the updraft
  107415. * @param radius the radius of the updraft
  107416. * @param strength the strength of the updraft
  107417. * @param height the height of the updraft
  107418. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  107419. * @returns A physics updraft event, or null
  107420. */
  107421. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  107422. /**
  107423. * Creates a physics vortex event
  107424. * @param origin the of the vortex
  107425. * @param radius the radius of the vortex
  107426. * @param strength the strength of the vortex
  107427. * @param height the height of the vortex
  107428. * @returns a Physics vortex event, or null
  107429. * A physics vortex event or null
  107430. */
  107431. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  107432. }
  107433. /**
  107434. * Represents a physics radial explosion event
  107435. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107436. */
  107437. export class PhysicsRadialExplosionEvent {
  107438. private _scene;
  107439. private _sphere;
  107440. private _sphereOptions;
  107441. private _rays;
  107442. private _dataFetched;
  107443. /**
  107444. * Initializes a radial explosioin event
  107445. * @param scene BabylonJS scene
  107446. */
  107447. constructor(scene: Scene);
  107448. /**
  107449. * Returns the data related to the radial explosion event (sphere & rays).
  107450. * @returns The radial explosion event data
  107451. */
  107452. getData(): PhysicsRadialExplosionEventData;
  107453. /**
  107454. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  107455. * @param impostor A physics imposter
  107456. * @param origin the origin of the explosion
  107457. * @param radius the explosion radius
  107458. * @param strength the explosion strength
  107459. * @param falloff possible options: Constant & Linear
  107460. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  107461. */
  107462. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  107463. /**
  107464. * Disposes the sphere.
  107465. * @param force Specifies if the sphere should be disposed by force
  107466. */
  107467. dispose(force?: boolean): void;
  107468. /*** Helpers ***/
  107469. private _prepareSphere;
  107470. private _intersectsWithSphere;
  107471. }
  107472. /**
  107473. * Represents a gravitational field event
  107474. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107475. */
  107476. export class PhysicsGravitationalFieldEvent {
  107477. private _physicsHelper;
  107478. private _scene;
  107479. private _origin;
  107480. private _radius;
  107481. private _strength;
  107482. private _falloff;
  107483. private _tickCallback;
  107484. private _sphere;
  107485. private _dataFetched;
  107486. /**
  107487. * Initializes the physics gravitational field event
  107488. * @param physicsHelper A physics helper
  107489. * @param scene BabylonJS scene
  107490. * @param origin The origin position of the gravitational field event
  107491. * @param radius The radius of the gravitational field event
  107492. * @param strength The strength of the gravitational field event
  107493. * @param falloff The falloff for the gravitational field event
  107494. */
  107495. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  107496. /**
  107497. * Returns the data related to the gravitational field event (sphere).
  107498. * @returns A gravitational field event
  107499. */
  107500. getData(): PhysicsGravitationalFieldEventData;
  107501. /**
  107502. * Enables the gravitational field.
  107503. */
  107504. enable(): void;
  107505. /**
  107506. * Disables the gravitational field.
  107507. */
  107508. disable(): void;
  107509. /**
  107510. * Disposes the sphere.
  107511. * @param force The force to dispose from the gravitational field event
  107512. */
  107513. dispose(force?: boolean): void;
  107514. private _tick;
  107515. }
  107516. /**
  107517. * Represents a physics updraft event
  107518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107519. */
  107520. export class PhysicsUpdraftEvent {
  107521. private _scene;
  107522. private _origin;
  107523. private _radius;
  107524. private _strength;
  107525. private _height;
  107526. private _updraftMode;
  107527. private _physicsEngine;
  107528. private _originTop;
  107529. private _originDirection;
  107530. private _tickCallback;
  107531. private _cylinder;
  107532. private _cylinderPosition;
  107533. private _dataFetched;
  107534. /**
  107535. * Initializes the physics updraft event
  107536. * @param _scene BabylonJS scene
  107537. * @param _origin The origin position of the updraft
  107538. * @param _radius The radius of the updraft
  107539. * @param _strength The strength of the updraft
  107540. * @param _height The height of the updraft
  107541. * @param _updraftMode The mode of the updraft
  107542. */
  107543. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  107544. /**
  107545. * Returns the data related to the updraft event (cylinder).
  107546. * @returns A physics updraft event
  107547. */
  107548. getData(): PhysicsUpdraftEventData;
  107549. /**
  107550. * Enables the updraft.
  107551. */
  107552. enable(): void;
  107553. /**
  107554. * Disables the cortex.
  107555. */
  107556. disable(): void;
  107557. /**
  107558. * Disposes the sphere.
  107559. * @param force Specifies if the updraft should be disposed by force
  107560. */
  107561. dispose(force?: boolean): void;
  107562. private getImpostorForceAndContactPoint;
  107563. private _tick;
  107564. /*** Helpers ***/
  107565. private _prepareCylinder;
  107566. private _intersectsWithCylinder;
  107567. }
  107568. /**
  107569. * Represents a physics vortex event
  107570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107571. */
  107572. export class PhysicsVortexEvent {
  107573. private _scene;
  107574. private _origin;
  107575. private _radius;
  107576. private _strength;
  107577. private _height;
  107578. private _physicsEngine;
  107579. private _originTop;
  107580. private _centripetalForceThreshold;
  107581. private _updraftMultiplier;
  107582. private _tickCallback;
  107583. private _cylinder;
  107584. private _cylinderPosition;
  107585. private _dataFetched;
  107586. /**
  107587. * Initializes the physics vortex event
  107588. * @param _scene The BabylonJS scene
  107589. * @param _origin The origin position of the vortex
  107590. * @param _radius The radius of the vortex
  107591. * @param _strength The strength of the vortex
  107592. * @param _height The height of the vortex
  107593. */
  107594. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  107595. /**
  107596. * Returns the data related to the vortex event (cylinder).
  107597. * @returns The physics vortex event data
  107598. */
  107599. getData(): PhysicsVortexEventData;
  107600. /**
  107601. * Enables the vortex.
  107602. */
  107603. enable(): void;
  107604. /**
  107605. * Disables the cortex.
  107606. */
  107607. disable(): void;
  107608. /**
  107609. * Disposes the sphere.
  107610. * @param force
  107611. */
  107612. dispose(force?: boolean): void;
  107613. private getImpostorForceAndContactPoint;
  107614. private _tick;
  107615. /*** Helpers ***/
  107616. private _prepareCylinder;
  107617. private _intersectsWithCylinder;
  107618. }
  107619. /**
  107620. * The strenght of the force in correspondence to the distance of the affected object
  107621. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107622. */
  107623. export enum PhysicsRadialImpulseFalloff {
  107624. /** Defines that impulse is constant in strength across it's whole radius */
  107625. Constant = 0,
  107626. /** DEfines that impulse gets weaker if it's further from the origin */
  107627. Linear = 1
  107628. }
  107629. /**
  107630. * The strength of the force in correspondence to the distance of the affected object
  107631. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107632. */
  107633. export enum PhysicsUpdraftMode {
  107634. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  107635. Center = 0,
  107636. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  107637. Perpendicular = 1
  107638. }
  107639. /**
  107640. * Interface for a physics force and contact point
  107641. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107642. */
  107643. export interface PhysicsForceAndContactPoint {
  107644. /**
  107645. * The force applied at the contact point
  107646. */
  107647. force: Vector3;
  107648. /**
  107649. * The contact point
  107650. */
  107651. contactPoint: Vector3;
  107652. }
  107653. /**
  107654. * Interface for radial explosion event data
  107655. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107656. */
  107657. export interface PhysicsRadialExplosionEventData {
  107658. /**
  107659. * A sphere used for the radial explosion event
  107660. */
  107661. sphere: Mesh;
  107662. /**
  107663. * An array of rays for the radial explosion event
  107664. */
  107665. rays: Array<Ray>;
  107666. }
  107667. /**
  107668. * Interface for gravitational field event data
  107669. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107670. */
  107671. export interface PhysicsGravitationalFieldEventData {
  107672. /**
  107673. * A sphere mesh used for the gravitational field event
  107674. */
  107675. sphere: Mesh;
  107676. }
  107677. /**
  107678. * Interface for updraft event data
  107679. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107680. */
  107681. export interface PhysicsUpdraftEventData {
  107682. /**
  107683. * A cylinder used for the updraft event
  107684. */
  107685. cylinder: Mesh;
  107686. }
  107687. /**
  107688. * Interface for vortex event data
  107689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107690. */
  107691. export interface PhysicsVortexEventData {
  107692. /**
  107693. * A cylinder used for the vortex event
  107694. */
  107695. cylinder: Mesh;
  107696. }
  107697. }
  107698. declare module BABYLON {
  107699. /**
  107700. * AmmoJS Physics plugin
  107701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107702. * @see https://github.com/kripken/ammo.js/
  107703. */
  107704. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  107705. private _useDeltaForWorldStep;
  107706. /**
  107707. * Reference to the Ammo library
  107708. */
  107709. bjsAMMO: any;
  107710. /**
  107711. * Created ammoJS world which physics bodies are added to
  107712. */
  107713. world: any;
  107714. /**
  107715. * Name of the plugin
  107716. */
  107717. name: string;
  107718. private _timeStep;
  107719. private _fixedTimeStep;
  107720. private _maxSteps;
  107721. private _tmpQuaternion;
  107722. private _tmpAmmoTransform;
  107723. private _tmpAmmoQuaternion;
  107724. private _tmpAmmoConcreteContactResultCallback;
  107725. private _collisionConfiguration;
  107726. private _dispatcher;
  107727. private _overlappingPairCache;
  107728. private _solver;
  107729. private _tmpAmmoVectorA;
  107730. private _tmpAmmoVectorB;
  107731. private _tmpAmmoVectorC;
  107732. private _tmpContactCallbackResult;
  107733. private static readonly DISABLE_COLLISION_FLAG;
  107734. private static readonly KINEMATIC_FLAG;
  107735. private static readonly DISABLE_DEACTIVATION_FLAG;
  107736. /**
  107737. * Initializes the ammoJS plugin
  107738. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107739. * @param ammoInjection can be used to inject your own ammo reference
  107740. */
  107741. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107742. /**
  107743. * Sets the gravity of the physics world (m/(s^2))
  107744. * @param gravity Gravity to set
  107745. */
  107746. setGravity(gravity: Vector3): void;
  107747. /**
  107748. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107749. * @param timeStep timestep to use in seconds
  107750. */
  107751. setTimeStep(timeStep: number): void;
  107752. /**
  107753. * 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)
  107754. * @param fixedTimeStep fixedTimeStep to use in seconds
  107755. */
  107756. setFixedTimeStep(fixedTimeStep: number): void;
  107757. /**
  107758. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107759. * @param maxSteps the maximum number of steps by the physics engine per frame
  107760. */
  107761. setMaxSteps(maxSteps: number): void;
  107762. /**
  107763. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107764. * @returns the current timestep in seconds
  107765. */
  107766. getTimeStep(): number;
  107767. private _isImpostorInContact;
  107768. private _isImpostorPairInContact;
  107769. private _stepSimulation;
  107770. /**
  107771. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107772. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107773. * After the step the babylon meshes are set to the position of the physics imposters
  107774. * @param delta amount of time to step forward
  107775. * @param impostors array of imposters to update before/after the step
  107776. */
  107777. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107778. private _tmpVector;
  107779. private _tmpMatrix;
  107780. /**
  107781. * Applies an implulse on the imposter
  107782. * @param impostor imposter to apply impulse
  107783. * @param force amount of force to be applied to the imposter
  107784. * @param contactPoint the location to apply the impulse on the imposter
  107785. */
  107786. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107787. /**
  107788. * Applies a force on the imposter
  107789. * @param impostor imposter to apply force
  107790. * @param force amount of force to be applied to the imposter
  107791. * @param contactPoint the location to apply the force on the imposter
  107792. */
  107793. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107794. /**
  107795. * Creates a physics body using the plugin
  107796. * @param impostor the imposter to create the physics body on
  107797. */
  107798. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107799. /**
  107800. * Removes the physics body from the imposter and disposes of the body's memory
  107801. * @param impostor imposter to remove the physics body from
  107802. */
  107803. removePhysicsBody(impostor: PhysicsImpostor): void;
  107804. /**
  107805. * Generates a joint
  107806. * @param impostorJoint the imposter joint to create the joint with
  107807. */
  107808. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107809. /**
  107810. * Removes a joint
  107811. * @param impostorJoint the imposter joint to remove the joint from
  107812. */
  107813. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107814. private _addMeshVerts;
  107815. private _createShape;
  107816. /**
  107817. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  107818. * @param impostor imposter containing the physics body and babylon object
  107819. */
  107820. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107821. /**
  107822. * Sets the babylon object's position/rotation from the physics body's position/rotation
  107823. * @param impostor imposter containing the physics body and babylon object
  107824. * @param newPosition new position
  107825. * @param newRotation new rotation
  107826. */
  107827. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107828. /**
  107829. * If this plugin is supported
  107830. * @returns true if its supported
  107831. */
  107832. isSupported(): boolean;
  107833. /**
  107834. * Sets the linear velocity of the physics body
  107835. * @param impostor imposter to set the velocity on
  107836. * @param velocity velocity to set
  107837. */
  107838. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107839. /**
  107840. * Sets the angular velocity of the physics body
  107841. * @param impostor imposter to set the velocity on
  107842. * @param velocity velocity to set
  107843. */
  107844. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107845. /**
  107846. * gets the linear velocity
  107847. * @param impostor imposter to get linear velocity from
  107848. * @returns linear velocity
  107849. */
  107850. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107851. /**
  107852. * gets the angular velocity
  107853. * @param impostor imposter to get angular velocity from
  107854. * @returns angular velocity
  107855. */
  107856. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107857. /**
  107858. * Sets the mass of physics body
  107859. * @param impostor imposter to set the mass on
  107860. * @param mass mass to set
  107861. */
  107862. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107863. /**
  107864. * Gets the mass of the physics body
  107865. * @param impostor imposter to get the mass from
  107866. * @returns mass
  107867. */
  107868. getBodyMass(impostor: PhysicsImpostor): number;
  107869. /**
  107870. * Gets friction of the impostor
  107871. * @param impostor impostor to get friction from
  107872. * @returns friction value
  107873. */
  107874. getBodyFriction(impostor: PhysicsImpostor): number;
  107875. /**
  107876. * Sets friction of the impostor
  107877. * @param impostor impostor to set friction on
  107878. * @param friction friction value
  107879. */
  107880. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107881. /**
  107882. * Gets restitution of the impostor
  107883. * @param impostor impostor to get restitution from
  107884. * @returns restitution value
  107885. */
  107886. getBodyRestitution(impostor: PhysicsImpostor): number;
  107887. /**
  107888. * Sets resitution of the impostor
  107889. * @param impostor impostor to set resitution on
  107890. * @param restitution resitution value
  107891. */
  107892. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107893. /**
  107894. * Sleeps the physics body and stops it from being active
  107895. * @param impostor impostor to sleep
  107896. */
  107897. sleepBody(impostor: PhysicsImpostor): void;
  107898. /**
  107899. * Activates the physics body
  107900. * @param impostor impostor to activate
  107901. */
  107902. wakeUpBody(impostor: PhysicsImpostor): void;
  107903. /**
  107904. * Updates the distance parameters of the joint
  107905. * @param joint joint to update
  107906. * @param maxDistance maximum distance of the joint
  107907. * @param minDistance minimum distance of the joint
  107908. */
  107909. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107910. /**
  107911. * Sets a motor on the joint
  107912. * @param joint joint to set motor on
  107913. * @param speed speed of the motor
  107914. * @param maxForce maximum force of the motor
  107915. * @param motorIndex index of the motor
  107916. */
  107917. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107918. /**
  107919. * Sets the motors limit
  107920. * @param joint joint to set limit on
  107921. * @param upperLimit upper limit
  107922. * @param lowerLimit lower limit
  107923. */
  107924. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107925. /**
  107926. * Syncs the position and rotation of a mesh with the impostor
  107927. * @param mesh mesh to sync
  107928. * @param impostor impostor to update the mesh with
  107929. */
  107930. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107931. /**
  107932. * Gets the radius of the impostor
  107933. * @param impostor impostor to get radius from
  107934. * @returns the radius
  107935. */
  107936. getRadius(impostor: PhysicsImpostor): number;
  107937. /**
  107938. * Gets the box size of the impostor
  107939. * @param impostor impostor to get box size from
  107940. * @param result the resulting box size
  107941. */
  107942. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107943. /**
  107944. * Disposes of the impostor
  107945. */
  107946. dispose(): void;
  107947. }
  107948. }
  107949. declare module BABYLON {
  107950. /** @hidden */
  107951. export var blackAndWhitePixelShader: {
  107952. name: string;
  107953. shader: string;
  107954. };
  107955. }
  107956. declare module BABYLON {
  107957. /**
  107958. * Post process used to render in black and white
  107959. */
  107960. export class BlackAndWhitePostProcess extends PostProcess {
  107961. /**
  107962. * Linear about to convert he result to black and white (default: 1)
  107963. */
  107964. degree: number;
  107965. /**
  107966. * Creates a black and white post process
  107967. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  107968. * @param name The name of the effect.
  107969. * @param options The required width/height ratio to downsize to before computing the render pass.
  107970. * @param camera The camera to apply the render pass to.
  107971. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107972. * @param engine The engine which the post process will be applied. (default: current engine)
  107973. * @param reusable If the post process can be reused on the same frame. (default: false)
  107974. */
  107975. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107976. }
  107977. }
  107978. declare module BABYLON {
  107979. /**
  107980. * This represents a set of one or more post processes in Babylon.
  107981. * A post process can be used to apply a shader to a texture after it is rendered.
  107982. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107983. */
  107984. export class PostProcessRenderEffect {
  107985. private _postProcesses;
  107986. private _getPostProcesses;
  107987. private _singleInstance;
  107988. private _cameras;
  107989. private _indicesForCamera;
  107990. /**
  107991. * Name of the effect
  107992. * @hidden
  107993. */
  107994. _name: string;
  107995. /**
  107996. * Instantiates a post process render effect.
  107997. * A post process can be used to apply a shader to a texture after it is rendered.
  107998. * @param engine The engine the effect is tied to
  107999. * @param name The name of the effect
  108000. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  108001. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  108002. */
  108003. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  108004. /**
  108005. * Checks if all the post processes in the effect are supported.
  108006. */
  108007. readonly isSupported: boolean;
  108008. /**
  108009. * Updates the current state of the effect
  108010. * @hidden
  108011. */
  108012. _update(): void;
  108013. /**
  108014. * Attaches the effect on cameras
  108015. * @param cameras The camera to attach to.
  108016. * @hidden
  108017. */
  108018. _attachCameras(cameras: Camera): void;
  108019. /**
  108020. * Attaches the effect on cameras
  108021. * @param cameras The camera to attach to.
  108022. * @hidden
  108023. */
  108024. _attachCameras(cameras: Camera[]): void;
  108025. /**
  108026. * Detatches the effect on cameras
  108027. * @param cameras The camera to detatch from.
  108028. * @hidden
  108029. */
  108030. _detachCameras(cameras: Camera): void;
  108031. /**
  108032. * Detatches the effect on cameras
  108033. * @param cameras The camera to detatch from.
  108034. * @hidden
  108035. */
  108036. _detachCameras(cameras: Camera[]): void;
  108037. /**
  108038. * Enables the effect on given cameras
  108039. * @param cameras The camera to enable.
  108040. * @hidden
  108041. */
  108042. _enable(cameras: Camera): void;
  108043. /**
  108044. * Enables the effect on given cameras
  108045. * @param cameras The camera to enable.
  108046. * @hidden
  108047. */
  108048. _enable(cameras: Nullable<Camera[]>): void;
  108049. /**
  108050. * Disables the effect on the given cameras
  108051. * @param cameras The camera to disable.
  108052. * @hidden
  108053. */
  108054. _disable(cameras: Camera): void;
  108055. /**
  108056. * Disables the effect on the given cameras
  108057. * @param cameras The camera to disable.
  108058. * @hidden
  108059. */
  108060. _disable(cameras: Nullable<Camera[]>): void;
  108061. /**
  108062. * Gets a list of the post processes contained in the effect.
  108063. * @param camera The camera to get the post processes on.
  108064. * @returns The list of the post processes in the effect.
  108065. */
  108066. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  108067. }
  108068. }
  108069. declare module BABYLON {
  108070. /** @hidden */
  108071. export var extractHighlightsPixelShader: {
  108072. name: string;
  108073. shader: string;
  108074. };
  108075. }
  108076. declare module BABYLON {
  108077. /**
  108078. * 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.
  108079. */
  108080. export class ExtractHighlightsPostProcess extends PostProcess {
  108081. /**
  108082. * The luminance threshold, pixels below this value will be set to black.
  108083. */
  108084. threshold: number;
  108085. /** @hidden */
  108086. _exposure: number;
  108087. /**
  108088. * Post process which has the input texture to be used when performing highlight extraction
  108089. * @hidden
  108090. */
  108091. _inputPostProcess: Nullable<PostProcess>;
  108092. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108093. }
  108094. }
  108095. declare module BABYLON {
  108096. /** @hidden */
  108097. export var bloomMergePixelShader: {
  108098. name: string;
  108099. shader: string;
  108100. };
  108101. }
  108102. declare module BABYLON {
  108103. /**
  108104. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  108105. */
  108106. export class BloomMergePostProcess extends PostProcess {
  108107. /** Weight of the bloom to be added to the original input. */
  108108. weight: number;
  108109. /**
  108110. * Creates a new instance of @see BloomMergePostProcess
  108111. * @param name The name of the effect.
  108112. * @param originalFromInput Post process which's input will be used for the merge.
  108113. * @param blurred Blurred highlights post process which's output will be used.
  108114. * @param weight Weight of the bloom to be added to the original input.
  108115. * @param options The required width/height ratio to downsize to before computing the render pass.
  108116. * @param camera The camera to apply the render pass to.
  108117. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108118. * @param engine The engine which the post process will be applied. (default: current engine)
  108119. * @param reusable If the post process can be reused on the same frame. (default: false)
  108120. * @param textureType Type of textures used when performing the post process. (default: 0)
  108121. * @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)
  108122. */
  108123. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  108124. /** Weight of the bloom to be added to the original input. */
  108125. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108126. }
  108127. }
  108128. declare module BABYLON {
  108129. /**
  108130. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  108131. */
  108132. export class BloomEffect extends PostProcessRenderEffect {
  108133. private bloomScale;
  108134. /**
  108135. * @hidden Internal
  108136. */
  108137. _effects: Array<PostProcess>;
  108138. /**
  108139. * @hidden Internal
  108140. */
  108141. _downscale: ExtractHighlightsPostProcess;
  108142. private _blurX;
  108143. private _blurY;
  108144. private _merge;
  108145. /**
  108146. * The luminance threshold to find bright areas of the image to bloom.
  108147. */
  108148. threshold: number;
  108149. /**
  108150. * The strength of the bloom.
  108151. */
  108152. weight: number;
  108153. /**
  108154. * Specifies the size of the bloom blur kernel, relative to the final output size
  108155. */
  108156. kernel: number;
  108157. /**
  108158. * Creates a new instance of @see BloomEffect
  108159. * @param scene The scene the effect belongs to.
  108160. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  108161. * @param bloomKernel The size of the kernel to be used when applying the blur.
  108162. * @param bloomWeight The the strength of bloom.
  108163. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  108164. * @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)
  108165. */
  108166. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  108167. /**
  108168. * Disposes each of the internal effects for a given camera.
  108169. * @param camera The camera to dispose the effect on.
  108170. */
  108171. disposeEffects(camera: Camera): void;
  108172. /**
  108173. * @hidden Internal
  108174. */
  108175. _updateEffects(): void;
  108176. /**
  108177. * Internal
  108178. * @returns if all the contained post processes are ready.
  108179. * @hidden
  108180. */
  108181. _isReady(): boolean;
  108182. }
  108183. }
  108184. declare module BABYLON {
  108185. /** @hidden */
  108186. export var chromaticAberrationPixelShader: {
  108187. name: string;
  108188. shader: string;
  108189. };
  108190. }
  108191. declare module BABYLON {
  108192. /**
  108193. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  108194. */
  108195. export class ChromaticAberrationPostProcess extends PostProcess {
  108196. /**
  108197. * The amount of seperation of rgb channels (default: 30)
  108198. */
  108199. aberrationAmount: number;
  108200. /**
  108201. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  108202. */
  108203. radialIntensity: number;
  108204. /**
  108205. * 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))
  108206. */
  108207. direction: Vector2;
  108208. /**
  108209. * 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))
  108210. */
  108211. centerPosition: Vector2;
  108212. /**
  108213. * Creates a new instance ChromaticAberrationPostProcess
  108214. * @param name The name of the effect.
  108215. * @param screenWidth The width of the screen to apply the effect on.
  108216. * @param screenHeight The height of the screen to apply the effect on.
  108217. * @param options The required width/height ratio to downsize to before computing the render pass.
  108218. * @param camera The camera to apply the render pass to.
  108219. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108220. * @param engine The engine which the post process will be applied. (default: current engine)
  108221. * @param reusable If the post process can be reused on the same frame. (default: false)
  108222. * @param textureType Type of textures used when performing the post process. (default: 0)
  108223. * @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)
  108224. */
  108225. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108226. }
  108227. }
  108228. declare module BABYLON {
  108229. /** @hidden */
  108230. export var circleOfConfusionPixelShader: {
  108231. name: string;
  108232. shader: string;
  108233. };
  108234. }
  108235. declare module BABYLON {
  108236. /**
  108237. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  108238. */
  108239. export class CircleOfConfusionPostProcess extends PostProcess {
  108240. /**
  108241. * 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.
  108242. */
  108243. lensSize: number;
  108244. /**
  108245. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  108246. */
  108247. fStop: number;
  108248. /**
  108249. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  108250. */
  108251. focusDistance: number;
  108252. /**
  108253. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  108254. */
  108255. focalLength: number;
  108256. private _depthTexture;
  108257. /**
  108258. * Creates a new instance CircleOfConfusionPostProcess
  108259. * @param name The name of the effect.
  108260. * @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.
  108261. * @param options The required width/height ratio to downsize to before computing the render pass.
  108262. * @param camera The camera to apply the render pass to.
  108263. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108264. * @param engine The engine which the post process will be applied. (default: current engine)
  108265. * @param reusable If the post process can be reused on the same frame. (default: false)
  108266. * @param textureType Type of textures used when performing the post process. (default: 0)
  108267. * @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)
  108268. */
  108269. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108270. /**
  108271. * 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.
  108272. */
  108273. depthTexture: RenderTargetTexture;
  108274. }
  108275. }
  108276. declare module BABYLON {
  108277. /** @hidden */
  108278. export var colorCorrectionPixelShader: {
  108279. name: string;
  108280. shader: string;
  108281. };
  108282. }
  108283. declare module BABYLON {
  108284. /**
  108285. *
  108286. * This post-process allows the modification of rendered colors by using
  108287. * a 'look-up table' (LUT). This effect is also called Color Grading.
  108288. *
  108289. * The object needs to be provided an url to a texture containing the color
  108290. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  108291. * Use an image editing software to tweak the LUT to match your needs.
  108292. *
  108293. * For an example of a color LUT, see here:
  108294. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  108295. * For explanations on color grading, see here:
  108296. * @see http://udn.epicgames.com/Three/ColorGrading.html
  108297. *
  108298. */
  108299. export class ColorCorrectionPostProcess extends PostProcess {
  108300. private _colorTableTexture;
  108301. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108302. }
  108303. }
  108304. declare module BABYLON {
  108305. /** @hidden */
  108306. export var convolutionPixelShader: {
  108307. name: string;
  108308. shader: string;
  108309. };
  108310. }
  108311. declare module BABYLON {
  108312. /**
  108313. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  108314. * input texture to perform effects such as edge detection or sharpening
  108315. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  108316. */
  108317. export class ConvolutionPostProcess extends PostProcess {
  108318. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  108319. kernel: number[];
  108320. /**
  108321. * Creates a new instance ConvolutionPostProcess
  108322. * @param name The name of the effect.
  108323. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  108324. * @param options The required width/height ratio to downsize to before computing the render pass.
  108325. * @param camera The camera to apply the render pass to.
  108326. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108327. * @param engine The engine which the post process will be applied. (default: current engine)
  108328. * @param reusable If the post process can be reused on the same frame. (default: false)
  108329. * @param textureType Type of textures used when performing the post process. (default: 0)
  108330. */
  108331. constructor(name: string,
  108332. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  108333. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108334. /**
  108335. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108336. */
  108337. static EdgeDetect0Kernel: number[];
  108338. /**
  108339. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108340. */
  108341. static EdgeDetect1Kernel: number[];
  108342. /**
  108343. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108344. */
  108345. static EdgeDetect2Kernel: number[];
  108346. /**
  108347. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108348. */
  108349. static SharpenKernel: number[];
  108350. /**
  108351. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108352. */
  108353. static EmbossKernel: number[];
  108354. /**
  108355. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108356. */
  108357. static GaussianKernel: number[];
  108358. }
  108359. }
  108360. declare module BABYLON {
  108361. /**
  108362. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  108363. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  108364. * based on samples that have a large difference in distance than the center pixel.
  108365. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  108366. */
  108367. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  108368. direction: Vector2;
  108369. /**
  108370. * Creates a new instance CircleOfConfusionPostProcess
  108371. * @param name The name of the effect.
  108372. * @param scene The scene the effect belongs to.
  108373. * @param direction The direction the blur should be applied.
  108374. * @param kernel The size of the kernel used to blur.
  108375. * @param options The required width/height ratio to downsize to before computing the render pass.
  108376. * @param camera The camera to apply the render pass to.
  108377. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  108378. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  108379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108380. * @param engine The engine which the post process will be applied. (default: current engine)
  108381. * @param reusable If the post process can be reused on the same frame. (default: false)
  108382. * @param textureType Type of textures used when performing the post process. (default: 0)
  108383. * @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)
  108384. */
  108385. 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);
  108386. }
  108387. }
  108388. declare module BABYLON {
  108389. /** @hidden */
  108390. export var depthOfFieldMergePixelShader: {
  108391. name: string;
  108392. shader: string;
  108393. };
  108394. }
  108395. declare module BABYLON {
  108396. /**
  108397. * Options to be set when merging outputs from the default pipeline.
  108398. */
  108399. export class DepthOfFieldMergePostProcessOptions {
  108400. /**
  108401. * The original image to merge on top of
  108402. */
  108403. originalFromInput: PostProcess;
  108404. /**
  108405. * Parameters to perform the merge of the depth of field effect
  108406. */
  108407. depthOfField?: {
  108408. circleOfConfusion: PostProcess;
  108409. blurSteps: Array<PostProcess>;
  108410. };
  108411. /**
  108412. * Parameters to perform the merge of bloom effect
  108413. */
  108414. bloom?: {
  108415. blurred: PostProcess;
  108416. weight: number;
  108417. };
  108418. }
  108419. /**
  108420. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  108421. */
  108422. export class DepthOfFieldMergePostProcess extends PostProcess {
  108423. private blurSteps;
  108424. /**
  108425. * Creates a new instance of DepthOfFieldMergePostProcess
  108426. * @param name The name of the effect.
  108427. * @param originalFromInput Post process which's input will be used for the merge.
  108428. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  108429. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  108430. * @param options The required width/height ratio to downsize to before computing the render pass.
  108431. * @param camera The camera to apply the render pass to.
  108432. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108433. * @param engine The engine which the post process will be applied. (default: current engine)
  108434. * @param reusable If the post process can be reused on the same frame. (default: false)
  108435. * @param textureType Type of textures used when performing the post process. (default: 0)
  108436. * @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)
  108437. */
  108438. 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);
  108439. /**
  108440. * Updates the effect with the current post process compile time values and recompiles the shader.
  108441. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108442. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108443. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108444. * @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
  108445. * @param onCompiled Called when the shader has been compiled.
  108446. * @param onError Called if there is an error when compiling a shader.
  108447. */
  108448. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108449. }
  108450. }
  108451. declare module BABYLON {
  108452. /**
  108453. * Specifies the level of max blur that should be applied when using the depth of field effect
  108454. */
  108455. export enum DepthOfFieldEffectBlurLevel {
  108456. /**
  108457. * Subtle blur
  108458. */
  108459. Low = 0,
  108460. /**
  108461. * Medium blur
  108462. */
  108463. Medium = 1,
  108464. /**
  108465. * Large blur
  108466. */
  108467. High = 2
  108468. }
  108469. /**
  108470. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  108471. */
  108472. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  108473. private _circleOfConfusion;
  108474. /**
  108475. * @hidden Internal, blurs from high to low
  108476. */
  108477. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  108478. private _depthOfFieldBlurY;
  108479. private _dofMerge;
  108480. /**
  108481. * @hidden Internal post processes in depth of field effect
  108482. */
  108483. _effects: Array<PostProcess>;
  108484. /**
  108485. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  108486. */
  108487. focalLength: number;
  108488. /**
  108489. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  108490. */
  108491. fStop: number;
  108492. /**
  108493. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  108494. */
  108495. focusDistance: number;
  108496. /**
  108497. * 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.
  108498. */
  108499. lensSize: number;
  108500. /**
  108501. * Creates a new instance DepthOfFieldEffect
  108502. * @param scene The scene the effect belongs to.
  108503. * @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.
  108504. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  108505. * @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)
  108506. */
  108507. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  108508. /**
  108509. * 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.
  108510. */
  108511. depthTexture: RenderTargetTexture;
  108512. /**
  108513. * Disposes each of the internal effects for a given camera.
  108514. * @param camera The camera to dispose the effect on.
  108515. */
  108516. disposeEffects(camera: Camera): void;
  108517. /**
  108518. * @hidden Internal
  108519. */
  108520. _updateEffects(): void;
  108521. /**
  108522. * Internal
  108523. * @returns if all the contained post processes are ready.
  108524. * @hidden
  108525. */
  108526. _isReady(): boolean;
  108527. }
  108528. }
  108529. declare module BABYLON {
  108530. /** @hidden */
  108531. export var displayPassPixelShader: {
  108532. name: string;
  108533. shader: string;
  108534. };
  108535. }
  108536. declare module BABYLON {
  108537. /**
  108538. * DisplayPassPostProcess which produces an output the same as it's input
  108539. */
  108540. export class DisplayPassPostProcess extends PostProcess {
  108541. /**
  108542. * Creates the DisplayPassPostProcess
  108543. * @param name The name of the effect.
  108544. * @param options The required width/height ratio to downsize to before computing the render pass.
  108545. * @param camera The camera to apply the render pass to.
  108546. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108547. * @param engine The engine which the post process will be applied. (default: current engine)
  108548. * @param reusable If the post process can be reused on the same frame. (default: false)
  108549. */
  108550. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108551. }
  108552. }
  108553. declare module BABYLON {
  108554. /** @hidden */
  108555. export var filterPixelShader: {
  108556. name: string;
  108557. shader: string;
  108558. };
  108559. }
  108560. declare module BABYLON {
  108561. /**
  108562. * Applies a kernel filter to the image
  108563. */
  108564. export class FilterPostProcess extends PostProcess {
  108565. /** The matrix to be applied to the image */
  108566. kernelMatrix: Matrix;
  108567. /**
  108568. *
  108569. * @param name The name of the effect.
  108570. * @param kernelMatrix The matrix to be applied to the image
  108571. * @param options The required width/height ratio to downsize to before computing the render pass.
  108572. * @param camera The camera to apply the render pass to.
  108573. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108574. * @param engine The engine which the post process will be applied. (default: current engine)
  108575. * @param reusable If the post process can be reused on the same frame. (default: false)
  108576. */
  108577. constructor(name: string,
  108578. /** The matrix to be applied to the image */
  108579. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108580. }
  108581. }
  108582. declare module BABYLON {
  108583. /** @hidden */
  108584. export var fxaaPixelShader: {
  108585. name: string;
  108586. shader: string;
  108587. };
  108588. }
  108589. declare module BABYLON {
  108590. /** @hidden */
  108591. export var fxaaVertexShader: {
  108592. name: string;
  108593. shader: string;
  108594. };
  108595. }
  108596. declare module BABYLON {
  108597. /**
  108598. * Fxaa post process
  108599. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  108600. */
  108601. export class FxaaPostProcess extends PostProcess {
  108602. /** @hidden */
  108603. texelWidth: number;
  108604. /** @hidden */
  108605. texelHeight: number;
  108606. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108607. private _getDefines;
  108608. }
  108609. }
  108610. declare module BABYLON {
  108611. /** @hidden */
  108612. export var grainPixelShader: {
  108613. name: string;
  108614. shader: string;
  108615. };
  108616. }
  108617. declare module BABYLON {
  108618. /**
  108619. * The GrainPostProcess adds noise to the image at mid luminance levels
  108620. */
  108621. export class GrainPostProcess extends PostProcess {
  108622. /**
  108623. * The intensity of the grain added (default: 30)
  108624. */
  108625. intensity: number;
  108626. /**
  108627. * If the grain should be randomized on every frame
  108628. */
  108629. animated: boolean;
  108630. /**
  108631. * Creates a new instance of @see GrainPostProcess
  108632. * @param name The name of the effect.
  108633. * @param options The required width/height ratio to downsize to before computing the render pass.
  108634. * @param camera The camera to apply the render pass to.
  108635. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108636. * @param engine The engine which the post process will be applied. (default: current engine)
  108637. * @param reusable If the post process can be reused on the same frame. (default: false)
  108638. * @param textureType Type of textures used when performing the post process. (default: 0)
  108639. * @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)
  108640. */
  108641. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108642. }
  108643. }
  108644. declare module BABYLON {
  108645. /** @hidden */
  108646. export var highlightsPixelShader: {
  108647. name: string;
  108648. shader: string;
  108649. };
  108650. }
  108651. declare module BABYLON {
  108652. /**
  108653. * Extracts highlights from the image
  108654. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108655. */
  108656. export class HighlightsPostProcess extends PostProcess {
  108657. /**
  108658. * Extracts highlights from the image
  108659. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108660. * @param name The name of the effect.
  108661. * @param options The required width/height ratio to downsize to before computing the render pass.
  108662. * @param camera The camera to apply the render pass to.
  108663. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108664. * @param engine The engine which the post process will be applied. (default: current engine)
  108665. * @param reusable If the post process can be reused on the same frame. (default: false)
  108666. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  108667. */
  108668. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108669. }
  108670. }
  108671. declare module BABYLON {
  108672. /** @hidden */
  108673. export var mrtFragmentDeclaration: {
  108674. name: string;
  108675. shader: string;
  108676. };
  108677. }
  108678. declare module BABYLON {
  108679. /** @hidden */
  108680. export var geometryPixelShader: {
  108681. name: string;
  108682. shader: string;
  108683. };
  108684. }
  108685. declare module BABYLON {
  108686. /** @hidden */
  108687. export var geometryVertexShader: {
  108688. name: string;
  108689. shader: string;
  108690. };
  108691. }
  108692. declare module BABYLON {
  108693. /**
  108694. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  108695. */
  108696. export class GeometryBufferRenderer {
  108697. /**
  108698. * Constant used to retrieve the position texture index in the G-Buffer textures array
  108699. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  108700. */
  108701. static readonly POSITION_TEXTURE_TYPE: number;
  108702. /**
  108703. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  108704. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  108705. */
  108706. static readonly VELOCITY_TEXTURE_TYPE: number;
  108707. /**
  108708. * Dictionary used to store the previous transformation matrices of each rendered mesh
  108709. * in order to compute objects velocities when enableVelocity is set to "true"
  108710. * @hidden
  108711. */
  108712. _previousTransformationMatrices: {
  108713. [index: number]: Matrix;
  108714. };
  108715. private _scene;
  108716. private _multiRenderTarget;
  108717. private _ratio;
  108718. private _enablePosition;
  108719. private _enableVelocity;
  108720. private _positionIndex;
  108721. private _velocityIndex;
  108722. protected _effect: Effect;
  108723. protected _cachedDefines: string;
  108724. /**
  108725. * Set the render list (meshes to be rendered) used in the G buffer.
  108726. */
  108727. renderList: Mesh[];
  108728. /**
  108729. * Gets wether or not G buffer are supported by the running hardware.
  108730. * This requires draw buffer supports
  108731. */
  108732. readonly isSupported: boolean;
  108733. /**
  108734. * Returns the index of the given texture type in the G-Buffer textures array
  108735. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  108736. * @returns the index of the given texture type in the G-Buffer textures array
  108737. */
  108738. getTextureIndex(textureType: number): number;
  108739. /**
  108740. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  108741. */
  108742. /**
  108743. * Sets whether or not objects positions are enabled for the G buffer.
  108744. */
  108745. enablePosition: boolean;
  108746. /**
  108747. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  108748. */
  108749. /**
  108750. * Sets wether or not objects velocities are enabled for the G buffer.
  108751. */
  108752. enableVelocity: boolean;
  108753. /**
  108754. * Gets the scene associated with the buffer.
  108755. */
  108756. readonly scene: Scene;
  108757. /**
  108758. * Gets the ratio used by the buffer during its creation.
  108759. * How big is the buffer related to the main canvas.
  108760. */
  108761. readonly ratio: number;
  108762. /** @hidden */
  108763. static _SceneComponentInitialization: (scene: Scene) => void;
  108764. /**
  108765. * Creates a new G Buffer for the scene
  108766. * @param scene The scene the buffer belongs to
  108767. * @param ratio How big is the buffer related to the main canvas.
  108768. */
  108769. constructor(scene: Scene, ratio?: number);
  108770. /**
  108771. * Checks wether everything is ready to render a submesh to the G buffer.
  108772. * @param subMesh the submesh to check readiness for
  108773. * @param useInstances is the mesh drawn using instance or not
  108774. * @returns true if ready otherwise false
  108775. */
  108776. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108777. /**
  108778. * Gets the current underlying G Buffer.
  108779. * @returns the buffer
  108780. */
  108781. getGBuffer(): MultiRenderTarget;
  108782. /**
  108783. * Gets the number of samples used to render the buffer (anti aliasing).
  108784. */
  108785. /**
  108786. * Sets the number of samples used to render the buffer (anti aliasing).
  108787. */
  108788. samples: number;
  108789. /**
  108790. * Disposes the renderer and frees up associated resources.
  108791. */
  108792. dispose(): void;
  108793. protected _createRenderTargets(): void;
  108794. }
  108795. }
  108796. declare module BABYLON {
  108797. interface Scene {
  108798. /** @hidden (Backing field) */
  108799. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108800. /**
  108801. * Gets or Sets the current geometry buffer associated to the scene.
  108802. */
  108803. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108804. /**
  108805. * Enables a GeometryBufferRender and associates it with the scene
  108806. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  108807. * @returns the GeometryBufferRenderer
  108808. */
  108809. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  108810. /**
  108811. * Disables the GeometryBufferRender associated with the scene
  108812. */
  108813. disableGeometryBufferRenderer(): void;
  108814. }
  108815. /**
  108816. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  108817. * in several rendering techniques.
  108818. */
  108819. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  108820. /**
  108821. * The component name helpful to identify the component in the list of scene components.
  108822. */
  108823. readonly name: string;
  108824. /**
  108825. * The scene the component belongs to.
  108826. */
  108827. scene: Scene;
  108828. /**
  108829. * Creates a new instance of the component for the given scene
  108830. * @param scene Defines the scene to register the component in
  108831. */
  108832. constructor(scene: Scene);
  108833. /**
  108834. * Registers the component in a given scene
  108835. */
  108836. register(): void;
  108837. /**
  108838. * Rebuilds the elements related to this component in case of
  108839. * context lost for instance.
  108840. */
  108841. rebuild(): void;
  108842. /**
  108843. * Disposes the component and the associated ressources
  108844. */
  108845. dispose(): void;
  108846. private _gatherRenderTargets;
  108847. }
  108848. }
  108849. declare module BABYLON {
  108850. /** @hidden */
  108851. export var motionBlurPixelShader: {
  108852. name: string;
  108853. shader: string;
  108854. };
  108855. }
  108856. declare module BABYLON {
  108857. /**
  108858. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  108859. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  108860. * As an example, all you have to do is to create the post-process:
  108861. * var mb = new BABYLON.MotionBlurPostProcess(
  108862. * 'mb', // The name of the effect.
  108863. * scene, // The scene containing the objects to blur according to their velocity.
  108864. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  108865. * camera // The camera to apply the render pass to.
  108866. * );
  108867. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  108868. */
  108869. export class MotionBlurPostProcess extends PostProcess {
  108870. /**
  108871. * Defines how much the image is blurred by the movement. Default value is equal to 1
  108872. */
  108873. motionStrength: number;
  108874. /**
  108875. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  108876. */
  108877. /**
  108878. * Sets the number of iterations to be used for motion blur quality
  108879. */
  108880. motionBlurSamples: number;
  108881. private _motionBlurSamples;
  108882. private _geometryBufferRenderer;
  108883. /**
  108884. * Creates a new instance MotionBlurPostProcess
  108885. * @param name The name of the effect.
  108886. * @param scene The scene containing the objects to blur according to their velocity.
  108887. * @param options The required width/height ratio to downsize to before computing the render pass.
  108888. * @param camera The camera to apply the render pass to.
  108889. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108890. * @param engine The engine which the post process will be applied. (default: current engine)
  108891. * @param reusable If the post process can be reused on the same frame. (default: false)
  108892. * @param textureType Type of textures used when performing the post process. (default: 0)
  108893. * @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)
  108894. */
  108895. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108896. /**
  108897. * Disposes the post process.
  108898. * @param camera The camera to dispose the post process on.
  108899. */
  108900. dispose(camera?: Camera): void;
  108901. }
  108902. }
  108903. declare module BABYLON {
  108904. /** @hidden */
  108905. export var refractionPixelShader: {
  108906. name: string;
  108907. shader: string;
  108908. };
  108909. }
  108910. declare module BABYLON {
  108911. /**
  108912. * Post process which applies a refractin texture
  108913. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  108914. */
  108915. export class RefractionPostProcess extends PostProcess {
  108916. /** the base color of the refraction (used to taint the rendering) */
  108917. color: Color3;
  108918. /** simulated refraction depth */
  108919. depth: number;
  108920. /** the coefficient of the base color (0 to remove base color tainting) */
  108921. colorLevel: number;
  108922. private _refTexture;
  108923. private _ownRefractionTexture;
  108924. /**
  108925. * Gets or sets the refraction texture
  108926. * Please note that you are responsible for disposing the texture if you set it manually
  108927. */
  108928. refractionTexture: Texture;
  108929. /**
  108930. * Initializes the RefractionPostProcess
  108931. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  108932. * @param name The name of the effect.
  108933. * @param refractionTextureUrl Url of the refraction texture to use
  108934. * @param color the base color of the refraction (used to taint the rendering)
  108935. * @param depth simulated refraction depth
  108936. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  108937. * @param camera The camera to apply the render pass to.
  108938. * @param options The required width/height ratio to downsize to before computing the render pass.
  108939. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108940. * @param engine The engine which the post process will be applied. (default: current engine)
  108941. * @param reusable If the post process can be reused on the same frame. (default: false)
  108942. */
  108943. constructor(name: string, refractionTextureUrl: string,
  108944. /** the base color of the refraction (used to taint the rendering) */
  108945. color: Color3,
  108946. /** simulated refraction depth */
  108947. depth: number,
  108948. /** the coefficient of the base color (0 to remove base color tainting) */
  108949. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108950. /**
  108951. * Disposes of the post process
  108952. * @param camera Camera to dispose post process on
  108953. */
  108954. dispose(camera: Camera): void;
  108955. }
  108956. }
  108957. declare module BABYLON {
  108958. /** @hidden */
  108959. export var sharpenPixelShader: {
  108960. name: string;
  108961. shader: string;
  108962. };
  108963. }
  108964. declare module BABYLON {
  108965. /**
  108966. * The SharpenPostProcess applies a sharpen kernel to every pixel
  108967. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  108968. */
  108969. export class SharpenPostProcess extends PostProcess {
  108970. /**
  108971. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  108972. */
  108973. colorAmount: number;
  108974. /**
  108975. * How much sharpness should be applied (default: 0.3)
  108976. */
  108977. edgeAmount: number;
  108978. /**
  108979. * Creates a new instance ConvolutionPostProcess
  108980. * @param name The name of the effect.
  108981. * @param options The required width/height ratio to downsize to before computing the render pass.
  108982. * @param camera The camera to apply the render pass to.
  108983. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108984. * @param engine The engine which the post process will be applied. (default: current engine)
  108985. * @param reusable If the post process can be reused on the same frame. (default: false)
  108986. * @param textureType Type of textures used when performing the post process. (default: 0)
  108987. * @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)
  108988. */
  108989. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108990. }
  108991. }
  108992. declare module BABYLON {
  108993. /**
  108994. * PostProcessRenderPipeline
  108995. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108996. */
  108997. export class PostProcessRenderPipeline {
  108998. private engine;
  108999. private _renderEffects;
  109000. private _renderEffectsForIsolatedPass;
  109001. /**
  109002. * @hidden
  109003. */
  109004. protected _cameras: Camera[];
  109005. /** @hidden */
  109006. _name: string;
  109007. /**
  109008. * Gets pipeline name
  109009. */
  109010. readonly name: string;
  109011. /**
  109012. * Initializes a PostProcessRenderPipeline
  109013. * @param engine engine to add the pipeline to
  109014. * @param name name of the pipeline
  109015. */
  109016. constructor(engine: Engine, name: string);
  109017. /**
  109018. * Gets the class name
  109019. * @returns "PostProcessRenderPipeline"
  109020. */
  109021. getClassName(): string;
  109022. /**
  109023. * If all the render effects in the pipeline are supported
  109024. */
  109025. readonly isSupported: boolean;
  109026. /**
  109027. * Adds an effect to the pipeline
  109028. * @param renderEffect the effect to add
  109029. */
  109030. addEffect(renderEffect: PostProcessRenderEffect): void;
  109031. /** @hidden */
  109032. _rebuild(): void;
  109033. /** @hidden */
  109034. _enableEffect(renderEffectName: string, cameras: Camera): void;
  109035. /** @hidden */
  109036. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  109037. /** @hidden */
  109038. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  109039. /** @hidden */
  109040. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  109041. /** @hidden */
  109042. _attachCameras(cameras: Camera, unique: boolean): void;
  109043. /** @hidden */
  109044. _attachCameras(cameras: Camera[], unique: boolean): void;
  109045. /** @hidden */
  109046. _detachCameras(cameras: Camera): void;
  109047. /** @hidden */
  109048. _detachCameras(cameras: Nullable<Camera[]>): void;
  109049. /** @hidden */
  109050. _update(): void;
  109051. /** @hidden */
  109052. _reset(): void;
  109053. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  109054. /**
  109055. * Disposes of the pipeline
  109056. */
  109057. dispose(): void;
  109058. }
  109059. }
  109060. declare module BABYLON {
  109061. /**
  109062. * PostProcessRenderPipelineManager class
  109063. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109064. */
  109065. export class PostProcessRenderPipelineManager {
  109066. private _renderPipelines;
  109067. /**
  109068. * Initializes a PostProcessRenderPipelineManager
  109069. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109070. */
  109071. constructor();
  109072. /**
  109073. * Gets the list of supported render pipelines
  109074. */
  109075. readonly supportedPipelines: PostProcessRenderPipeline[];
  109076. /**
  109077. * Adds a pipeline to the manager
  109078. * @param renderPipeline The pipeline to add
  109079. */
  109080. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  109081. /**
  109082. * Attaches a camera to the pipeline
  109083. * @param renderPipelineName The name of the pipeline to attach to
  109084. * @param cameras the camera to attach
  109085. * @param unique if the camera can be attached multiple times to the pipeline
  109086. */
  109087. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  109088. /**
  109089. * Detaches a camera from the pipeline
  109090. * @param renderPipelineName The name of the pipeline to detach from
  109091. * @param cameras the camera to detach
  109092. */
  109093. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  109094. /**
  109095. * Enables an effect by name on a pipeline
  109096. * @param renderPipelineName the name of the pipeline to enable the effect in
  109097. * @param renderEffectName the name of the effect to enable
  109098. * @param cameras the cameras that the effect should be enabled on
  109099. */
  109100. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109101. /**
  109102. * Disables an effect by name on a pipeline
  109103. * @param renderPipelineName the name of the pipeline to disable the effect in
  109104. * @param renderEffectName the name of the effect to disable
  109105. * @param cameras the cameras that the effect should be disabled on
  109106. */
  109107. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109108. /**
  109109. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  109110. */
  109111. update(): void;
  109112. /** @hidden */
  109113. _rebuild(): void;
  109114. /**
  109115. * Disposes of the manager and pipelines
  109116. */
  109117. dispose(): void;
  109118. }
  109119. }
  109120. declare module BABYLON {
  109121. interface Scene {
  109122. /** @hidden (Backing field) */
  109123. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109124. /**
  109125. * Gets the postprocess render pipeline manager
  109126. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109127. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  109128. */
  109129. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109130. }
  109131. /**
  109132. * Defines the Render Pipeline scene component responsible to rendering pipelines
  109133. */
  109134. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  109135. /**
  109136. * The component name helpfull to identify the component in the list of scene components.
  109137. */
  109138. readonly name: string;
  109139. /**
  109140. * The scene the component belongs to.
  109141. */
  109142. scene: Scene;
  109143. /**
  109144. * Creates a new instance of the component for the given scene
  109145. * @param scene Defines the scene to register the component in
  109146. */
  109147. constructor(scene: Scene);
  109148. /**
  109149. * Registers the component in a given scene
  109150. */
  109151. register(): void;
  109152. /**
  109153. * Rebuilds the elements related to this component in case of
  109154. * context lost for instance.
  109155. */
  109156. rebuild(): void;
  109157. /**
  109158. * Disposes the component and the associated ressources
  109159. */
  109160. dispose(): void;
  109161. private _gatherRenderTargets;
  109162. }
  109163. }
  109164. declare module BABYLON {
  109165. /**
  109166. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  109167. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  109168. */
  109169. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  109170. private _scene;
  109171. private _camerasToBeAttached;
  109172. /**
  109173. * ID of the sharpen post process,
  109174. */
  109175. private readonly SharpenPostProcessId;
  109176. /**
  109177. * @ignore
  109178. * ID of the image processing post process;
  109179. */
  109180. readonly ImageProcessingPostProcessId: string;
  109181. /**
  109182. * @ignore
  109183. * ID of the Fast Approximate Anti-Aliasing post process;
  109184. */
  109185. readonly FxaaPostProcessId: string;
  109186. /**
  109187. * ID of the chromatic aberration post process,
  109188. */
  109189. private readonly ChromaticAberrationPostProcessId;
  109190. /**
  109191. * ID of the grain post process
  109192. */
  109193. private readonly GrainPostProcessId;
  109194. /**
  109195. * Sharpen post process which will apply a sharpen convolution to enhance edges
  109196. */
  109197. sharpen: SharpenPostProcess;
  109198. private _sharpenEffect;
  109199. private bloom;
  109200. /**
  109201. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  109202. */
  109203. depthOfField: DepthOfFieldEffect;
  109204. /**
  109205. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  109206. */
  109207. fxaa: FxaaPostProcess;
  109208. /**
  109209. * Image post processing pass used to perform operations such as tone mapping or color grading.
  109210. */
  109211. imageProcessing: ImageProcessingPostProcess;
  109212. /**
  109213. * Chromatic aberration post process which will shift rgb colors in the image
  109214. */
  109215. chromaticAberration: ChromaticAberrationPostProcess;
  109216. private _chromaticAberrationEffect;
  109217. /**
  109218. * Grain post process which add noise to the image
  109219. */
  109220. grain: GrainPostProcess;
  109221. private _grainEffect;
  109222. /**
  109223. * Glow post process which adds a glow to emissive areas of the image
  109224. */
  109225. private _glowLayer;
  109226. /**
  109227. * Animations which can be used to tweak settings over a period of time
  109228. */
  109229. animations: Animation[];
  109230. private _imageProcessingConfigurationObserver;
  109231. private _sharpenEnabled;
  109232. private _bloomEnabled;
  109233. private _depthOfFieldEnabled;
  109234. private _depthOfFieldBlurLevel;
  109235. private _fxaaEnabled;
  109236. private _imageProcessingEnabled;
  109237. private _defaultPipelineTextureType;
  109238. private _bloomScale;
  109239. private _chromaticAberrationEnabled;
  109240. private _grainEnabled;
  109241. private _buildAllowed;
  109242. /**
  109243. * Gets active scene
  109244. */
  109245. readonly scene: Scene;
  109246. /**
  109247. * Enable or disable the sharpen process from the pipeline
  109248. */
  109249. sharpenEnabled: boolean;
  109250. private _resizeObserver;
  109251. private _hardwareScaleLevel;
  109252. private _bloomKernel;
  109253. /**
  109254. * Specifies the size of the bloom blur kernel, relative to the final output size
  109255. */
  109256. bloomKernel: number;
  109257. /**
  109258. * Specifies the weight of the bloom in the final rendering
  109259. */
  109260. private _bloomWeight;
  109261. /**
  109262. * Specifies the luma threshold for the area that will be blurred by the bloom
  109263. */
  109264. private _bloomThreshold;
  109265. private _hdr;
  109266. /**
  109267. * The strength of the bloom.
  109268. */
  109269. bloomWeight: number;
  109270. /**
  109271. * The strength of the bloom.
  109272. */
  109273. bloomThreshold: number;
  109274. /**
  109275. * The scale of the bloom, lower value will provide better performance.
  109276. */
  109277. bloomScale: number;
  109278. /**
  109279. * Enable or disable the bloom from the pipeline
  109280. */
  109281. bloomEnabled: boolean;
  109282. private _rebuildBloom;
  109283. /**
  109284. * If the depth of field is enabled.
  109285. */
  109286. depthOfFieldEnabled: boolean;
  109287. /**
  109288. * Blur level of the depth of field effect. (Higher blur will effect performance)
  109289. */
  109290. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  109291. /**
  109292. * If the anti aliasing is enabled.
  109293. */
  109294. fxaaEnabled: boolean;
  109295. private _samples;
  109296. /**
  109297. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  109298. */
  109299. samples: number;
  109300. /**
  109301. * If image processing is enabled.
  109302. */
  109303. imageProcessingEnabled: boolean;
  109304. /**
  109305. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  109306. */
  109307. glowLayerEnabled: boolean;
  109308. /**
  109309. * Enable or disable the chromaticAberration process from the pipeline
  109310. */
  109311. chromaticAberrationEnabled: boolean;
  109312. /**
  109313. * Enable or disable the grain process from the pipeline
  109314. */
  109315. grainEnabled: boolean;
  109316. /**
  109317. * @constructor
  109318. * @param name - The rendering pipeline name (default: "")
  109319. * @param hdr - If high dynamic range textures should be used (default: true)
  109320. * @param scene - The scene linked to this pipeline (default: the last created scene)
  109321. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  109322. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  109323. */
  109324. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  109325. /**
  109326. * Get the class name
  109327. * @returns "DefaultRenderingPipeline"
  109328. */
  109329. getClassName(): string;
  109330. /**
  109331. * Force the compilation of the entire pipeline.
  109332. */
  109333. prepare(): void;
  109334. private _hasCleared;
  109335. private _prevPostProcess;
  109336. private _prevPrevPostProcess;
  109337. private _setAutoClearAndTextureSharing;
  109338. private _depthOfFieldSceneObserver;
  109339. private _buildPipeline;
  109340. private _disposePostProcesses;
  109341. /**
  109342. * Adds a camera to the pipeline
  109343. * @param camera the camera to be added
  109344. */
  109345. addCamera(camera: Camera): void;
  109346. /**
  109347. * Removes a camera from the pipeline
  109348. * @param camera the camera to remove
  109349. */
  109350. removeCamera(camera: Camera): void;
  109351. /**
  109352. * Dispose of the pipeline and stop all post processes
  109353. */
  109354. dispose(): void;
  109355. /**
  109356. * Serialize the rendering pipeline (Used when exporting)
  109357. * @returns the serialized object
  109358. */
  109359. serialize(): any;
  109360. /**
  109361. * Parse the serialized pipeline
  109362. * @param source Source pipeline.
  109363. * @param scene The scene to load the pipeline to.
  109364. * @param rootUrl The URL of the serialized pipeline.
  109365. * @returns An instantiated pipeline from the serialized object.
  109366. */
  109367. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  109368. }
  109369. }
  109370. declare module BABYLON {
  109371. /** @hidden */
  109372. export var lensHighlightsPixelShader: {
  109373. name: string;
  109374. shader: string;
  109375. };
  109376. }
  109377. declare module BABYLON {
  109378. /** @hidden */
  109379. export var depthOfFieldPixelShader: {
  109380. name: string;
  109381. shader: string;
  109382. };
  109383. }
  109384. declare module BABYLON {
  109385. /**
  109386. * BABYLON.JS Chromatic Aberration GLSL Shader
  109387. * Author: Olivier Guyot
  109388. * Separates very slightly R, G and B colors on the edges of the screen
  109389. * Inspired by Francois Tarlier & Martins Upitis
  109390. */
  109391. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  109392. /**
  109393. * @ignore
  109394. * The chromatic aberration PostProcess id in the pipeline
  109395. */
  109396. LensChromaticAberrationEffect: string;
  109397. /**
  109398. * @ignore
  109399. * The highlights enhancing PostProcess id in the pipeline
  109400. */
  109401. HighlightsEnhancingEffect: string;
  109402. /**
  109403. * @ignore
  109404. * The depth-of-field PostProcess id in the pipeline
  109405. */
  109406. LensDepthOfFieldEffect: string;
  109407. private _scene;
  109408. private _depthTexture;
  109409. private _grainTexture;
  109410. private _chromaticAberrationPostProcess;
  109411. private _highlightsPostProcess;
  109412. private _depthOfFieldPostProcess;
  109413. private _edgeBlur;
  109414. private _grainAmount;
  109415. private _chromaticAberration;
  109416. private _distortion;
  109417. private _highlightsGain;
  109418. private _highlightsThreshold;
  109419. private _dofDistance;
  109420. private _dofAperture;
  109421. private _dofDarken;
  109422. private _dofPentagon;
  109423. private _blurNoise;
  109424. /**
  109425. * @constructor
  109426. *
  109427. * Effect parameters are as follow:
  109428. * {
  109429. * chromatic_aberration: number; // from 0 to x (1 for realism)
  109430. * edge_blur: number; // from 0 to x (1 for realism)
  109431. * distortion: number; // from 0 to x (1 for realism)
  109432. * grain_amount: number; // from 0 to 1
  109433. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  109434. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  109435. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  109436. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  109437. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  109438. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  109439. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  109440. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  109441. * }
  109442. * Note: if an effect parameter is unset, effect is disabled
  109443. *
  109444. * @param name The rendering pipeline name
  109445. * @param parameters - An object containing all parameters (see above)
  109446. * @param scene The scene linked to this pipeline
  109447. * @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)
  109448. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109449. */
  109450. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  109451. /**
  109452. * Sets the amount of blur at the edges
  109453. * @param amount blur amount
  109454. */
  109455. setEdgeBlur(amount: number): void;
  109456. /**
  109457. * Sets edge blur to 0
  109458. */
  109459. disableEdgeBlur(): void;
  109460. /**
  109461. * Sets the amout of grain
  109462. * @param amount Amount of grain
  109463. */
  109464. setGrainAmount(amount: number): void;
  109465. /**
  109466. * Set grain amount to 0
  109467. */
  109468. disableGrain(): void;
  109469. /**
  109470. * Sets the chromatic aberration amount
  109471. * @param amount amount of chromatic aberration
  109472. */
  109473. setChromaticAberration(amount: number): void;
  109474. /**
  109475. * Sets chromatic aberration amount to 0
  109476. */
  109477. disableChromaticAberration(): void;
  109478. /**
  109479. * Sets the EdgeDistortion amount
  109480. * @param amount amount of EdgeDistortion
  109481. */
  109482. setEdgeDistortion(amount: number): void;
  109483. /**
  109484. * Sets edge distortion to 0
  109485. */
  109486. disableEdgeDistortion(): void;
  109487. /**
  109488. * Sets the FocusDistance amount
  109489. * @param amount amount of FocusDistance
  109490. */
  109491. setFocusDistance(amount: number): void;
  109492. /**
  109493. * Disables depth of field
  109494. */
  109495. disableDepthOfField(): void;
  109496. /**
  109497. * Sets the Aperture amount
  109498. * @param amount amount of Aperture
  109499. */
  109500. setAperture(amount: number): void;
  109501. /**
  109502. * Sets the DarkenOutOfFocus amount
  109503. * @param amount amount of DarkenOutOfFocus
  109504. */
  109505. setDarkenOutOfFocus(amount: number): void;
  109506. /**
  109507. * Creates a pentagon bokeh effect
  109508. */
  109509. enablePentagonBokeh(): void;
  109510. /**
  109511. * Disables the pentagon bokeh effect
  109512. */
  109513. disablePentagonBokeh(): void;
  109514. /**
  109515. * Enables noise blur
  109516. */
  109517. enableNoiseBlur(): void;
  109518. /**
  109519. * Disables noise blur
  109520. */
  109521. disableNoiseBlur(): void;
  109522. /**
  109523. * Sets the HighlightsGain amount
  109524. * @param amount amount of HighlightsGain
  109525. */
  109526. setHighlightsGain(amount: number): void;
  109527. /**
  109528. * Sets the HighlightsThreshold amount
  109529. * @param amount amount of HighlightsThreshold
  109530. */
  109531. setHighlightsThreshold(amount: number): void;
  109532. /**
  109533. * Disables highlights
  109534. */
  109535. disableHighlights(): void;
  109536. /**
  109537. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  109538. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  109539. */
  109540. dispose(disableDepthRender?: boolean): void;
  109541. private _createChromaticAberrationPostProcess;
  109542. private _createHighlightsPostProcess;
  109543. private _createDepthOfFieldPostProcess;
  109544. private _createGrainTexture;
  109545. }
  109546. }
  109547. declare module BABYLON {
  109548. /** @hidden */
  109549. export var ssao2PixelShader: {
  109550. name: string;
  109551. shader: string;
  109552. };
  109553. }
  109554. declare module BABYLON {
  109555. /** @hidden */
  109556. export var ssaoCombinePixelShader: {
  109557. name: string;
  109558. shader: string;
  109559. };
  109560. }
  109561. declare module BABYLON {
  109562. /**
  109563. * Render pipeline to produce ssao effect
  109564. */
  109565. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  109566. /**
  109567. * @ignore
  109568. * The PassPostProcess id in the pipeline that contains the original scene color
  109569. */
  109570. SSAOOriginalSceneColorEffect: string;
  109571. /**
  109572. * @ignore
  109573. * The SSAO PostProcess id in the pipeline
  109574. */
  109575. SSAORenderEffect: string;
  109576. /**
  109577. * @ignore
  109578. * The horizontal blur PostProcess id in the pipeline
  109579. */
  109580. SSAOBlurHRenderEffect: string;
  109581. /**
  109582. * @ignore
  109583. * The vertical blur PostProcess id in the pipeline
  109584. */
  109585. SSAOBlurVRenderEffect: string;
  109586. /**
  109587. * @ignore
  109588. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  109589. */
  109590. SSAOCombineRenderEffect: string;
  109591. /**
  109592. * The output strength of the SSAO post-process. Default value is 1.0.
  109593. */
  109594. totalStrength: number;
  109595. /**
  109596. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  109597. */
  109598. maxZ: number;
  109599. /**
  109600. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  109601. */
  109602. minZAspect: number;
  109603. private _samples;
  109604. /**
  109605. * Number of samples used for the SSAO calculations. Default value is 8
  109606. */
  109607. samples: number;
  109608. private _textureSamples;
  109609. /**
  109610. * Number of samples to use for antialiasing
  109611. */
  109612. textureSamples: number;
  109613. /**
  109614. * Ratio object used for SSAO ratio and blur ratio
  109615. */
  109616. private _ratio;
  109617. /**
  109618. * Dynamically generated sphere sampler.
  109619. */
  109620. private _sampleSphere;
  109621. /**
  109622. * Blur filter offsets
  109623. */
  109624. private _samplerOffsets;
  109625. private _expensiveBlur;
  109626. /**
  109627. * If bilateral blur should be used
  109628. */
  109629. expensiveBlur: boolean;
  109630. /**
  109631. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  109632. */
  109633. radius: number;
  109634. /**
  109635. * The base color of the SSAO post-process
  109636. * The final result is "base + ssao" between [0, 1]
  109637. */
  109638. base: number;
  109639. /**
  109640. * Support test.
  109641. */
  109642. static readonly IsSupported: boolean;
  109643. private _scene;
  109644. private _depthTexture;
  109645. private _normalTexture;
  109646. private _randomTexture;
  109647. private _originalColorPostProcess;
  109648. private _ssaoPostProcess;
  109649. private _blurHPostProcess;
  109650. private _blurVPostProcess;
  109651. private _ssaoCombinePostProcess;
  109652. private _firstUpdate;
  109653. /**
  109654. * Gets active scene
  109655. */
  109656. readonly scene: Scene;
  109657. /**
  109658. * @constructor
  109659. * @param name The rendering pipeline name
  109660. * @param scene The scene linked to this pipeline
  109661. * @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 }
  109662. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109663. */
  109664. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  109665. /**
  109666. * Get the class name
  109667. * @returns "SSAO2RenderingPipeline"
  109668. */
  109669. getClassName(): string;
  109670. /**
  109671. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  109672. */
  109673. dispose(disableGeometryBufferRenderer?: boolean): void;
  109674. private _createBlurPostProcess;
  109675. /** @hidden */
  109676. _rebuild(): void;
  109677. private _bits;
  109678. private _radicalInverse_VdC;
  109679. private _hammersley;
  109680. private _hemisphereSample_uniform;
  109681. private _generateHemisphere;
  109682. private _createSSAOPostProcess;
  109683. private _createSSAOCombinePostProcess;
  109684. private _createRandomTexture;
  109685. /**
  109686. * Serialize the rendering pipeline (Used when exporting)
  109687. * @returns the serialized object
  109688. */
  109689. serialize(): any;
  109690. /**
  109691. * Parse the serialized pipeline
  109692. * @param source Source pipeline.
  109693. * @param scene The scene to load the pipeline to.
  109694. * @param rootUrl The URL of the serialized pipeline.
  109695. * @returns An instantiated pipeline from the serialized object.
  109696. */
  109697. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  109698. }
  109699. }
  109700. declare module BABYLON {
  109701. /** @hidden */
  109702. export var ssaoPixelShader: {
  109703. name: string;
  109704. shader: string;
  109705. };
  109706. }
  109707. declare module BABYLON {
  109708. /**
  109709. * Render pipeline to produce ssao effect
  109710. */
  109711. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  109712. /**
  109713. * @ignore
  109714. * The PassPostProcess id in the pipeline that contains the original scene color
  109715. */
  109716. SSAOOriginalSceneColorEffect: string;
  109717. /**
  109718. * @ignore
  109719. * The SSAO PostProcess id in the pipeline
  109720. */
  109721. SSAORenderEffect: string;
  109722. /**
  109723. * @ignore
  109724. * The horizontal blur PostProcess id in the pipeline
  109725. */
  109726. SSAOBlurHRenderEffect: string;
  109727. /**
  109728. * @ignore
  109729. * The vertical blur PostProcess id in the pipeline
  109730. */
  109731. SSAOBlurVRenderEffect: string;
  109732. /**
  109733. * @ignore
  109734. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  109735. */
  109736. SSAOCombineRenderEffect: string;
  109737. /**
  109738. * The output strength of the SSAO post-process. Default value is 1.0.
  109739. */
  109740. totalStrength: number;
  109741. /**
  109742. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  109743. */
  109744. radius: number;
  109745. /**
  109746. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  109747. * Must not be equal to fallOff and superior to fallOff.
  109748. * Default value is 0.0075
  109749. */
  109750. area: number;
  109751. /**
  109752. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  109753. * Must not be equal to area and inferior to area.
  109754. * Default value is 0.000001
  109755. */
  109756. fallOff: number;
  109757. /**
  109758. * The base color of the SSAO post-process
  109759. * The final result is "base + ssao" between [0, 1]
  109760. */
  109761. base: number;
  109762. private _scene;
  109763. private _depthTexture;
  109764. private _randomTexture;
  109765. private _originalColorPostProcess;
  109766. private _ssaoPostProcess;
  109767. private _blurHPostProcess;
  109768. private _blurVPostProcess;
  109769. private _ssaoCombinePostProcess;
  109770. private _firstUpdate;
  109771. /**
  109772. * Gets active scene
  109773. */
  109774. readonly scene: Scene;
  109775. /**
  109776. * @constructor
  109777. * @param name - The rendering pipeline name
  109778. * @param scene - The scene linked to this pipeline
  109779. * @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 }
  109780. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  109781. */
  109782. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  109783. /**
  109784. * Get the class name
  109785. * @returns "SSAORenderingPipeline"
  109786. */
  109787. getClassName(): string;
  109788. /**
  109789. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  109790. */
  109791. dispose(disableDepthRender?: boolean): void;
  109792. private _createBlurPostProcess;
  109793. /** @hidden */
  109794. _rebuild(): void;
  109795. private _createSSAOPostProcess;
  109796. private _createSSAOCombinePostProcess;
  109797. private _createRandomTexture;
  109798. }
  109799. }
  109800. declare module BABYLON {
  109801. /** @hidden */
  109802. export var standardPixelShader: {
  109803. name: string;
  109804. shader: string;
  109805. };
  109806. }
  109807. declare module BABYLON {
  109808. /**
  109809. * Standard rendering pipeline
  109810. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  109811. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  109812. */
  109813. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  109814. /**
  109815. * Public members
  109816. */
  109817. /**
  109818. * Post-process which contains the original scene color before the pipeline applies all the effects
  109819. */
  109820. originalPostProcess: Nullable<PostProcess>;
  109821. /**
  109822. * Post-process used to down scale an image x4
  109823. */
  109824. downSampleX4PostProcess: Nullable<PostProcess>;
  109825. /**
  109826. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  109827. */
  109828. brightPassPostProcess: Nullable<PostProcess>;
  109829. /**
  109830. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  109831. */
  109832. blurHPostProcesses: PostProcess[];
  109833. /**
  109834. * Post-process array storing all the vertical blur post-processes used by the pipeline
  109835. */
  109836. blurVPostProcesses: PostProcess[];
  109837. /**
  109838. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  109839. */
  109840. textureAdderPostProcess: Nullable<PostProcess>;
  109841. /**
  109842. * Post-process used to create volumetric lighting effect
  109843. */
  109844. volumetricLightPostProcess: Nullable<PostProcess>;
  109845. /**
  109846. * Post-process used to smooth the previous volumetric light post-process on the X axis
  109847. */
  109848. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  109849. /**
  109850. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  109851. */
  109852. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  109853. /**
  109854. * Post-process used to merge the volumetric light effect and the real scene color
  109855. */
  109856. volumetricLightMergePostProces: Nullable<PostProcess>;
  109857. /**
  109858. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  109859. */
  109860. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  109861. /**
  109862. * Base post-process used to calculate the average luminance of the final image for HDR
  109863. */
  109864. luminancePostProcess: Nullable<PostProcess>;
  109865. /**
  109866. * Post-processes used to create down sample post-processes in order to get
  109867. * the average luminance of the final image for HDR
  109868. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  109869. */
  109870. luminanceDownSamplePostProcesses: PostProcess[];
  109871. /**
  109872. * Post-process used to create a HDR effect (light adaptation)
  109873. */
  109874. hdrPostProcess: Nullable<PostProcess>;
  109875. /**
  109876. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  109877. */
  109878. textureAdderFinalPostProcess: Nullable<PostProcess>;
  109879. /**
  109880. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  109881. */
  109882. lensFlareFinalPostProcess: Nullable<PostProcess>;
  109883. /**
  109884. * Post-process used to merge the final HDR post-process and the real scene color
  109885. */
  109886. hdrFinalPostProcess: Nullable<PostProcess>;
  109887. /**
  109888. * Post-process used to create a lens flare effect
  109889. */
  109890. lensFlarePostProcess: Nullable<PostProcess>;
  109891. /**
  109892. * Post-process that merges the result of the lens flare post-process and the real scene color
  109893. */
  109894. lensFlareComposePostProcess: Nullable<PostProcess>;
  109895. /**
  109896. * Post-process used to create a motion blur effect
  109897. */
  109898. motionBlurPostProcess: Nullable<PostProcess>;
  109899. /**
  109900. * Post-process used to create a depth of field effect
  109901. */
  109902. depthOfFieldPostProcess: Nullable<PostProcess>;
  109903. /**
  109904. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  109905. */
  109906. fxaaPostProcess: Nullable<FxaaPostProcess>;
  109907. /**
  109908. * Represents the brightness threshold in order to configure the illuminated surfaces
  109909. */
  109910. brightThreshold: number;
  109911. /**
  109912. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  109913. */
  109914. blurWidth: number;
  109915. /**
  109916. * Sets if the blur for highlighted surfaces must be only horizontal
  109917. */
  109918. horizontalBlur: boolean;
  109919. /**
  109920. * Sets the overall exposure used by the pipeline
  109921. */
  109922. exposure: number;
  109923. /**
  109924. * Texture used typically to simulate "dirty" on camera lens
  109925. */
  109926. lensTexture: Nullable<Texture>;
  109927. /**
  109928. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  109929. */
  109930. volumetricLightCoefficient: number;
  109931. /**
  109932. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  109933. */
  109934. volumetricLightPower: number;
  109935. /**
  109936. * Used the set the blur intensity to smooth the volumetric lights
  109937. */
  109938. volumetricLightBlurScale: number;
  109939. /**
  109940. * Light (spot or directional) used to generate the volumetric lights rays
  109941. * The source light must have a shadow generate so the pipeline can get its
  109942. * depth map
  109943. */
  109944. sourceLight: Nullable<SpotLight | DirectionalLight>;
  109945. /**
  109946. * For eye adaptation, represents the minimum luminance the eye can see
  109947. */
  109948. hdrMinimumLuminance: number;
  109949. /**
  109950. * For eye adaptation, represents the decrease luminance speed
  109951. */
  109952. hdrDecreaseRate: number;
  109953. /**
  109954. * For eye adaptation, represents the increase luminance speed
  109955. */
  109956. hdrIncreaseRate: number;
  109957. /**
  109958. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  109959. */
  109960. lensColorTexture: Nullable<Texture>;
  109961. /**
  109962. * The overall strengh for the lens flare effect
  109963. */
  109964. lensFlareStrength: number;
  109965. /**
  109966. * Dispersion coefficient for lens flare ghosts
  109967. */
  109968. lensFlareGhostDispersal: number;
  109969. /**
  109970. * Main lens flare halo width
  109971. */
  109972. lensFlareHaloWidth: number;
  109973. /**
  109974. * Based on the lens distortion effect, defines how much the lens flare result
  109975. * is distorted
  109976. */
  109977. lensFlareDistortionStrength: number;
  109978. /**
  109979. * Lens star texture must be used to simulate rays on the flares and is available
  109980. * in the documentation
  109981. */
  109982. lensStarTexture: Nullable<Texture>;
  109983. /**
  109984. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  109985. * flare effect by taking account of the dirt texture
  109986. */
  109987. lensFlareDirtTexture: Nullable<Texture>;
  109988. /**
  109989. * Represents the focal length for the depth of field effect
  109990. */
  109991. depthOfFieldDistance: number;
  109992. /**
  109993. * Represents the blur intensity for the blurred part of the depth of field effect
  109994. */
  109995. depthOfFieldBlurWidth: number;
  109996. /**
  109997. * For motion blur, defines how much the image is blurred by the movement
  109998. */
  109999. motionStrength: number;
  110000. /**
  110001. * List of animations for the pipeline (IAnimatable implementation)
  110002. */
  110003. animations: Animation[];
  110004. /**
  110005. * Private members
  110006. */
  110007. private _scene;
  110008. private _currentDepthOfFieldSource;
  110009. private _basePostProcess;
  110010. private _hdrCurrentLuminance;
  110011. private _floatTextureType;
  110012. private _ratio;
  110013. private _bloomEnabled;
  110014. private _depthOfFieldEnabled;
  110015. private _vlsEnabled;
  110016. private _lensFlareEnabled;
  110017. private _hdrEnabled;
  110018. private _motionBlurEnabled;
  110019. private _fxaaEnabled;
  110020. private _motionBlurSamples;
  110021. private _volumetricLightStepsCount;
  110022. private _samples;
  110023. /**
  110024. * @ignore
  110025. * Specifies if the bloom pipeline is enabled
  110026. */
  110027. BloomEnabled: boolean;
  110028. /**
  110029. * @ignore
  110030. * Specifies if the depth of field pipeline is enabed
  110031. */
  110032. DepthOfFieldEnabled: boolean;
  110033. /**
  110034. * @ignore
  110035. * Specifies if the lens flare pipeline is enabed
  110036. */
  110037. LensFlareEnabled: boolean;
  110038. /**
  110039. * @ignore
  110040. * Specifies if the HDR pipeline is enabled
  110041. */
  110042. HDREnabled: boolean;
  110043. /**
  110044. * @ignore
  110045. * Specifies if the volumetric lights scattering effect is enabled
  110046. */
  110047. VLSEnabled: boolean;
  110048. /**
  110049. * @ignore
  110050. * Specifies if the motion blur effect is enabled
  110051. */
  110052. MotionBlurEnabled: boolean;
  110053. /**
  110054. * Specifies if anti-aliasing is enabled
  110055. */
  110056. fxaaEnabled: boolean;
  110057. /**
  110058. * Specifies the number of steps used to calculate the volumetric lights
  110059. * Typically in interval [50, 200]
  110060. */
  110061. volumetricLightStepsCount: number;
  110062. /**
  110063. * Specifies the number of samples used for the motion blur effect
  110064. * Typically in interval [16, 64]
  110065. */
  110066. motionBlurSamples: number;
  110067. /**
  110068. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  110069. */
  110070. samples: number;
  110071. /**
  110072. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  110073. * @constructor
  110074. * @param name The rendering pipeline name
  110075. * @param scene The scene linked to this pipeline
  110076. * @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)
  110077. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  110078. * @param cameras The array of cameras that the rendering pipeline will be attached to
  110079. */
  110080. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  110081. private _buildPipeline;
  110082. private _createDownSampleX4PostProcess;
  110083. private _createBrightPassPostProcess;
  110084. private _createBlurPostProcesses;
  110085. private _createTextureAdderPostProcess;
  110086. private _createVolumetricLightPostProcess;
  110087. private _createLuminancePostProcesses;
  110088. private _createHdrPostProcess;
  110089. private _createLensFlarePostProcess;
  110090. private _createDepthOfFieldPostProcess;
  110091. private _createMotionBlurPostProcess;
  110092. private _getDepthTexture;
  110093. private _disposePostProcesses;
  110094. /**
  110095. * Dispose of the pipeline and stop all post processes
  110096. */
  110097. dispose(): void;
  110098. /**
  110099. * Serialize the rendering pipeline (Used when exporting)
  110100. * @returns the serialized object
  110101. */
  110102. serialize(): any;
  110103. /**
  110104. * Parse the serialized pipeline
  110105. * @param source Source pipeline.
  110106. * @param scene The scene to load the pipeline to.
  110107. * @param rootUrl The URL of the serialized pipeline.
  110108. * @returns An instantiated pipeline from the serialized object.
  110109. */
  110110. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  110111. /**
  110112. * Luminance steps
  110113. */
  110114. static LuminanceSteps: number;
  110115. }
  110116. }
  110117. declare module BABYLON {
  110118. /** @hidden */
  110119. export var tonemapPixelShader: {
  110120. name: string;
  110121. shader: string;
  110122. };
  110123. }
  110124. declare module BABYLON {
  110125. /** Defines operator used for tonemapping */
  110126. export enum TonemappingOperator {
  110127. /** Hable */
  110128. Hable = 0,
  110129. /** Reinhard */
  110130. Reinhard = 1,
  110131. /** HejiDawson */
  110132. HejiDawson = 2,
  110133. /** Photographic */
  110134. Photographic = 3
  110135. }
  110136. /**
  110137. * Defines a post process to apply tone mapping
  110138. */
  110139. export class TonemapPostProcess extends PostProcess {
  110140. private _operator;
  110141. /** Defines the required exposure adjustement */
  110142. exposureAdjustment: number;
  110143. /**
  110144. * Creates a new TonemapPostProcess
  110145. * @param name defines the name of the postprocess
  110146. * @param _operator defines the operator to use
  110147. * @param exposureAdjustment defines the required exposure adjustement
  110148. * @param camera defines the camera to use (can be null)
  110149. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  110150. * @param engine defines the hosting engine (can be ignore if camera is set)
  110151. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  110152. */
  110153. constructor(name: string, _operator: TonemappingOperator,
  110154. /** Defines the required exposure adjustement */
  110155. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  110156. }
  110157. }
  110158. declare module BABYLON {
  110159. /** @hidden */
  110160. export var depthVertexShader: {
  110161. name: string;
  110162. shader: string;
  110163. };
  110164. }
  110165. declare module BABYLON {
  110166. /** @hidden */
  110167. export var volumetricLightScatteringPixelShader: {
  110168. name: string;
  110169. shader: string;
  110170. };
  110171. }
  110172. declare module BABYLON {
  110173. /** @hidden */
  110174. export var volumetricLightScatteringPassPixelShader: {
  110175. name: string;
  110176. shader: string;
  110177. };
  110178. }
  110179. declare module BABYLON {
  110180. /**
  110181. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  110182. */
  110183. export class VolumetricLightScatteringPostProcess extends PostProcess {
  110184. private _volumetricLightScatteringPass;
  110185. private _volumetricLightScatteringRTT;
  110186. private _viewPort;
  110187. private _screenCoordinates;
  110188. private _cachedDefines;
  110189. /**
  110190. * If not undefined, the mesh position is computed from the attached node position
  110191. */
  110192. attachedNode: {
  110193. position: Vector3;
  110194. };
  110195. /**
  110196. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  110197. */
  110198. customMeshPosition: Vector3;
  110199. /**
  110200. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  110201. */
  110202. useCustomMeshPosition: boolean;
  110203. /**
  110204. * If the post-process should inverse the light scattering direction
  110205. */
  110206. invert: boolean;
  110207. /**
  110208. * The internal mesh used by the post-process
  110209. */
  110210. mesh: Mesh;
  110211. /**
  110212. * @hidden
  110213. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  110214. */
  110215. useDiffuseColor: boolean;
  110216. /**
  110217. * Array containing the excluded meshes not rendered in the internal pass
  110218. */
  110219. excludedMeshes: AbstractMesh[];
  110220. /**
  110221. * Controls the overall intensity of the post-process
  110222. */
  110223. exposure: number;
  110224. /**
  110225. * Dissipates each sample's contribution in range [0, 1]
  110226. */
  110227. decay: number;
  110228. /**
  110229. * Controls the overall intensity of each sample
  110230. */
  110231. weight: number;
  110232. /**
  110233. * Controls the density of each sample
  110234. */
  110235. density: number;
  110236. /**
  110237. * @constructor
  110238. * @param name The post-process name
  110239. * @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)
  110240. * @param camera The camera that the post-process will be attached to
  110241. * @param mesh The mesh used to create the light scattering
  110242. * @param samples The post-process quality, default 100
  110243. * @param samplingModeThe post-process filtering mode
  110244. * @param engine The babylon engine
  110245. * @param reusable If the post-process is reusable
  110246. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  110247. */
  110248. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  110249. /**
  110250. * Returns the string "VolumetricLightScatteringPostProcess"
  110251. * @returns "VolumetricLightScatteringPostProcess"
  110252. */
  110253. getClassName(): string;
  110254. private _isReady;
  110255. /**
  110256. * Sets the new light position for light scattering effect
  110257. * @param position The new custom light position
  110258. */
  110259. setCustomMeshPosition(position: Vector3): void;
  110260. /**
  110261. * Returns the light position for light scattering effect
  110262. * @return Vector3 The custom light position
  110263. */
  110264. getCustomMeshPosition(): Vector3;
  110265. /**
  110266. * Disposes the internal assets and detaches the post-process from the camera
  110267. */
  110268. dispose(camera: Camera): void;
  110269. /**
  110270. * Returns the render target texture used by the post-process
  110271. * @return the render target texture used by the post-process
  110272. */
  110273. getPass(): RenderTargetTexture;
  110274. private _meshExcluded;
  110275. private _createPass;
  110276. private _updateMeshScreenCoordinates;
  110277. /**
  110278. * Creates a default mesh for the Volumeric Light Scattering post-process
  110279. * @param name The mesh name
  110280. * @param scene The scene where to create the mesh
  110281. * @return the default mesh
  110282. */
  110283. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  110284. }
  110285. }
  110286. declare module BABYLON {
  110287. interface Scene {
  110288. /** @hidden (Backing field) */
  110289. _boundingBoxRenderer: BoundingBoxRenderer;
  110290. /** @hidden (Backing field) */
  110291. _forceShowBoundingBoxes: boolean;
  110292. /**
  110293. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  110294. */
  110295. forceShowBoundingBoxes: boolean;
  110296. /**
  110297. * Gets the bounding box renderer associated with the scene
  110298. * @returns a BoundingBoxRenderer
  110299. */
  110300. getBoundingBoxRenderer(): BoundingBoxRenderer;
  110301. }
  110302. interface AbstractMesh {
  110303. /** @hidden (Backing field) */
  110304. _showBoundingBox: boolean;
  110305. /**
  110306. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  110307. */
  110308. showBoundingBox: boolean;
  110309. }
  110310. /**
  110311. * Component responsible of rendering the bounding box of the meshes in a scene.
  110312. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  110313. */
  110314. export class BoundingBoxRenderer implements ISceneComponent {
  110315. /**
  110316. * The component name helpfull to identify the component in the list of scene components.
  110317. */
  110318. readonly name: string;
  110319. /**
  110320. * The scene the component belongs to.
  110321. */
  110322. scene: Scene;
  110323. /**
  110324. * Color of the bounding box lines placed in front of an object
  110325. */
  110326. frontColor: Color3;
  110327. /**
  110328. * Color of the bounding box lines placed behind an object
  110329. */
  110330. backColor: Color3;
  110331. /**
  110332. * Defines if the renderer should show the back lines or not
  110333. */
  110334. showBackLines: boolean;
  110335. /**
  110336. * @hidden
  110337. */
  110338. renderList: SmartArray<BoundingBox>;
  110339. private _colorShader;
  110340. private _vertexBuffers;
  110341. private _indexBuffer;
  110342. /**
  110343. * Instantiates a new bounding box renderer in a scene.
  110344. * @param scene the scene the renderer renders in
  110345. */
  110346. constructor(scene: Scene);
  110347. /**
  110348. * Registers the component in a given scene
  110349. */
  110350. register(): void;
  110351. private _evaluateSubMesh;
  110352. private _activeMesh;
  110353. private _prepareRessources;
  110354. private _createIndexBuffer;
  110355. /**
  110356. * Rebuilds the elements related to this component in case of
  110357. * context lost for instance.
  110358. */
  110359. rebuild(): void;
  110360. /**
  110361. * @hidden
  110362. */
  110363. reset(): void;
  110364. /**
  110365. * Render the bounding boxes of a specific rendering group
  110366. * @param renderingGroupId defines the rendering group to render
  110367. */
  110368. render(renderingGroupId: number): void;
  110369. /**
  110370. * In case of occlusion queries, we can render the occlusion bounding box through this method
  110371. * @param mesh Define the mesh to render the occlusion bounding box for
  110372. */
  110373. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  110374. /**
  110375. * Dispose and release the resources attached to this renderer.
  110376. */
  110377. dispose(): void;
  110378. }
  110379. }
  110380. declare module BABYLON {
  110381. /** @hidden */
  110382. export var depthPixelShader: {
  110383. name: string;
  110384. shader: string;
  110385. };
  110386. }
  110387. declare module BABYLON {
  110388. /**
  110389. * This represents a depth renderer in Babylon.
  110390. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  110391. */
  110392. export class DepthRenderer {
  110393. private _scene;
  110394. private _depthMap;
  110395. private _effect;
  110396. private _cachedDefines;
  110397. private _camera;
  110398. /**
  110399. * Specifiess that the depth renderer will only be used within
  110400. * the camera it is created for.
  110401. * This can help forcing its rendering during the camera processing.
  110402. */
  110403. useOnlyInActiveCamera: boolean;
  110404. /** @hidden */
  110405. static _SceneComponentInitialization: (scene: Scene) => void;
  110406. /**
  110407. * Instantiates a depth renderer
  110408. * @param scene The scene the renderer belongs to
  110409. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  110410. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  110411. */
  110412. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  110413. /**
  110414. * Creates the depth rendering effect and checks if the effect is ready.
  110415. * @param subMesh The submesh to be used to render the depth map of
  110416. * @param useInstances If multiple world instances should be used
  110417. * @returns if the depth renderer is ready to render the depth map
  110418. */
  110419. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110420. /**
  110421. * Gets the texture which the depth map will be written to.
  110422. * @returns The depth map texture
  110423. */
  110424. getDepthMap(): RenderTargetTexture;
  110425. /**
  110426. * Disposes of the depth renderer.
  110427. */
  110428. dispose(): void;
  110429. }
  110430. }
  110431. declare module BABYLON {
  110432. interface Scene {
  110433. /** @hidden (Backing field) */
  110434. _depthRenderer: {
  110435. [id: string]: DepthRenderer;
  110436. };
  110437. /**
  110438. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  110439. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  110440. * @returns the created depth renderer
  110441. */
  110442. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  110443. /**
  110444. * Disables a depth renderer for a given camera
  110445. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  110446. */
  110447. disableDepthRenderer(camera?: Nullable<Camera>): void;
  110448. }
  110449. /**
  110450. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  110451. * in several rendering techniques.
  110452. */
  110453. export class DepthRendererSceneComponent implements ISceneComponent {
  110454. /**
  110455. * The component name helpfull to identify the component in the list of scene components.
  110456. */
  110457. readonly name: string;
  110458. /**
  110459. * The scene the component belongs to.
  110460. */
  110461. scene: Scene;
  110462. /**
  110463. * Creates a new instance of the component for the given scene
  110464. * @param scene Defines the scene to register the component in
  110465. */
  110466. constructor(scene: Scene);
  110467. /**
  110468. * Registers the component in a given scene
  110469. */
  110470. register(): void;
  110471. /**
  110472. * Rebuilds the elements related to this component in case of
  110473. * context lost for instance.
  110474. */
  110475. rebuild(): void;
  110476. /**
  110477. * Disposes the component and the associated ressources
  110478. */
  110479. dispose(): void;
  110480. private _gatherRenderTargets;
  110481. private _gatherActiveCameraRenderTargets;
  110482. }
  110483. }
  110484. declare module BABYLON {
  110485. /** @hidden */
  110486. export var outlinePixelShader: {
  110487. name: string;
  110488. shader: string;
  110489. };
  110490. }
  110491. declare module BABYLON {
  110492. /** @hidden */
  110493. export var outlineVertexShader: {
  110494. name: string;
  110495. shader: string;
  110496. };
  110497. }
  110498. declare module BABYLON {
  110499. interface Scene {
  110500. /** @hidden */
  110501. _outlineRenderer: OutlineRenderer;
  110502. /**
  110503. * Gets the outline renderer associated with the scene
  110504. * @returns a OutlineRenderer
  110505. */
  110506. getOutlineRenderer(): OutlineRenderer;
  110507. }
  110508. interface AbstractMesh {
  110509. /** @hidden (Backing field) */
  110510. _renderOutline: boolean;
  110511. /**
  110512. * Gets or sets a boolean indicating if the outline must be rendered as well
  110513. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  110514. */
  110515. renderOutline: boolean;
  110516. /** @hidden (Backing field) */
  110517. _renderOverlay: boolean;
  110518. /**
  110519. * Gets or sets a boolean indicating if the overlay must be rendered as well
  110520. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  110521. */
  110522. renderOverlay: boolean;
  110523. }
  110524. /**
  110525. * This class is responsible to draw bothe outline/overlay of meshes.
  110526. * It should not be used directly but through the available method on mesh.
  110527. */
  110528. export class OutlineRenderer implements ISceneComponent {
  110529. /**
  110530. * The name of the component. Each component must have a unique name.
  110531. */
  110532. name: string;
  110533. /**
  110534. * The scene the component belongs to.
  110535. */
  110536. scene: Scene;
  110537. /**
  110538. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  110539. */
  110540. zOffset: number;
  110541. private _engine;
  110542. private _effect;
  110543. private _cachedDefines;
  110544. private _savedDepthWrite;
  110545. /**
  110546. * Instantiates a new outline renderer. (There could be only one per scene).
  110547. * @param scene Defines the scene it belongs to
  110548. */
  110549. constructor(scene: Scene);
  110550. /**
  110551. * Register the component to one instance of a scene.
  110552. */
  110553. register(): void;
  110554. /**
  110555. * Rebuilds the elements related to this component in case of
  110556. * context lost for instance.
  110557. */
  110558. rebuild(): void;
  110559. /**
  110560. * Disposes the component and the associated ressources.
  110561. */
  110562. dispose(): void;
  110563. /**
  110564. * Renders the outline in the canvas.
  110565. * @param subMesh Defines the sumesh to render
  110566. * @param batch Defines the batch of meshes in case of instances
  110567. * @param useOverlay Defines if the rendering is for the overlay or the outline
  110568. */
  110569. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  110570. /**
  110571. * Returns whether or not the outline renderer is ready for a given submesh.
  110572. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  110573. * @param subMesh Defines the submesh to check readyness for
  110574. * @param useInstances Defines wheter wee are trying to render instances or not
  110575. * @returns true if ready otherwise false
  110576. */
  110577. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110578. private _beforeRenderingMesh;
  110579. private _afterRenderingMesh;
  110580. }
  110581. }
  110582. declare module BABYLON {
  110583. /**
  110584. * Defines the list of states available for a task inside a AssetsManager
  110585. */
  110586. export enum AssetTaskState {
  110587. /**
  110588. * Initialization
  110589. */
  110590. INIT = 0,
  110591. /**
  110592. * Running
  110593. */
  110594. RUNNING = 1,
  110595. /**
  110596. * Done
  110597. */
  110598. DONE = 2,
  110599. /**
  110600. * Error
  110601. */
  110602. ERROR = 3
  110603. }
  110604. /**
  110605. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  110606. */
  110607. export abstract class AbstractAssetTask {
  110608. /**
  110609. * Task name
  110610. */ name: string;
  110611. /**
  110612. * Callback called when the task is successful
  110613. */
  110614. onSuccess: (task: any) => void;
  110615. /**
  110616. * Callback called when the task is not successful
  110617. */
  110618. onError: (task: any, message?: string, exception?: any) => void;
  110619. /**
  110620. * Creates a new AssetsManager
  110621. * @param name defines the name of the task
  110622. */
  110623. constructor(
  110624. /**
  110625. * Task name
  110626. */ name: string);
  110627. private _isCompleted;
  110628. private _taskState;
  110629. private _errorObject;
  110630. /**
  110631. * Get if the task is completed
  110632. */
  110633. readonly isCompleted: boolean;
  110634. /**
  110635. * Gets the current state of the task
  110636. */
  110637. readonly taskState: AssetTaskState;
  110638. /**
  110639. * Gets the current error object (if task is in error)
  110640. */
  110641. readonly errorObject: {
  110642. message?: string;
  110643. exception?: any;
  110644. };
  110645. /**
  110646. * Internal only
  110647. * @hidden
  110648. */
  110649. _setErrorObject(message?: string, exception?: any): void;
  110650. /**
  110651. * Execute the current task
  110652. * @param scene defines the scene where you want your assets to be loaded
  110653. * @param onSuccess is a callback called when the task is successfully executed
  110654. * @param onError is a callback called if an error occurs
  110655. */
  110656. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110657. /**
  110658. * Execute the current task
  110659. * @param scene defines the scene where you want your assets to be loaded
  110660. * @param onSuccess is a callback called when the task is successfully executed
  110661. * @param onError is a callback called if an error occurs
  110662. */
  110663. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110664. /**
  110665. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  110666. * This can be used with failed tasks that have the reason for failure fixed.
  110667. */
  110668. reset(): void;
  110669. private onErrorCallback;
  110670. private onDoneCallback;
  110671. }
  110672. /**
  110673. * Define the interface used by progress events raised during assets loading
  110674. */
  110675. export interface IAssetsProgressEvent {
  110676. /**
  110677. * Defines the number of remaining tasks to process
  110678. */
  110679. remainingCount: number;
  110680. /**
  110681. * Defines the total number of tasks
  110682. */
  110683. totalCount: number;
  110684. /**
  110685. * Defines the task that was just processed
  110686. */
  110687. task: AbstractAssetTask;
  110688. }
  110689. /**
  110690. * Class used to share progress information about assets loading
  110691. */
  110692. export class AssetsProgressEvent implements IAssetsProgressEvent {
  110693. /**
  110694. * Defines the number of remaining tasks to process
  110695. */
  110696. remainingCount: number;
  110697. /**
  110698. * Defines the total number of tasks
  110699. */
  110700. totalCount: number;
  110701. /**
  110702. * Defines the task that was just processed
  110703. */
  110704. task: AbstractAssetTask;
  110705. /**
  110706. * Creates a AssetsProgressEvent
  110707. * @param remainingCount defines the number of remaining tasks to process
  110708. * @param totalCount defines the total number of tasks
  110709. * @param task defines the task that was just processed
  110710. */
  110711. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  110712. }
  110713. /**
  110714. * Define a task used by AssetsManager to load meshes
  110715. */
  110716. export class MeshAssetTask extends AbstractAssetTask {
  110717. /**
  110718. * Defines the name of the task
  110719. */
  110720. name: string;
  110721. /**
  110722. * Defines the list of mesh's names you want to load
  110723. */
  110724. meshesNames: any;
  110725. /**
  110726. * Defines the root url to use as a base to load your meshes and associated resources
  110727. */
  110728. rootUrl: string;
  110729. /**
  110730. * Defines the filename of the scene to load from
  110731. */
  110732. sceneFilename: string;
  110733. /**
  110734. * Gets the list of loaded meshes
  110735. */
  110736. loadedMeshes: Array<AbstractMesh>;
  110737. /**
  110738. * Gets the list of loaded particle systems
  110739. */
  110740. loadedParticleSystems: Array<IParticleSystem>;
  110741. /**
  110742. * Gets the list of loaded skeletons
  110743. */
  110744. loadedSkeletons: Array<Skeleton>;
  110745. /**
  110746. * Gets the list of loaded animation groups
  110747. */
  110748. loadedAnimationGroups: Array<AnimationGroup>;
  110749. /**
  110750. * Callback called when the task is successful
  110751. */
  110752. onSuccess: (task: MeshAssetTask) => void;
  110753. /**
  110754. * Callback called when the task is successful
  110755. */
  110756. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  110757. /**
  110758. * Creates a new MeshAssetTask
  110759. * @param name defines the name of the task
  110760. * @param meshesNames defines the list of mesh's names you want to load
  110761. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  110762. * @param sceneFilename defines the filename of the scene to load from
  110763. */
  110764. constructor(
  110765. /**
  110766. * Defines the name of the task
  110767. */
  110768. name: string,
  110769. /**
  110770. * Defines the list of mesh's names you want to load
  110771. */
  110772. meshesNames: any,
  110773. /**
  110774. * Defines the root url to use as a base to load your meshes and associated resources
  110775. */
  110776. rootUrl: string,
  110777. /**
  110778. * Defines the filename of the scene to load from
  110779. */
  110780. sceneFilename: string);
  110781. /**
  110782. * Execute the current task
  110783. * @param scene defines the scene where you want your assets to be loaded
  110784. * @param onSuccess is a callback called when the task is successfully executed
  110785. * @param onError is a callback called if an error occurs
  110786. */
  110787. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110788. }
  110789. /**
  110790. * Define a task used by AssetsManager to load text content
  110791. */
  110792. export class TextFileAssetTask extends AbstractAssetTask {
  110793. /**
  110794. * Defines the name of the task
  110795. */
  110796. name: string;
  110797. /**
  110798. * Defines the location of the file to load
  110799. */
  110800. url: string;
  110801. /**
  110802. * Gets the loaded text string
  110803. */
  110804. text: string;
  110805. /**
  110806. * Callback called when the task is successful
  110807. */
  110808. onSuccess: (task: TextFileAssetTask) => void;
  110809. /**
  110810. * Callback called when the task is successful
  110811. */
  110812. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  110813. /**
  110814. * Creates a new TextFileAssetTask object
  110815. * @param name defines the name of the task
  110816. * @param url defines the location of the file to load
  110817. */
  110818. constructor(
  110819. /**
  110820. * Defines the name of the task
  110821. */
  110822. name: string,
  110823. /**
  110824. * Defines the location of the file to load
  110825. */
  110826. url: string);
  110827. /**
  110828. * Execute the current task
  110829. * @param scene defines the scene where you want your assets to be loaded
  110830. * @param onSuccess is a callback called when the task is successfully executed
  110831. * @param onError is a callback called if an error occurs
  110832. */
  110833. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110834. }
  110835. /**
  110836. * Define a task used by AssetsManager to load binary data
  110837. */
  110838. export class BinaryFileAssetTask extends AbstractAssetTask {
  110839. /**
  110840. * Defines the name of the task
  110841. */
  110842. name: string;
  110843. /**
  110844. * Defines the location of the file to load
  110845. */
  110846. url: string;
  110847. /**
  110848. * Gets the lodaded data (as an array buffer)
  110849. */
  110850. data: ArrayBuffer;
  110851. /**
  110852. * Callback called when the task is successful
  110853. */
  110854. onSuccess: (task: BinaryFileAssetTask) => void;
  110855. /**
  110856. * Callback called when the task is successful
  110857. */
  110858. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  110859. /**
  110860. * Creates a new BinaryFileAssetTask object
  110861. * @param name defines the name of the new task
  110862. * @param url defines the location of the file to load
  110863. */
  110864. constructor(
  110865. /**
  110866. * Defines the name of the task
  110867. */
  110868. name: string,
  110869. /**
  110870. * Defines the location of the file to load
  110871. */
  110872. url: string);
  110873. /**
  110874. * Execute the current task
  110875. * @param scene defines the scene where you want your assets to be loaded
  110876. * @param onSuccess is a callback called when the task is successfully executed
  110877. * @param onError is a callback called if an error occurs
  110878. */
  110879. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110880. }
  110881. /**
  110882. * Define a task used by AssetsManager to load images
  110883. */
  110884. export class ImageAssetTask extends AbstractAssetTask {
  110885. /**
  110886. * Defines the name of the task
  110887. */
  110888. name: string;
  110889. /**
  110890. * Defines the location of the image to load
  110891. */
  110892. url: string;
  110893. /**
  110894. * Gets the loaded images
  110895. */
  110896. image: HTMLImageElement;
  110897. /**
  110898. * Callback called when the task is successful
  110899. */
  110900. onSuccess: (task: ImageAssetTask) => void;
  110901. /**
  110902. * Callback called when the task is successful
  110903. */
  110904. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  110905. /**
  110906. * Creates a new ImageAssetTask
  110907. * @param name defines the name of the task
  110908. * @param url defines the location of the image to load
  110909. */
  110910. constructor(
  110911. /**
  110912. * Defines the name of the task
  110913. */
  110914. name: string,
  110915. /**
  110916. * Defines the location of the image to load
  110917. */
  110918. url: string);
  110919. /**
  110920. * Execute the current task
  110921. * @param scene defines the scene where you want your assets to be loaded
  110922. * @param onSuccess is a callback called when the task is successfully executed
  110923. * @param onError is a callback called if an error occurs
  110924. */
  110925. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110926. }
  110927. /**
  110928. * Defines the interface used by texture loading tasks
  110929. */
  110930. export interface ITextureAssetTask<TEX extends BaseTexture> {
  110931. /**
  110932. * Gets the loaded texture
  110933. */
  110934. texture: TEX;
  110935. }
  110936. /**
  110937. * Define a task used by AssetsManager to load 2D textures
  110938. */
  110939. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  110940. /**
  110941. * Defines the name of the task
  110942. */
  110943. name: string;
  110944. /**
  110945. * Defines the location of the file to load
  110946. */
  110947. url: string;
  110948. /**
  110949. * Defines if mipmap should not be generated (default is false)
  110950. */
  110951. noMipmap?: boolean | undefined;
  110952. /**
  110953. * Defines if texture must be inverted on Y axis (default is false)
  110954. */
  110955. invertY?: boolean | undefined;
  110956. /**
  110957. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110958. */
  110959. samplingMode: number;
  110960. /**
  110961. * Gets the loaded texture
  110962. */
  110963. texture: Texture;
  110964. /**
  110965. * Callback called when the task is successful
  110966. */
  110967. onSuccess: (task: TextureAssetTask) => void;
  110968. /**
  110969. * Callback called when the task is successful
  110970. */
  110971. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  110972. /**
  110973. * Creates a new TextureAssetTask object
  110974. * @param name defines the name of the task
  110975. * @param url defines the location of the file to load
  110976. * @param noMipmap defines if mipmap should not be generated (default is false)
  110977. * @param invertY defines if texture must be inverted on Y axis (default is false)
  110978. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110979. */
  110980. constructor(
  110981. /**
  110982. * Defines the name of the task
  110983. */
  110984. name: string,
  110985. /**
  110986. * Defines the location of the file to load
  110987. */
  110988. url: string,
  110989. /**
  110990. * Defines if mipmap should not be generated (default is false)
  110991. */
  110992. noMipmap?: boolean | undefined,
  110993. /**
  110994. * Defines if texture must be inverted on Y axis (default is false)
  110995. */
  110996. invertY?: boolean | undefined,
  110997. /**
  110998. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110999. */
  111000. samplingMode?: number);
  111001. /**
  111002. * Execute the current task
  111003. * @param scene defines the scene where you want your assets to be loaded
  111004. * @param onSuccess is a callback called when the task is successfully executed
  111005. * @param onError is a callback called if an error occurs
  111006. */
  111007. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111008. }
  111009. /**
  111010. * Define a task used by AssetsManager to load cube textures
  111011. */
  111012. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  111013. /**
  111014. * Defines the name of the task
  111015. */
  111016. name: string;
  111017. /**
  111018. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111019. */
  111020. url: string;
  111021. /**
  111022. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111023. */
  111024. extensions?: string[] | undefined;
  111025. /**
  111026. * Defines if mipmaps should not be generated (default is false)
  111027. */
  111028. noMipmap?: boolean | undefined;
  111029. /**
  111030. * Defines the explicit list of files (undefined by default)
  111031. */
  111032. files?: string[] | undefined;
  111033. /**
  111034. * Gets the loaded texture
  111035. */
  111036. texture: CubeTexture;
  111037. /**
  111038. * Callback called when the task is successful
  111039. */
  111040. onSuccess: (task: CubeTextureAssetTask) => void;
  111041. /**
  111042. * Callback called when the task is successful
  111043. */
  111044. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  111045. /**
  111046. * Creates a new CubeTextureAssetTask
  111047. * @param name defines the name of the task
  111048. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111049. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111050. * @param noMipmap defines if mipmaps should not be generated (default is false)
  111051. * @param files defines the explicit list of files (undefined by default)
  111052. */
  111053. constructor(
  111054. /**
  111055. * Defines the name of the task
  111056. */
  111057. name: string,
  111058. /**
  111059. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111060. */
  111061. url: string,
  111062. /**
  111063. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111064. */
  111065. extensions?: string[] | undefined,
  111066. /**
  111067. * Defines if mipmaps should not be generated (default is false)
  111068. */
  111069. noMipmap?: boolean | undefined,
  111070. /**
  111071. * Defines the explicit list of files (undefined by default)
  111072. */
  111073. files?: string[] | undefined);
  111074. /**
  111075. * Execute the current task
  111076. * @param scene defines the scene where you want your assets to be loaded
  111077. * @param onSuccess is a callback called when the task is successfully executed
  111078. * @param onError is a callback called if an error occurs
  111079. */
  111080. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111081. }
  111082. /**
  111083. * Define a task used by AssetsManager to load HDR cube textures
  111084. */
  111085. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  111086. /**
  111087. * Defines the name of the task
  111088. */
  111089. name: string;
  111090. /**
  111091. * Defines the location of the file to load
  111092. */
  111093. url: string;
  111094. /**
  111095. * Defines the desired size (the more it increases the longer the generation will be)
  111096. */
  111097. size: number;
  111098. /**
  111099. * Defines if mipmaps should not be generated (default is false)
  111100. */
  111101. noMipmap: boolean;
  111102. /**
  111103. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111104. */
  111105. generateHarmonics: boolean;
  111106. /**
  111107. * 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)
  111108. */
  111109. gammaSpace: boolean;
  111110. /**
  111111. * Internal Use Only
  111112. */
  111113. reserved: boolean;
  111114. /**
  111115. * Gets the loaded texture
  111116. */
  111117. texture: HDRCubeTexture;
  111118. /**
  111119. * Callback called when the task is successful
  111120. */
  111121. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  111122. /**
  111123. * Callback called when the task is successful
  111124. */
  111125. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  111126. /**
  111127. * Creates a new HDRCubeTextureAssetTask object
  111128. * @param name defines the name of the task
  111129. * @param url defines the location of the file to load
  111130. * @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.
  111131. * @param noMipmap defines if mipmaps should not be generated (default is false)
  111132. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111133. * @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)
  111134. * @param reserved Internal use only
  111135. */
  111136. constructor(
  111137. /**
  111138. * Defines the name of the task
  111139. */
  111140. name: string,
  111141. /**
  111142. * Defines the location of the file to load
  111143. */
  111144. url: string,
  111145. /**
  111146. * Defines the desired size (the more it increases the longer the generation will be)
  111147. */
  111148. size: number,
  111149. /**
  111150. * Defines if mipmaps should not be generated (default is false)
  111151. */
  111152. noMipmap?: boolean,
  111153. /**
  111154. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111155. */
  111156. generateHarmonics?: boolean,
  111157. /**
  111158. * 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)
  111159. */
  111160. gammaSpace?: boolean,
  111161. /**
  111162. * Internal Use Only
  111163. */
  111164. reserved?: boolean);
  111165. /**
  111166. * Execute the current task
  111167. * @param scene defines the scene where you want your assets to be loaded
  111168. * @param onSuccess is a callback called when the task is successfully executed
  111169. * @param onError is a callback called if an error occurs
  111170. */
  111171. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111172. }
  111173. /**
  111174. * This class can be used to easily import assets into a scene
  111175. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  111176. */
  111177. export class AssetsManager {
  111178. private _scene;
  111179. private _isLoading;
  111180. protected _tasks: AbstractAssetTask[];
  111181. protected _waitingTasksCount: number;
  111182. protected _totalTasksCount: number;
  111183. /**
  111184. * Callback called when all tasks are processed
  111185. */
  111186. onFinish: (tasks: AbstractAssetTask[]) => void;
  111187. /**
  111188. * Callback called when a task is successful
  111189. */
  111190. onTaskSuccess: (task: AbstractAssetTask) => void;
  111191. /**
  111192. * Callback called when a task had an error
  111193. */
  111194. onTaskError: (task: AbstractAssetTask) => void;
  111195. /**
  111196. * Callback called when a task is done (whatever the result is)
  111197. */
  111198. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  111199. /**
  111200. * Observable called when all tasks are processed
  111201. */
  111202. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  111203. /**
  111204. * Observable called when a task had an error
  111205. */
  111206. onTaskErrorObservable: Observable<AbstractAssetTask>;
  111207. /**
  111208. * Observable called when a task is successful
  111209. */
  111210. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  111211. /**
  111212. * Observable called when a task is done (whatever the result is)
  111213. */
  111214. onProgressObservable: Observable<IAssetsProgressEvent>;
  111215. /**
  111216. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  111217. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  111218. */
  111219. useDefaultLoadingScreen: boolean;
  111220. /**
  111221. * Creates a new AssetsManager
  111222. * @param scene defines the scene to work on
  111223. */
  111224. constructor(scene: Scene);
  111225. /**
  111226. * Add a MeshAssetTask to the list of active tasks
  111227. * @param taskName defines the name of the new task
  111228. * @param meshesNames defines the name of meshes to load
  111229. * @param rootUrl defines the root url to use to locate files
  111230. * @param sceneFilename defines the filename of the scene file
  111231. * @returns a new MeshAssetTask object
  111232. */
  111233. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  111234. /**
  111235. * Add a TextFileAssetTask to the list of active tasks
  111236. * @param taskName defines the name of the new task
  111237. * @param url defines the url of the file to load
  111238. * @returns a new TextFileAssetTask object
  111239. */
  111240. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  111241. /**
  111242. * Add a BinaryFileAssetTask to the list of active tasks
  111243. * @param taskName defines the name of the new task
  111244. * @param url defines the url of the file to load
  111245. * @returns a new BinaryFileAssetTask object
  111246. */
  111247. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  111248. /**
  111249. * Add a ImageAssetTask to the list of active tasks
  111250. * @param taskName defines the name of the new task
  111251. * @param url defines the url of the file to load
  111252. * @returns a new ImageAssetTask object
  111253. */
  111254. addImageTask(taskName: string, url: string): ImageAssetTask;
  111255. /**
  111256. * Add a TextureAssetTask to the list of active tasks
  111257. * @param taskName defines the name of the new task
  111258. * @param url defines the url of the file to load
  111259. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111260. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  111261. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  111262. * @returns a new TextureAssetTask object
  111263. */
  111264. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  111265. /**
  111266. * Add a CubeTextureAssetTask to the list of active tasks
  111267. * @param taskName defines the name of the new task
  111268. * @param url defines the url of the file to load
  111269. * @param extensions defines the extension to use to load the cube map (can be null)
  111270. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111271. * @param files defines the list of files to load (can be null)
  111272. * @returns a new CubeTextureAssetTask object
  111273. */
  111274. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  111275. /**
  111276. *
  111277. * Add a HDRCubeTextureAssetTask to the list of active tasks
  111278. * @param taskName defines the name of the new task
  111279. * @param url defines the url of the file to load
  111280. * @param size defines the size you want for the cubemap (can be null)
  111281. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111282. * @param generateHarmonics defines if you want to automatically generate (true by default)
  111283. * @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)
  111284. * @param reserved Internal use only
  111285. * @returns a new HDRCubeTextureAssetTask object
  111286. */
  111287. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  111288. /**
  111289. * Remove a task from the assets manager.
  111290. * @param task the task to remove
  111291. */
  111292. removeTask(task: AbstractAssetTask): void;
  111293. private _decreaseWaitingTasksCount;
  111294. private _runTask;
  111295. /**
  111296. * Reset the AssetsManager and remove all tasks
  111297. * @return the current instance of the AssetsManager
  111298. */
  111299. reset(): AssetsManager;
  111300. /**
  111301. * Start the loading process
  111302. * @return the current instance of the AssetsManager
  111303. */
  111304. load(): AssetsManager;
  111305. }
  111306. }
  111307. declare module BABYLON {
  111308. /**
  111309. * Wrapper class for promise with external resolve and reject.
  111310. */
  111311. export class Deferred<T> {
  111312. /**
  111313. * The promise associated with this deferred object.
  111314. */
  111315. readonly promise: Promise<T>;
  111316. private _resolve;
  111317. private _reject;
  111318. /**
  111319. * The resolve method of the promise associated with this deferred object.
  111320. */
  111321. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  111322. /**
  111323. * The reject method of the promise associated with this deferred object.
  111324. */
  111325. readonly reject: (reason?: any) => void;
  111326. /**
  111327. * Constructor for this deferred object.
  111328. */
  111329. constructor();
  111330. }
  111331. }
  111332. declare module BABYLON {
  111333. /**
  111334. * Class used to help managing file picking and drag'n'drop
  111335. */
  111336. export class FilesInput {
  111337. /**
  111338. * List of files ready to be loaded
  111339. */
  111340. static readonly FilesToLoad: {
  111341. [key: string]: File;
  111342. };
  111343. /**
  111344. * Callback called when a file is processed
  111345. */
  111346. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  111347. private _engine;
  111348. private _currentScene;
  111349. private _sceneLoadedCallback;
  111350. private _progressCallback;
  111351. private _additionalRenderLoopLogicCallback;
  111352. private _textureLoadingCallback;
  111353. private _startingProcessingFilesCallback;
  111354. private _onReloadCallback;
  111355. private _errorCallback;
  111356. private _elementToMonitor;
  111357. private _sceneFileToLoad;
  111358. private _filesToLoad;
  111359. /**
  111360. * Creates a new FilesInput
  111361. * @param engine defines the rendering engine
  111362. * @param scene defines the hosting scene
  111363. * @param sceneLoadedCallback callback called when scene is loaded
  111364. * @param progressCallback callback called to track progress
  111365. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  111366. * @param textureLoadingCallback callback called when a texture is loading
  111367. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  111368. * @param onReloadCallback callback called when a reload is requested
  111369. * @param errorCallback callback call if an error occurs
  111370. */
  111371. 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);
  111372. private _dragEnterHandler;
  111373. private _dragOverHandler;
  111374. private _dropHandler;
  111375. /**
  111376. * Calls this function to listen to drag'n'drop events on a specific DOM element
  111377. * @param elementToMonitor defines the DOM element to track
  111378. */
  111379. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  111380. /**
  111381. * Release all associated resources
  111382. */
  111383. dispose(): void;
  111384. private renderFunction;
  111385. private drag;
  111386. private drop;
  111387. private _traverseFolder;
  111388. private _processFiles;
  111389. /**
  111390. * Load files from a drop event
  111391. * @param event defines the drop event to use as source
  111392. */
  111393. loadFiles(event: any): void;
  111394. private _processReload;
  111395. /**
  111396. * Reload the current scene from the loaded files
  111397. */
  111398. reload(): void;
  111399. }
  111400. }
  111401. declare module BABYLON {
  111402. /**
  111403. * Defines the root class used to create scene optimization to use with SceneOptimizer
  111404. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111405. */
  111406. export class SceneOptimization {
  111407. /**
  111408. * Defines the priority of this optimization (0 by default which means first in the list)
  111409. */
  111410. priority: number;
  111411. /**
  111412. * Gets a string describing the action executed by the current optimization
  111413. * @returns description string
  111414. */
  111415. getDescription(): string;
  111416. /**
  111417. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111418. * @param scene defines the current scene where to apply this optimization
  111419. * @param optimizer defines the current optimizer
  111420. * @returns true if everything that can be done was applied
  111421. */
  111422. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111423. /**
  111424. * Creates the SceneOptimization object
  111425. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111426. * @param desc defines the description associated with the optimization
  111427. */
  111428. constructor(
  111429. /**
  111430. * Defines the priority of this optimization (0 by default which means first in the list)
  111431. */
  111432. priority?: number);
  111433. }
  111434. /**
  111435. * Defines an optimization used to reduce the size of render target textures
  111436. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111437. */
  111438. export class TextureOptimization extends SceneOptimization {
  111439. /**
  111440. * Defines the priority of this optimization (0 by default which means first in the list)
  111441. */
  111442. priority: number;
  111443. /**
  111444. * 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
  111445. */
  111446. maximumSize: number;
  111447. /**
  111448. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111449. */
  111450. step: number;
  111451. /**
  111452. * Gets a string describing the action executed by the current optimization
  111453. * @returns description string
  111454. */
  111455. getDescription(): string;
  111456. /**
  111457. * Creates the TextureOptimization object
  111458. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111459. * @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
  111460. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111461. */
  111462. constructor(
  111463. /**
  111464. * Defines the priority of this optimization (0 by default which means first in the list)
  111465. */
  111466. priority?: number,
  111467. /**
  111468. * 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
  111469. */
  111470. maximumSize?: number,
  111471. /**
  111472. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111473. */
  111474. step?: number);
  111475. /**
  111476. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111477. * @param scene defines the current scene where to apply this optimization
  111478. * @param optimizer defines the current optimizer
  111479. * @returns true if everything that can be done was applied
  111480. */
  111481. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111482. }
  111483. /**
  111484. * Defines an optimization used to increase or decrease the rendering resolution
  111485. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111486. */
  111487. export class HardwareScalingOptimization extends SceneOptimization {
  111488. /**
  111489. * Defines the priority of this optimization (0 by default which means first in the list)
  111490. */
  111491. priority: number;
  111492. /**
  111493. * Defines the maximum scale to use (2 by default)
  111494. */
  111495. maximumScale: number;
  111496. /**
  111497. * Defines the step to use between two passes (0.5 by default)
  111498. */
  111499. step: number;
  111500. private _currentScale;
  111501. private _directionOffset;
  111502. /**
  111503. * Gets a string describing the action executed by the current optimization
  111504. * @return description string
  111505. */
  111506. getDescription(): string;
  111507. /**
  111508. * Creates the HardwareScalingOptimization object
  111509. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111510. * @param maximumScale defines the maximum scale to use (2 by default)
  111511. * @param step defines the step to use between two passes (0.5 by default)
  111512. */
  111513. constructor(
  111514. /**
  111515. * Defines the priority of this optimization (0 by default which means first in the list)
  111516. */
  111517. priority?: number,
  111518. /**
  111519. * Defines the maximum scale to use (2 by default)
  111520. */
  111521. maximumScale?: number,
  111522. /**
  111523. * Defines the step to use between two passes (0.5 by default)
  111524. */
  111525. step?: number);
  111526. /**
  111527. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111528. * @param scene defines the current scene where to apply this optimization
  111529. * @param optimizer defines the current optimizer
  111530. * @returns true if everything that can be done was applied
  111531. */
  111532. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111533. }
  111534. /**
  111535. * Defines an optimization used to remove shadows
  111536. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111537. */
  111538. export class ShadowsOptimization extends SceneOptimization {
  111539. /**
  111540. * Gets a string describing the action executed by the current optimization
  111541. * @return description string
  111542. */
  111543. getDescription(): string;
  111544. /**
  111545. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111546. * @param scene defines the current scene where to apply this optimization
  111547. * @param optimizer defines the current optimizer
  111548. * @returns true if everything that can be done was applied
  111549. */
  111550. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111551. }
  111552. /**
  111553. * Defines an optimization used to turn post-processes off
  111554. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111555. */
  111556. export class PostProcessesOptimization extends SceneOptimization {
  111557. /**
  111558. * Gets a string describing the action executed by the current optimization
  111559. * @return description string
  111560. */
  111561. getDescription(): string;
  111562. /**
  111563. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111564. * @param scene defines the current scene where to apply this optimization
  111565. * @param optimizer defines the current optimizer
  111566. * @returns true if everything that can be done was applied
  111567. */
  111568. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111569. }
  111570. /**
  111571. * Defines an optimization used to turn lens flares off
  111572. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111573. */
  111574. export class LensFlaresOptimization extends SceneOptimization {
  111575. /**
  111576. * Gets a string describing the action executed by the current optimization
  111577. * @return description string
  111578. */
  111579. getDescription(): string;
  111580. /**
  111581. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111582. * @param scene defines the current scene where to apply this optimization
  111583. * @param optimizer defines the current optimizer
  111584. * @returns true if everything that can be done was applied
  111585. */
  111586. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111587. }
  111588. /**
  111589. * Defines an optimization based on user defined callback.
  111590. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111591. */
  111592. export class CustomOptimization extends SceneOptimization {
  111593. /**
  111594. * Callback called to apply the custom optimization.
  111595. */
  111596. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  111597. /**
  111598. * Callback called to get custom description
  111599. */
  111600. onGetDescription: () => string;
  111601. /**
  111602. * Gets a string describing the action executed by the current optimization
  111603. * @returns description string
  111604. */
  111605. getDescription(): string;
  111606. /**
  111607. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111608. * @param scene defines the current scene where to apply this optimization
  111609. * @param optimizer defines the current optimizer
  111610. * @returns true if everything that can be done was applied
  111611. */
  111612. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111613. }
  111614. /**
  111615. * Defines an optimization used to turn particles off
  111616. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111617. */
  111618. export class ParticlesOptimization extends SceneOptimization {
  111619. /**
  111620. * Gets a string describing the action executed by the current optimization
  111621. * @return description string
  111622. */
  111623. getDescription(): string;
  111624. /**
  111625. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111626. * @param scene defines the current scene where to apply this optimization
  111627. * @param optimizer defines the current optimizer
  111628. * @returns true if everything that can be done was applied
  111629. */
  111630. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111631. }
  111632. /**
  111633. * Defines an optimization used to turn render targets off
  111634. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111635. */
  111636. export class RenderTargetsOptimization extends SceneOptimization {
  111637. /**
  111638. * Gets a string describing the action executed by the current optimization
  111639. * @return description string
  111640. */
  111641. getDescription(): string;
  111642. /**
  111643. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111644. * @param scene defines the current scene where to apply this optimization
  111645. * @param optimizer defines the current optimizer
  111646. * @returns true if everything that can be done was applied
  111647. */
  111648. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111649. }
  111650. /**
  111651. * Defines an optimization used to merge meshes with compatible materials
  111652. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111653. */
  111654. export class MergeMeshesOptimization extends SceneOptimization {
  111655. private static _UpdateSelectionTree;
  111656. /**
  111657. * Gets or sets a boolean which defines if optimization octree has to be updated
  111658. */
  111659. /**
  111660. * Gets or sets a boolean which defines if optimization octree has to be updated
  111661. */
  111662. static UpdateSelectionTree: boolean;
  111663. /**
  111664. * Gets a string describing the action executed by the current optimization
  111665. * @return description string
  111666. */
  111667. getDescription(): string;
  111668. private _canBeMerged;
  111669. /**
  111670. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111671. * @param scene defines the current scene where to apply this optimization
  111672. * @param optimizer defines the current optimizer
  111673. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  111674. * @returns true if everything that can be done was applied
  111675. */
  111676. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  111677. }
  111678. /**
  111679. * Defines a list of options used by SceneOptimizer
  111680. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111681. */
  111682. export class SceneOptimizerOptions {
  111683. /**
  111684. * Defines the target frame rate to reach (60 by default)
  111685. */
  111686. targetFrameRate: number;
  111687. /**
  111688. * Defines the interval between two checkes (2000ms by default)
  111689. */
  111690. trackerDuration: number;
  111691. /**
  111692. * Gets the list of optimizations to apply
  111693. */
  111694. optimizations: SceneOptimization[];
  111695. /**
  111696. * Creates a new list of options used by SceneOptimizer
  111697. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  111698. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  111699. */
  111700. constructor(
  111701. /**
  111702. * Defines the target frame rate to reach (60 by default)
  111703. */
  111704. targetFrameRate?: number,
  111705. /**
  111706. * Defines the interval between two checkes (2000ms by default)
  111707. */
  111708. trackerDuration?: number);
  111709. /**
  111710. * Add a new optimization
  111711. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  111712. * @returns the current SceneOptimizerOptions
  111713. */
  111714. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  111715. /**
  111716. * Add a new custom optimization
  111717. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  111718. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  111719. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111720. * @returns the current SceneOptimizerOptions
  111721. */
  111722. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  111723. /**
  111724. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  111725. * @param targetFrameRate defines the target frame rate (60 by default)
  111726. * @returns a SceneOptimizerOptions object
  111727. */
  111728. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111729. /**
  111730. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  111731. * @param targetFrameRate defines the target frame rate (60 by default)
  111732. * @returns a SceneOptimizerOptions object
  111733. */
  111734. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111735. /**
  111736. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  111737. * @param targetFrameRate defines the target frame rate (60 by default)
  111738. * @returns a SceneOptimizerOptions object
  111739. */
  111740. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111741. }
  111742. /**
  111743. * Class used to run optimizations in order to reach a target frame rate
  111744. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111745. */
  111746. export class SceneOptimizer implements IDisposable {
  111747. private _isRunning;
  111748. private _options;
  111749. private _scene;
  111750. private _currentPriorityLevel;
  111751. private _targetFrameRate;
  111752. private _trackerDuration;
  111753. private _currentFrameRate;
  111754. private _sceneDisposeObserver;
  111755. private _improvementMode;
  111756. /**
  111757. * Defines an observable called when the optimizer reaches the target frame rate
  111758. */
  111759. onSuccessObservable: Observable<SceneOptimizer>;
  111760. /**
  111761. * Defines an observable called when the optimizer enables an optimization
  111762. */
  111763. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  111764. /**
  111765. * Defines an observable called when the optimizer is not able to reach the target frame rate
  111766. */
  111767. onFailureObservable: Observable<SceneOptimizer>;
  111768. /**
  111769. * Gets a boolean indicating if the optimizer is in improvement mode
  111770. */
  111771. readonly isInImprovementMode: boolean;
  111772. /**
  111773. * Gets the current priority level (0 at start)
  111774. */
  111775. readonly currentPriorityLevel: number;
  111776. /**
  111777. * Gets the current frame rate checked by the SceneOptimizer
  111778. */
  111779. readonly currentFrameRate: number;
  111780. /**
  111781. * Gets or sets the current target frame rate (60 by default)
  111782. */
  111783. /**
  111784. * Gets or sets the current target frame rate (60 by default)
  111785. */
  111786. targetFrameRate: number;
  111787. /**
  111788. * Gets or sets the current interval between two checks (every 2000ms by default)
  111789. */
  111790. /**
  111791. * Gets or sets the current interval between two checks (every 2000ms by default)
  111792. */
  111793. trackerDuration: number;
  111794. /**
  111795. * Gets the list of active optimizations
  111796. */
  111797. readonly optimizations: SceneOptimization[];
  111798. /**
  111799. * Creates a new SceneOptimizer
  111800. * @param scene defines the scene to work on
  111801. * @param options defines the options to use with the SceneOptimizer
  111802. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  111803. * @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)
  111804. */
  111805. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  111806. /**
  111807. * Stops the current optimizer
  111808. */
  111809. stop(): void;
  111810. /**
  111811. * Reset the optimizer to initial step (current priority level = 0)
  111812. */
  111813. reset(): void;
  111814. /**
  111815. * Start the optimizer. By default it will try to reach a specific framerate
  111816. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  111817. */
  111818. start(): void;
  111819. private _checkCurrentState;
  111820. /**
  111821. * Release all resources
  111822. */
  111823. dispose(): void;
  111824. /**
  111825. * Helper function to create a SceneOptimizer with one single line of code
  111826. * @param scene defines the scene to work on
  111827. * @param options defines the options to use with the SceneOptimizer
  111828. * @param onSuccess defines a callback to call on success
  111829. * @param onFailure defines a callback to call on failure
  111830. * @returns the new SceneOptimizer object
  111831. */
  111832. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  111833. }
  111834. }
  111835. declare module BABYLON {
  111836. /**
  111837. * Class used to serialize a scene into a string
  111838. */
  111839. export class SceneSerializer {
  111840. /**
  111841. * Clear cache used by a previous serialization
  111842. */
  111843. static ClearCache(): void;
  111844. /**
  111845. * Serialize a scene into a JSON compatible object
  111846. * @param scene defines the scene to serialize
  111847. * @returns a JSON compatible object
  111848. */
  111849. static Serialize(scene: Scene): any;
  111850. /**
  111851. * Serialize a mesh into a JSON compatible object
  111852. * @param toSerialize defines the mesh to serialize
  111853. * @param withParents defines if parents must be serialized as well
  111854. * @param withChildren defines if children must be serialized as well
  111855. * @returns a JSON compatible object
  111856. */
  111857. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  111858. }
  111859. }
  111860. declare module BABYLON {
  111861. /**
  111862. * This represents the different options avilable for the video capture.
  111863. */
  111864. export interface VideoRecorderOptions {
  111865. /** Defines the mime type of the video */
  111866. mimeType: string;
  111867. /** Defines the video the video should be recorded at */
  111868. fps: number;
  111869. /** Defines the chunk size for the recording data */
  111870. recordChunckSize: number;
  111871. /** The audio tracks to attach to the record */
  111872. audioTracks?: MediaStreamTrack[];
  111873. }
  111874. /**
  111875. * This can helps recording videos from BabylonJS.
  111876. * This is based on the available WebRTC functionalities of the browser.
  111877. *
  111878. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  111879. */
  111880. export class VideoRecorder {
  111881. private static readonly _defaultOptions;
  111882. /**
  111883. * Returns wehther or not the VideoRecorder is available in your browser.
  111884. * @param engine Defines the Babylon Engine to check the support for
  111885. * @returns true if supported otherwise false
  111886. */
  111887. static IsSupported(engine: Engine): boolean;
  111888. private readonly _options;
  111889. private _canvas;
  111890. private _mediaRecorder;
  111891. private _recordedChunks;
  111892. private _fileName;
  111893. private _resolve;
  111894. private _reject;
  111895. /**
  111896. * True wether a recording is already in progress.
  111897. */
  111898. readonly isRecording: boolean;
  111899. /**
  111900. * Create a new VideoCapture object which can help converting what you see in Babylon to
  111901. * a video file.
  111902. * @param engine Defines the BabylonJS Engine you wish to record
  111903. * @param options Defines options that can be used to customized the capture
  111904. */
  111905. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  111906. /**
  111907. * Stops the current recording before the default capture timeout passed in the startRecording
  111908. * functions.
  111909. */
  111910. stopRecording(): void;
  111911. /**
  111912. * Starts recording the canvas for a max duration specified in parameters.
  111913. * @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.
  111914. * @param maxDuration Defines the maximum recording time in seconds.
  111915. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  111916. * @return a promise callback at the end of the recording with the video data in Blob.
  111917. */
  111918. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  111919. /**
  111920. * Releases internal resources used during the recording.
  111921. */
  111922. dispose(): void;
  111923. private _handleDataAvailable;
  111924. private _handleError;
  111925. private _handleStop;
  111926. }
  111927. }
  111928. declare module BABYLON {
  111929. /**
  111930. * Helper class to push actions to a pool of workers.
  111931. */
  111932. export class WorkerPool implements IDisposable {
  111933. private _workerInfos;
  111934. private _pendingActions;
  111935. /**
  111936. * Constructor
  111937. * @param workers Array of workers to use for actions
  111938. */
  111939. constructor(workers: Array<Worker>);
  111940. /**
  111941. * Terminates all workers and clears any pending actions.
  111942. */
  111943. dispose(): void;
  111944. /**
  111945. * Pushes an action to the worker pool. If all the workers are active, the action will be
  111946. * pended until a worker has completed its action.
  111947. * @param action The action to perform. Call onComplete when the action is complete.
  111948. */
  111949. push(action: (worker: Worker, onComplete: () => void) => void): void;
  111950. private _execute;
  111951. }
  111952. }
  111953. declare module BABYLON {
  111954. /**
  111955. * Class containing a set of static utilities functions for screenshots
  111956. */
  111957. export class ScreenshotTools {
  111958. /**
  111959. * Captures a screenshot of the current rendering
  111960. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  111961. * @param engine defines the rendering engine
  111962. * @param camera defines the source camera
  111963. * @param size This parameter can be set to a single number or to an object with the
  111964. * following (optional) properties: precision, width, height. If a single number is passed,
  111965. * it will be used for both width and height. If an object is passed, the screenshot size
  111966. * will be derived from the parameters. The precision property is a multiplier allowing
  111967. * rendering at a higher or lower resolution
  111968. * @param successCallback defines the callback receives a single parameter which contains the
  111969. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  111970. * src parameter of an <img> to display it
  111971. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  111972. * Check your browser for supported MIME types
  111973. */
  111974. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  111975. /**
  111976. * Generates an image screenshot from the specified camera.
  111977. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  111978. * @param engine The engine to use for rendering
  111979. * @param camera The camera to use for rendering
  111980. * @param size This parameter can be set to a single number or to an object with the
  111981. * following (optional) properties: precision, width, height. If a single number is passed,
  111982. * it will be used for both width and height. If an object is passed, the screenshot size
  111983. * will be derived from the parameters. The precision property is a multiplier allowing
  111984. * rendering at a higher or lower resolution
  111985. * @param successCallback The callback receives a single parameter which contains the
  111986. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  111987. * src parameter of an <img> to display it
  111988. * @param mimeType The MIME type of the screenshot image (default: image/png).
  111989. * Check your browser for supported MIME types
  111990. * @param samples Texture samples (default: 1)
  111991. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  111992. * @param fileName A name for for the downloaded file.
  111993. */
  111994. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  111995. }
  111996. }
  111997. declare module BABYLON {
  111998. /**
  111999. * A cursor which tracks a point on a path
  112000. */
  112001. export class PathCursor {
  112002. private path;
  112003. /**
  112004. * Stores path cursor callbacks for when an onchange event is triggered
  112005. */
  112006. private _onchange;
  112007. /**
  112008. * The value of the path cursor
  112009. */
  112010. value: number;
  112011. /**
  112012. * The animation array of the path cursor
  112013. */
  112014. animations: Animation[];
  112015. /**
  112016. * Initializes the path cursor
  112017. * @param path The path to track
  112018. */
  112019. constructor(path: Path2);
  112020. /**
  112021. * Gets the cursor point on the path
  112022. * @returns A point on the path cursor at the cursor location
  112023. */
  112024. getPoint(): Vector3;
  112025. /**
  112026. * Moves the cursor ahead by the step amount
  112027. * @param step The amount to move the cursor forward
  112028. * @returns This path cursor
  112029. */
  112030. moveAhead(step?: number): PathCursor;
  112031. /**
  112032. * Moves the cursor behind by the step amount
  112033. * @param step The amount to move the cursor back
  112034. * @returns This path cursor
  112035. */
  112036. moveBack(step?: number): PathCursor;
  112037. /**
  112038. * Moves the cursor by the step amount
  112039. * If the step amount is greater than one, an exception is thrown
  112040. * @param step The amount to move the cursor
  112041. * @returns This path cursor
  112042. */
  112043. move(step: number): PathCursor;
  112044. /**
  112045. * Ensures that the value is limited between zero and one
  112046. * @returns This path cursor
  112047. */
  112048. private ensureLimits;
  112049. /**
  112050. * Runs onchange callbacks on change (used by the animation engine)
  112051. * @returns This path cursor
  112052. */
  112053. private raiseOnChange;
  112054. /**
  112055. * Executes a function on change
  112056. * @param f A path cursor onchange callback
  112057. * @returns This path cursor
  112058. */
  112059. onchange(f: (cursor: PathCursor) => void): PathCursor;
  112060. }
  112061. }
  112062. declare module BABYLON {
  112063. /** @hidden */
  112064. export var blurPixelShader: {
  112065. name: string;
  112066. shader: string;
  112067. };
  112068. }
  112069. declare module BABYLON {
  112070. /** @hidden */
  112071. export var bones300Declaration: {
  112072. name: string;
  112073. shader: string;
  112074. };
  112075. }
  112076. declare module BABYLON {
  112077. /** @hidden */
  112078. export var instances300Declaration: {
  112079. name: string;
  112080. shader: string;
  112081. };
  112082. }
  112083. declare module BABYLON {
  112084. /** @hidden */
  112085. export var pointCloudVertexDeclaration: {
  112086. name: string;
  112087. shader: string;
  112088. };
  112089. }
  112090. // Mixins
  112091. interface Window {
  112092. mozIndexedDB: IDBFactory;
  112093. webkitIndexedDB: IDBFactory;
  112094. msIndexedDB: IDBFactory;
  112095. webkitURL: typeof URL;
  112096. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  112097. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  112098. WebGLRenderingContext: WebGLRenderingContext;
  112099. MSGesture: MSGesture;
  112100. CANNON: any;
  112101. AudioContext: AudioContext;
  112102. webkitAudioContext: AudioContext;
  112103. PointerEvent: any;
  112104. Math: Math;
  112105. Uint8Array: Uint8ArrayConstructor;
  112106. Float32Array: Float32ArrayConstructor;
  112107. mozURL: typeof URL;
  112108. msURL: typeof URL;
  112109. VRFrameData: any; // WebVR, from specs 1.1
  112110. DracoDecoderModule: any;
  112111. setImmediate(handler: (...args: any[]) => void): number;
  112112. }
  112113. interface HTMLCanvasElement {
  112114. requestPointerLock(): void;
  112115. msRequestPointerLock?(): void;
  112116. mozRequestPointerLock?(): void;
  112117. webkitRequestPointerLock?(): void;
  112118. /** Track wether a record is in progress */
  112119. isRecording: boolean;
  112120. /** Capture Stream method defined by some browsers */
  112121. captureStream(fps?: number): MediaStream;
  112122. }
  112123. interface CanvasRenderingContext2D {
  112124. msImageSmoothingEnabled: boolean;
  112125. }
  112126. interface MouseEvent {
  112127. mozMovementX: number;
  112128. mozMovementY: number;
  112129. webkitMovementX: number;
  112130. webkitMovementY: number;
  112131. msMovementX: number;
  112132. msMovementY: number;
  112133. }
  112134. interface Navigator {
  112135. mozGetVRDevices: (any: any) => any;
  112136. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112137. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112138. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112139. webkitGetGamepads(): Gamepad[];
  112140. msGetGamepads(): Gamepad[];
  112141. webkitGamepads(): Gamepad[];
  112142. }
  112143. interface HTMLVideoElement {
  112144. mozSrcObject: any;
  112145. }
  112146. interface Math {
  112147. fround(x: number): number;
  112148. imul(a: number, b: number): number;
  112149. }
  112150. interface WebGLProgram {
  112151. context?: WebGLRenderingContext;
  112152. vertexShader?: WebGLShader;
  112153. fragmentShader?: WebGLShader;
  112154. isParallelCompiled: boolean;
  112155. onCompiled?: () => void;
  112156. }
  112157. interface WebGLRenderingContext {
  112158. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  112159. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  112160. vertexAttribDivisor(index: number, divisor: number): void;
  112161. createVertexArray(): any;
  112162. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  112163. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  112164. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  112165. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  112166. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  112167. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  112168. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  112169. // Queries
  112170. createQuery(): WebGLQuery;
  112171. deleteQuery(query: WebGLQuery): void;
  112172. beginQuery(target: number, query: WebGLQuery): void;
  112173. endQuery(target: number): void;
  112174. getQueryParameter(query: WebGLQuery, pname: number): any;
  112175. getQuery(target: number, pname: number): any;
  112176. MAX_SAMPLES: number;
  112177. RGBA8: number;
  112178. READ_FRAMEBUFFER: number;
  112179. DRAW_FRAMEBUFFER: number;
  112180. UNIFORM_BUFFER: number;
  112181. HALF_FLOAT_OES: number;
  112182. RGBA16F: number;
  112183. RGBA32F: number;
  112184. R32F: number;
  112185. RG32F: number;
  112186. RGB32F: number;
  112187. R16F: number;
  112188. RG16F: number;
  112189. RGB16F: number;
  112190. RED: number;
  112191. RG: number;
  112192. R8: number;
  112193. RG8: number;
  112194. UNSIGNED_INT_24_8: number;
  112195. DEPTH24_STENCIL8: number;
  112196. /* Multiple Render Targets */
  112197. drawBuffers(buffers: number[]): void;
  112198. readBuffer(src: number): void;
  112199. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  112200. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  112201. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  112202. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  112203. // Occlusion Query
  112204. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  112205. ANY_SAMPLES_PASSED: number;
  112206. QUERY_RESULT_AVAILABLE: number;
  112207. QUERY_RESULT: number;
  112208. }
  112209. interface WebGLBuffer {
  112210. references: number;
  112211. capacity: number;
  112212. is32Bits: boolean;
  112213. }
  112214. interface WebGLProgram {
  112215. transformFeedback?: WebGLTransformFeedback | null;
  112216. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  112217. }
  112218. interface EXT_disjoint_timer_query {
  112219. QUERY_COUNTER_BITS_EXT: number;
  112220. TIME_ELAPSED_EXT: number;
  112221. TIMESTAMP_EXT: number;
  112222. GPU_DISJOINT_EXT: number;
  112223. QUERY_RESULT_EXT: number;
  112224. QUERY_RESULT_AVAILABLE_EXT: number;
  112225. queryCounterEXT(query: WebGLQuery, target: number): void;
  112226. createQueryEXT(): WebGLQuery;
  112227. beginQueryEXT(target: number, query: WebGLQuery): void;
  112228. endQueryEXT(target: number): void;
  112229. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  112230. deleteQueryEXT(query: WebGLQuery): void;
  112231. }
  112232. interface WebGLUniformLocation {
  112233. _currentState: any;
  112234. }
  112235. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  112236. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  112237. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  112238. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  112239. interface WebGLRenderingContext {
  112240. readonly RASTERIZER_DISCARD: number;
  112241. readonly DEPTH_COMPONENT24: number;
  112242. readonly TEXTURE_3D: number;
  112243. readonly TEXTURE_2D_ARRAY: number;
  112244. readonly TEXTURE_COMPARE_FUNC: number;
  112245. readonly TEXTURE_COMPARE_MODE: number;
  112246. readonly COMPARE_REF_TO_TEXTURE: number;
  112247. readonly TEXTURE_WRAP_R: number;
  112248. readonly HALF_FLOAT: number;
  112249. readonly RGB8: number;
  112250. readonly RED_INTEGER: number;
  112251. readonly RG_INTEGER: number;
  112252. readonly RGB_INTEGER: number;
  112253. readonly RGBA_INTEGER: number;
  112254. readonly R8_SNORM: number;
  112255. readonly RG8_SNORM: number;
  112256. readonly RGB8_SNORM: number;
  112257. readonly RGBA8_SNORM: number;
  112258. readonly R8I: number;
  112259. readonly RG8I: number;
  112260. readonly RGB8I: number;
  112261. readonly RGBA8I: number;
  112262. readonly R8UI: number;
  112263. readonly RG8UI: number;
  112264. readonly RGB8UI: number;
  112265. readonly RGBA8UI: number;
  112266. readonly R16I: number;
  112267. readonly RG16I: number;
  112268. readonly RGB16I: number;
  112269. readonly RGBA16I: number;
  112270. readonly R16UI: number;
  112271. readonly RG16UI: number;
  112272. readonly RGB16UI: number;
  112273. readonly RGBA16UI: number;
  112274. readonly R32I: number;
  112275. readonly RG32I: number;
  112276. readonly RGB32I: number;
  112277. readonly RGBA32I: number;
  112278. readonly R32UI: number;
  112279. readonly RG32UI: number;
  112280. readonly RGB32UI: number;
  112281. readonly RGBA32UI: number;
  112282. readonly RGB10_A2UI: number;
  112283. readonly R11F_G11F_B10F: number;
  112284. readonly RGB9_E5: number;
  112285. readonly RGB10_A2: number;
  112286. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  112287. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  112288. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  112289. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  112290. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  112291. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  112292. 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;
  112293. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  112294. readonly TRANSFORM_FEEDBACK: number;
  112295. readonly INTERLEAVED_ATTRIBS: number;
  112296. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  112297. createTransformFeedback(): WebGLTransformFeedback;
  112298. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  112299. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  112300. beginTransformFeedback(primitiveMode: number): void;
  112301. endTransformFeedback(): void;
  112302. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  112303. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112304. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112305. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112306. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  112307. }
  112308. interface ImageBitmap {
  112309. readonly width: number;
  112310. readonly height: number;
  112311. close(): void;
  112312. }
  112313. interface WebGLQuery extends WebGLObject {
  112314. }
  112315. declare var WebGLQuery: {
  112316. prototype: WebGLQuery;
  112317. new(): WebGLQuery;
  112318. };
  112319. interface WebGLSampler extends WebGLObject {
  112320. }
  112321. declare var WebGLSampler: {
  112322. prototype: WebGLSampler;
  112323. new(): WebGLSampler;
  112324. };
  112325. interface WebGLSync extends WebGLObject {
  112326. }
  112327. declare var WebGLSync: {
  112328. prototype: WebGLSync;
  112329. new(): WebGLSync;
  112330. };
  112331. interface WebGLTransformFeedback extends WebGLObject {
  112332. }
  112333. declare var WebGLTransformFeedback: {
  112334. prototype: WebGLTransformFeedback;
  112335. new(): WebGLTransformFeedback;
  112336. };
  112337. interface WebGLVertexArrayObject extends WebGLObject {
  112338. }
  112339. declare var WebGLVertexArrayObject: {
  112340. prototype: WebGLVertexArrayObject;
  112341. new(): WebGLVertexArrayObject;
  112342. };
  112343. // Type definitions for WebVR API
  112344. // Project: https://w3c.github.io/webvr/
  112345. // Definitions by: six a <https://github.com/lostfictions>
  112346. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  112347. interface VRDisplay extends EventTarget {
  112348. /**
  112349. * Dictionary of capabilities describing the VRDisplay.
  112350. */
  112351. readonly capabilities: VRDisplayCapabilities;
  112352. /**
  112353. * z-depth defining the far plane of the eye view frustum
  112354. * enables mapping of values in the render target depth
  112355. * attachment to scene coordinates. Initially set to 10000.0.
  112356. */
  112357. depthFar: number;
  112358. /**
  112359. * z-depth defining the near plane of the eye view frustum
  112360. * enables mapping of values in the render target depth
  112361. * attachment to scene coordinates. Initially set to 0.01.
  112362. */
  112363. depthNear: number;
  112364. /**
  112365. * An identifier for this distinct VRDisplay. Used as an
  112366. * association point in the Gamepad API.
  112367. */
  112368. readonly displayId: number;
  112369. /**
  112370. * A display name, a user-readable name identifying it.
  112371. */
  112372. readonly displayName: string;
  112373. readonly isConnected: boolean;
  112374. readonly isPresenting: boolean;
  112375. /**
  112376. * If this VRDisplay supports room-scale experiences, the optional
  112377. * stage attribute contains details on the room-scale parameters.
  112378. */
  112379. readonly stageParameters: VRStageParameters | null;
  112380. /**
  112381. * Passing the value returned by `requestAnimationFrame` to
  112382. * `cancelAnimationFrame` will unregister the callback.
  112383. * @param handle Define the hanle of the request to cancel
  112384. */
  112385. cancelAnimationFrame(handle: number): void;
  112386. /**
  112387. * Stops presenting to the VRDisplay.
  112388. * @returns a promise to know when it stopped
  112389. */
  112390. exitPresent(): Promise<void>;
  112391. /**
  112392. * Return the current VREyeParameters for the given eye.
  112393. * @param whichEye Define the eye we want the parameter for
  112394. * @returns the eye parameters
  112395. */
  112396. getEyeParameters(whichEye: string): VREyeParameters;
  112397. /**
  112398. * Populates the passed VRFrameData with the information required to render
  112399. * the current frame.
  112400. * @param frameData Define the data structure to populate
  112401. * @returns true if ok otherwise false
  112402. */
  112403. getFrameData(frameData: VRFrameData): boolean;
  112404. /**
  112405. * Get the layers currently being presented.
  112406. * @returns the list of VR layers
  112407. */
  112408. getLayers(): VRLayer[];
  112409. /**
  112410. * Return a VRPose containing the future predicted pose of the VRDisplay
  112411. * when the current frame will be presented. The value returned will not
  112412. * change until JavaScript has returned control to the browser.
  112413. *
  112414. * The VRPose will contain the position, orientation, velocity,
  112415. * and acceleration of each of these properties.
  112416. * @returns the pose object
  112417. */
  112418. getPose(): VRPose;
  112419. /**
  112420. * Return the current instantaneous pose of the VRDisplay, with no
  112421. * prediction applied.
  112422. * @returns the current instantaneous pose
  112423. */
  112424. getImmediatePose(): VRPose;
  112425. /**
  112426. * The callback passed to `requestAnimationFrame` will be called
  112427. * any time a new frame should be rendered. When the VRDisplay is
  112428. * presenting the callback will be called at the native refresh
  112429. * rate of the HMD. When not presenting this function acts
  112430. * identically to how window.requestAnimationFrame acts. Content should
  112431. * make no assumptions of frame rate or vsync behavior as the HMD runs
  112432. * asynchronously from other displays and at differing refresh rates.
  112433. * @param callback Define the eaction to run next frame
  112434. * @returns the request handle it
  112435. */
  112436. requestAnimationFrame(callback: FrameRequestCallback): number;
  112437. /**
  112438. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  112439. * Repeat calls while already presenting will update the VRLayers being displayed.
  112440. * @param layers Define the list of layer to present
  112441. * @returns a promise to know when the request has been fulfilled
  112442. */
  112443. requestPresent(layers: VRLayer[]): Promise<void>;
  112444. /**
  112445. * Reset the pose for this display, treating its current position and
  112446. * orientation as the "origin/zero" values. VRPose.position,
  112447. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  112448. * updated when calling resetPose(). This should be called in only
  112449. * sitting-space experiences.
  112450. */
  112451. resetPose(): void;
  112452. /**
  112453. * The VRLayer provided to the VRDisplay will be captured and presented
  112454. * in the HMD. Calling this function has the same effect on the source
  112455. * canvas as any other operation that uses its source image, and canvases
  112456. * created without preserveDrawingBuffer set to true will be cleared.
  112457. * @param pose Define the pose to submit
  112458. */
  112459. submitFrame(pose?: VRPose): void;
  112460. }
  112461. declare var VRDisplay: {
  112462. prototype: VRDisplay;
  112463. new(): VRDisplay;
  112464. };
  112465. interface VRLayer {
  112466. leftBounds?: number[] | Float32Array | null;
  112467. rightBounds?: number[] | Float32Array | null;
  112468. source?: HTMLCanvasElement | null;
  112469. }
  112470. interface VRDisplayCapabilities {
  112471. readonly canPresent: boolean;
  112472. readonly hasExternalDisplay: boolean;
  112473. readonly hasOrientation: boolean;
  112474. readonly hasPosition: boolean;
  112475. readonly maxLayers: number;
  112476. }
  112477. interface VREyeParameters {
  112478. /** @deprecated */
  112479. readonly fieldOfView: VRFieldOfView;
  112480. readonly offset: Float32Array;
  112481. readonly renderHeight: number;
  112482. readonly renderWidth: number;
  112483. }
  112484. interface VRFieldOfView {
  112485. readonly downDegrees: number;
  112486. readonly leftDegrees: number;
  112487. readonly rightDegrees: number;
  112488. readonly upDegrees: number;
  112489. }
  112490. interface VRFrameData {
  112491. readonly leftProjectionMatrix: Float32Array;
  112492. readonly leftViewMatrix: Float32Array;
  112493. readonly pose: VRPose;
  112494. readonly rightProjectionMatrix: Float32Array;
  112495. readonly rightViewMatrix: Float32Array;
  112496. readonly timestamp: number;
  112497. }
  112498. interface VRPose {
  112499. readonly angularAcceleration: Float32Array | null;
  112500. readonly angularVelocity: Float32Array | null;
  112501. readonly linearAcceleration: Float32Array | null;
  112502. readonly linearVelocity: Float32Array | null;
  112503. readonly orientation: Float32Array | null;
  112504. readonly position: Float32Array | null;
  112505. readonly timestamp: number;
  112506. }
  112507. interface VRStageParameters {
  112508. sittingToStandingTransform?: Float32Array;
  112509. sizeX?: number;
  112510. sizeY?: number;
  112511. }
  112512. interface Navigator {
  112513. getVRDisplays(): Promise<VRDisplay[]>;
  112514. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  112515. }
  112516. interface Window {
  112517. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  112518. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  112519. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  112520. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  112521. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  112522. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  112523. }
  112524. interface Gamepad {
  112525. readonly displayId: number;
  112526. }
  112527. interface XRDevice {
  112528. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  112529. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  112530. }
  112531. interface XRSession {
  112532. getInputSources(): Array<any>;
  112533. baseLayer: XRWebGLLayer;
  112534. requestFrameOfReference(type: string): Promise<void>;
  112535. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  112536. end(): Promise<void>;
  112537. requestAnimationFrame: Function;
  112538. addEventListener: Function;
  112539. }
  112540. interface XRSessionCreationOptions {
  112541. outputContext?: WebGLRenderingContext | null;
  112542. immersive?: boolean;
  112543. environmentIntegration?: boolean;
  112544. }
  112545. interface XRLayer {
  112546. getViewport: Function;
  112547. framebufferWidth: number;
  112548. framebufferHeight: number;
  112549. }
  112550. interface XRView {
  112551. projectionMatrix: Float32Array;
  112552. }
  112553. interface XRFrame {
  112554. getDevicePose: Function;
  112555. getInputPose: Function;
  112556. views: Array<XRView>;
  112557. baseLayer: XRLayer;
  112558. }
  112559. interface XRFrameOfReference {
  112560. }
  112561. interface XRWebGLLayer extends XRLayer {
  112562. framebuffer: WebGLFramebuffer;
  112563. }
  112564. declare var XRWebGLLayer: {
  112565. prototype: XRWebGLLayer;
  112566. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  112567. };